Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

StDbNode Class Reference

#include <StDbNode.hh>

Inheritance diagram for StDbNode:

StDbConfigNode StDbTable StDbConfigNodeImpl List of all members.

Public Member Functions

 StDbNode ()
 StDbNode (const char *name, const char *versionKey)
 StDbNode (const char *name)
 StDbNode (StDbNode &node)
virtual ~StDbNode ()
char * getName ()
char * printName ()
char * getMyName ()
char * getVersion ()
char * printVersion ()
char * getDbName ()
char * printDbName ()
StDbType getDbType () const
StDbDomain getDbDomain () const
int getNodeID () const
char * getNodeType ()
char * printNodeType ()
void setName (const char *nodeName)
void setVersion (const char *nodeVersion)
void setDbName (const char *nodeDbName)
void setDbType (StDbType type)
void setDbDomain (StDbDomain domain)
void setNodeID (int id)
void setNodeType (const char *nodeType)
bool canRollBack () const
void addWrittenNode (int dataID)
void commit ()
bool checkName (const char *nodeName) const
bool checkVersion (const char *nodeVersion) const
bool checkNode (const char *nodeName, const char *nodeVersion) const
bool IsConfigured () const
void setConfigured (bool isConfigured)
bool isNode (StDbType type, StDbDomain domain)
virtual bool IsTable () const
char * mstrDup (const char *s2)
int * decodeElementID (const char *elementID, int &numRows)
char * getNextID (char *&currentElement) const

Protected Attributes

char * mname
char * mversion
char * mdbName
StDbType mdbType
StDbDomain mdbDomain
int mnodeID
char * mnodeType
bool misConfigured
bool mcanRollBack

Constructor & Destructor Documentation

StDbNode::StDbNode  )  [inline]
 

Definition at line 90 of file StDbNode.hh.

00090 : mname(0), mversion(0), mdbName(0), mnodeID(0), mnodeType(0), misConfigured(false), mcanRollBack(false) {};

StDbNode::StDbNode const char *  name,
const char *  versionKey
 

Definition at line 84 of file StDbNode.cc.

00084 : mname(0), mversion(0), mdbName(0), mnodeID(0),mnodeType(0){ 00085 00086 setName(name); 00087 setVersion(versionKey); 00088 misConfigured = false; 00089 mcanRollBack = false; 00090 }

StDbNode::StDbNode const char *  name  ) 
 

Definition at line 93 of file StDbNode.cc.

00093 : mname(0), mversion(0), mdbName(0), mnodeID(0) ,mnodeType(0){ 00094 setName(name); 00095 setVersion(StDbDefaults::Instance()->printVersion()); 00096 misConfigured = false; 00097 mcanRollBack = false; 00098 }

StDbNode::StDbNode StDbNode node  ) 
 

Definition at line 101 of file StDbNode.cc.

00101 { 00102 00103 mname = node.getName(); 00104 mversion = node.getVersion(); 00105 mdbName = node.getDbName(); 00106 mdbType = node.getDbType(); 00107 mdbDomain = node.getDbDomain(); 00108 mnodeID = node.getNodeID(); 00109 mnodeType = node.getNodeType(); 00110 misConfigured = node.IsConfigured(); 00111 mcanRollBack = node.canRollBack(); 00112 }

StDbNode::~StDbNode  )  [virtual]
 

Definition at line 115 of file StDbNode.cc.

00115 { 00116 if(mname) delete [] mname; 00117 if(mversion) delete [] mversion; 00118 if(mdbName) delete [] mdbName; 00119 if(mnodeType) delete [] mnodeType; 00120 }


Member Function Documentation

void StDbNode::addWrittenNode int  dataID  )  [inline]
 

Definition at line 158 of file StDbNode.hh.

00158 { 00159 mcanRollBack=true; 00160 mnodeID=dataID; 00161 }

bool StDbNode::canRollBack  )  const [inline]
 

Definition at line 157 of file StDbNode.hh.

00157 { return mcanRollBack; }

bool StDbNode::checkName const char *  nodeName  )  const [inline]
 

Definition at line 163 of file StDbNode.hh.

00163 { 00164 return (mname && (strcmp(mname,nodeName)==0)) ? true : false; 00165 }

bool StDbNode::checkNode const char *  nodeName,
const char *  nodeVersion
const [inline]
 

Definition at line 169 of file StDbNode.hh.

00169 { 00170 return (checkName(name) && checkVersion(version)) ? true : false; 00171 }

bool StDbNode::checkVersion const char *  nodeVersion  )  const [inline]
 

Definition at line 166 of file StDbNode.hh.

00166 { 00167 return (mversion && (strcmp(mversion,nodeVersion)==0)) ? true : false; 00168 }

void StDbNode::commit  )  [inline]
 

Definition at line 162 of file StDbNode.hh.

00162 { mcanRollBack = false; }

int * StDbNode::decodeElementID const char *  elementID,
int &  numRows
 

Definition at line 147 of file StDbNode.cc.

00147 { 00148 00149 numRows=1; 00150 int * retVal = 0; 00151 char* id=strstr((char*)elemID,"None"); 00152 00153 if(id){ 00154 numRows=1; 00155 int* e = new int[1]; *e=0; 00156 return e; 00157 } 00158 00159 char* tmpName = new char[strlen(elemID)+1]; 00160 strcpy(tmpName,elemID); 00161 00162 int numElements = 1; 00163 id = strstr(tmpName,","); 00164 char* id1; 00165 char* id2; 00166 00167 id2 = strstr(tmpName,"-"); 00168 StString sl; 00169 00170 if(id2 && ( (id && id2<id) || !id)){ 00171 id=id2; 00172 id[0]=','; 00173 sl<<"r"; 00174 } else { 00175 sl<<"l"; 00176 } 00177 00178 int numEntries = 1; 00179 if(id)id++; 00180 while(id){ 00181 // cout << "id = " << id << endl; 00182 numEntries++; 00183 id1=strstr(id,","); 00184 id2=strstr(id,"-"); 00185 id = id1; 00186 if(id && id2 && id2<id){ 00187 id=id2; 00188 id[0]=','; 00189 sl<<"r"; 00190 } else { 00191 sl<<"l"; 00192 } 00193 if(id)id++; 00194 } 00195 char* islist=new char[strlen((sl.str()).c_str())+1]; 00196 strcpy(islist,(sl.str()).c_str()); 00197 00198 // cout << "My string list = " << islist << endl; 00199 00200 int* tmpElements = new int[100000]; 00201 char* p1=&tmpName[0]; 00202 char* anID=0; 00203 anID = getNextID(p1); 00204 tmpElements[0] = atoi(anID); 00205 if(anID)delete [] anID; 00206 numElements = 1; 00207 int iEnd, iStart, k; 00208 for(int ient=1;ient<numEntries;ient++){ 00209 anID = getNextID(p1); 00210 if(islist[ient-1]=='r'){ 00211 iEnd = atoi(anID); 00212 iStart = tmpElements[numElements-1]; 00213 int irange=iEnd-iStart; 00214 for(int ir=1;ir<=irange;ir++){ 00215 numElements++; 00216 tmpElements[numElements-1]=iStart+ir; 00217 } 00218 } else { 00219 numElements++; 00220 tmpElements[numElements-1]=atoi(anID); 00221 } 00222 if(anID) delete [] anID; 00223 } 00224 00225 retVal = new int[numElements]; 00226 for(k=0;k<numElements;k++)retVal[k]=tmpElements[k]; 00227 numRows = numElements; 00228 00229 delete [] islist; 00230 delete [] tmpElements; 00231 delete [] tmpName; 00232 00233 return retVal; 00234 }

StDbDomain StDbNode::getDbDomain  )  const [inline]
 

Definition at line 147 of file StDbNode.hh.

00147 { return mdbDomain; }

char * StDbNode::getDbName  ) 
 

Definition at line 126 of file StDbNode.cc.

00126 { return mstrDup((const char*)mdbName); }

StDbType StDbNode::getDbType  )  const [inline]
 

Definition at line 146 of file StDbNode.hh.

00146 { return mdbType;}

char * StDbNode::getMyName  )  [inline]
 

Definition at line 145 of file StDbNode.hh.

00145 { return printName(); }

char * StDbNode::getName  ) 
 

Definition at line 124 of file StDbNode.cc.

00124 { return mstrDup((const char*)mname); };

char * StDbNode::getNextID char *&  currentElement  )  const
 

Definition at line 238 of file StDbNode.cc.

00238 { 00239 00240 char* nextID = 0; 00241 if(!currentElement)return nextID; 00242 00243 char* id = strstr(currentElement,","); 00244 00245 if(!id) { 00246 nextID = new char[strlen(currentElement)+1]; 00247 strcpy(nextID,currentElement); 00248 currentElement = 0; 00249 } else { 00250 int iloc = id-currentElement; 00251 nextID = new char[iloc+1]; 00252 strncpy(nextID,currentElement,iloc); 00253 nextID[iloc]='\0'; 00254 currentElement = id; currentElement++; 00255 } 00256 00257 return nextID; 00258 }

int StDbNode::getNodeID  )  const [inline]
 

Definition at line 150 of file StDbNode.hh.

00150 { return mnodeID; }

char * StDbNode::getNodeType  ) 
 

Definition at line 127 of file StDbNode.cc.

00127 { return mstrDup(mnodeType); }

char * StDbNode::getVersion  ) 
 

Definition at line 125 of file StDbNode.cc.

00125 { return mstrDup((const char*)mversion); }

bool StDbNode::IsConfigured  )  const [inline]
 

Definition at line 153 of file StDbNode.hh.

00153 { return misConfigured; }

bool StDbNode::isNode StDbType  type,
StDbDomain  domain
[inline]
 

Definition at line 154 of file StDbNode.hh.

00154 { 00155 return ( (type==mdbType) && (domain==mdbDomain) ) ? true : false; 00156 }

bool StDbNode::IsTable  )  const [inline, virtual]
 

Reimplemented in StDbTable.

Definition at line 172 of file StDbNode.hh.

00172 { return false; }

char * StDbNode::mstrDup const char *  s2  ) 
 

Definition at line 261 of file StDbNode.cc.

00261 { 00262 00263 char* s1=0; 00264 if(!s2) return s1; 00265 s1 = new char[strlen(s2)+1]; 00266 strcpy(s1,s2); 00267 return s1; 00268 }

char * StDbNode::printDbName  )  [inline]
 

Definition at line 142 of file StDbNode.hh.

00142 { return mdbName; };

char * StDbNode::printName  )  [inline]
 

Definition at line 141 of file StDbNode.hh.

00141 { return mname; };

char * StDbNode::printNodeType  )  [inline]
 

Definition at line 143 of file StDbNode.hh.

00143 { return mnodeType; };

char * StDbNode::printVersion  )  [inline]
 

Definition at line 144 of file StDbNode.hh.

00144 { return mversion; };

void StDbNode::setConfigured bool  isConfigured  )  [inline]
 

Definition at line 152 of file StDbNode.hh.

00152 { misConfigured=isC; }

void StDbNode::setDbDomain StDbDomain  domain  )  [inline]
 

Definition at line 149 of file StDbNode.hh.

00149 { mdbDomain=domain; }

void StDbNode::setDbName const char *  nodeDbName  ) 
 

Definition at line 137 of file StDbNode.cc.

00137 { 00138 if(mdbName)delete [] mdbName; 00139 mdbName=mstrDup(dbName); 00140 }

void StDbNode::setDbType StDbType  type  )  [inline]
 

Definition at line 148 of file StDbNode.hh.

00148 { mdbType=type;}

void StDbNode::setName const char *  nodeName  ) 
 

Definition at line 129 of file StDbNode.cc.

00129 { 00130 if(mname) delete [] mname; 00131 mname=mstrDup(nodeName); 00132 }

void StDbNode::setNodeID int  id  )  [inline]
 

Definition at line 151 of file StDbNode.hh.

00151 {mnodeID = id; }

void StDbNode::setNodeType const char *  nodeType  ) 
 

Definition at line 141 of file StDbNode.cc.

00141 { 00142 if(mnodeType) delete [] mnodeType; 00143 mnodeType=mstrDup(type); 00144 }

void StDbNode::setVersion const char *  nodeVersion  ) 
 

Definition at line 133 of file StDbNode.cc.

00133 { 00134 if(mversion) delete [] mversion; 00135 mversion=mstrDup(version); 00136 }


Member Data Documentation

bool StDbNode::mcanRollBack [protected]
 

Definition at line 86 of file StDbNode.hh.

StDbDomain StDbNode::mdbDomain [protected]
 

Definition at line 79 of file StDbNode.hh.

char* StDbNode::mdbName [protected]
 

Definition at line 77 of file StDbNode.hh.

StDbType StDbNode::mdbType [protected]
 

Definition at line 78 of file StDbNode.hh.

bool StDbNode::misConfigured [protected]
 

Definition at line 85 of file StDbNode.hh.

char* StDbNode::mname [protected]
 

Definition at line 75 of file StDbNode.hh.

int StDbNode::mnodeID [protected]
 

Definition at line 82 of file StDbNode.hh.

char* StDbNode::mnodeType [protected]
 

Definition at line 83 of file StDbNode.hh.

char* StDbNode::mversion [protected]
 

Definition at line 76 of file StDbNode.hh.


The documentation for this class was generated from the following files:
Generated on Thu Aug 24 14:45:59 2006 for Doxygen by doxygen 1.3.7