TDsKey.cxx

Go to the documentation of this file.
00001 // @(#)root/table:$Id: TDsKey.cxx 35875 2010-09-30 08:04:13Z brun $
00002 // Author: Victor Perevoztchikov (fine@bnl.gov)   01/03/2001
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
00006  * Copyright (C) 2001 [BNL] Brookhaven National Laboratory.              *
00007  * All rights reserved.                                                  *
00008  *                                                                       *
00009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00011  *************************************************************************/
00012 
00013 #include <stdio.h>
00014 #include <string.h>
00015 #include <stdlib.h>
00016 #include <assert.h>
00017 #include "TDsKey.h"
00018 
00019 
00020 //______________________________________________________________________________
00021 TDsKey::TDsKey(const char *name,UInt_t *uk,int nk) : fUrr(nk)
00022 {
00023    //to be documented
00024    if (name) SetName(name);
00025    SetUrr(uk,nk);
00026 }
00027 //______________________________________________________________________________
00028 TDsKey::TDsKey(const char *name,UInt_t uk) : fUrr(1)
00029 {
00030    //to be documented
00031    if (name) SetName(name);
00032    SetUrr(&uk,1);
00033 }
00034 //______________________________________________________________________________
00035 TDsKey::TDsKey(UInt_t uRun,UInt_t uEvent) :fUrr(2)
00036 {
00037    //to be documented
00038    UInt_t u[2]; u[0]=uRun; u[1]=uEvent;
00039    int n = 1; if (u[1]) n=2;
00040    SetUrr(u,n);
00041 }
00042 
00043 //______________________________________________________________________________
00044 void TDsKey::SetUrr(const UInt_t *uk,int nk)
00045 {
00046    //to be documented
00047    int n;
00048    fUrr[0] = 0;
00049    if (!uk) return;
00050    for (n=1;n<nk && uk[n]; n++){}
00051    fUrr.Set(n,(Int_t *)uk);
00052 }
00053 //______________________________________________________________________________
00054 TDsKey &TDsKey::operator=( const TDsKey &from)
00055 {
00056    //to be documented
00057    SetName(from.GetName());
00058    fUrr = from.fUrr;
00059    return *this;
00060 }
00061 //______________________________________________________________________________
00062 TDsKey &TDsKey::operator=( UInt_t from)
00063 {
00064    //to be documented
00065    SetUrr(&from,1);
00066    return *this;
00067 }
00068 //______________________________________________________________________________
00069 TDsKey &TDsKey::operator=( const char *from)
00070 {
00071    //to be documented
00072    SetName(from);
00073    return *this;
00074 }
00075 //______________________________________________________________________________
00076 Bool_t TDsKey::operator==(const TDsKey &from) const
00077 {
00078    // Compare two keys
00079    Bool_t res  =    ( fName == from.fName )
00080                  && ( fUrr.GetSize() == from.fUrr.GetSize() ) ;
00081 
00082    Bool_t numMatch = kTRUE;
00083    int i = 0;
00084    for (; i < fUrr.GetSize(); i++) {
00085       if ( fUrr[i] != from.fUrr[i] )  {
00086          numMatch =kFALSE;
00087          break;
00088       }
00089    }
00090    return ( res && numMatch ) ;
00091 }
00092 //______________________________________________________________________________
00093 void  TDsKey::Update( const TDsKey &from, const char *name)
00094 {
00095    //to be documented
00096    fUrr = from.fUrr;
00097    if (name) SetName(name);
00098 }
00099 //______________________________________________________________________________
00100 TString TDsKey::GetKey() const
00101 {
00102    //to be documented
00103    char ubuf[12];
00104    TString tk(fName);
00105    Int_t lUrr = fUrr.GetSize();
00106    for (int i=0;i<lUrr;i++){
00107       tk +=".";
00108       snprintf(ubuf,12,"%010u",fUrr[i]);
00109       tk +=ubuf;
00110    }
00111    return tk;
00112 }
00113 //______________________________________________________________________________
00114 void TDsKey::SetKey(const char *key)
00115 {
00116    //to be documented
00117    const char *cc;
00118    int n = strchr(key,'.') - key;
00119    assert(n>0 && n<100);
00120    fName.Replace(0,999,key,n);
00121    Int_t i = 0;
00122    for (cc=key+n;*cc=='.'; cc+=11,i++)
00123       fUrr.AddAt(strtoul(cc+1,0,10),i);
00124 }
00125 //______________________________________________________________________________
00126 UInt_t  TDsKey::GetSum() const
00127 {
00128    //to be documented
00129    UInt_t s = fUrr[0];
00130    for (int i=1;i<fUrr.GetSize();i++) s^=fUrr[i];
00131    return s;
00132 }
00133 
00134 

Generated on Tue Jul 5 14:45:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1