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

StDbNode.hh

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * 00003 * $Id: StDbNode.hh,v 1.6 2001/02/08 23:23:56 porter Exp $ 00004 * 00005 * Author: R. Jeff Porter 00006 *************************************************************************** 00007 * 00008 * Description: Base-class database entities 00009 * 00010 *************************************************************************** 00011 * 00012 * $Log: StDbNode.hh,v $ 00013 * Revision 1.6 2001/02/08 23:23:56 porter 00014 * fixed initialization of schemaID in table & fixed some warnings when 00015 * compiled with NODEBUG 00016 * 00017 * Revision 1.5 2001/01/22 18:37:58 porter 00018 * Update of code needed in next year running. This update has little 00019 * effect on the interface (only 1 method has been changed in the interface). 00020 * Code also preserves backwards compatibility so that old versions of 00021 * StDbLib can read new table structures. 00022 * -Important features: 00023 * a. more efficient low-level table structure (see StDbSql.cc) 00024 * b. more flexible indexing for new systems (see StDbElememtIndex.cc) 00025 * c. environment variable override KEYS for each database 00026 * d. StMessage support & clock-time logging diagnostics 00027 * -Cosmetic features 00028 * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access 00029 * f. removed codes that have been obsolete for awhile (e.g. db factories) 00030 * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI 00031 * and mysqlAccessor became StDbSql) 00032 * 00033 * Revision 1.4 2000/04/25 18:26:03 porter 00034 * added flavor & production time as settable query fields in 00035 * table &/or node. Associated SQL updated in mysqlAccessor. 00036 * Flavor key supports "+" as an OR symbol. 00037 * 00038 * Revision 1.3 2000/02/15 20:27:44 porter 00039 * Some updates to writing to the database(s) via an ensemble (should 00040 * not affect read methods & haven't in my tests. 00041 * - closeAllConnections(node) & closeConnection(table) method to mgr. 00042 * - 'NullEntry' version to write, with setStoreMode in table; 00043 * - updated both StDbTable's & StDbTableDescriptor's copy-constructor 00044 * 00045 * Revision 1.2 2000/01/19 20:20:06 porter 00046 * - finished transaction model needed by online 00047 * - fixed CC5 compile problem in StDbNodeInfo.cc 00048 * - replace TableIter class by StDbTableIter to prevent name problems 00049 * 00050 * Revision 1.1 2000/01/10 20:37:54 porter 00051 * expanded functionality based on planned additions or feedback from Online work. 00052 * update includes: 00053 * 1. basis for real transaction model with roll-back 00054 * 2. limited SQL access via the manager for run-log & tagDb 00055 * 3. balance obtained between enumerated & string access to databases 00056 * 4. 3-levels of diagnostic output: Quiet, Normal, Verbose 00057 * 5. restructured Node model for better XML support 00058 * 00059 * 00060 ***************************************************************************/ 00061 #ifndef STDBNODE_HH 00062 #define STDBNODE_HH 00063 00064 #include "StDbDefs.hh" 00065 #include <string.h> 00066 #ifdef __ROOT__ 00067 #include "TROOT.h" 00068 #endif 00069 00070 class StDbNode { 00071 00072 protected: 00073 00074 // unique node identfier 00075 char * mname; 00076 char * mversion; 00077 char * mdbName; 00078 StDbType mdbType; 00079 StDbDomain mdbDomain; 00080 00081 // from db 00082 int mnodeID; 00083 char* mnodeType; 00084 00085 bool misConfigured; 00086 bool mcanRollBack; 00087 00088 public: 00089 00090 StDbNode() : mname(0), mversion(0), mdbName(0), mnodeID(0), mnodeType(0), misConfigured(false), mcanRollBack(false) {}; 00091 StDbNode(const char* name, const char* versionKey); 00092 StDbNode(const char* name); 00093 StDbNode(StDbNode& node); 00094 00095 virtual ~StDbNode(); 00096 00097 char* getName() ; 00098 char* printName() ; 00099 char* getMyName() ; 00100 char* getVersion() ; 00101 char* printVersion() ; 00102 char* getDbName() ; 00103 char* printDbName(); 00104 StDbType getDbType() const; 00105 StDbDomain getDbDomain() const; 00106 int getNodeID() const; 00107 char* getNodeType() ; 00108 char* printNodeType(); 00109 00110 void setName(const char* nodeName); 00111 void setVersion(const char* nodeVersion); 00112 void setDbName(const char* nodeDbName); 00113 void setDbType(StDbType type); 00114 void setDbDomain(StDbDomain domain); 00115 void setNodeID(int id); 00116 void setNodeType(const char* nodeType); 00117 00118 // write transactions 00119 bool canRollBack() const; 00120 void addWrittenNode(int dataID); 00121 void commit(); 00122 00123 // string comparisons 00124 bool checkName(const char* nodeName) const; 00125 bool checkVersion(const char* nodeVersion) const; 00126 bool checkNode(const char* nodeName, const char* nodeVersion) const; 00127 bool IsConfigured() const; 00128 void setConfigured(bool isConfigured); 00129 bool isNode(StDbType type, StDbDomain domain); 00130 virtual bool IsTable() const; 00131 00132 // helper functions 00133 char* mstrDup(const char* s2) ; // strdup isn't ANSI 00134 int* decodeElementID(const char* elementID, int& numRows) ; 00135 char* getNextID(char*& currentElement) const; 00136 #ifdef __ROOT__ 00137 ClassDef(StDbNode,0) 00138 #endif 00139 00140 }; 00141 inline char* StDbNode::printName() { return mname; }; 00142 inline char* StDbNode::printDbName() { return mdbName; }; 00143 inline char* StDbNode::printNodeType() { return mnodeType; }; 00144 inline char* StDbNode::printVersion() { return mversion; }; 00145 inline char* StDbNode::getMyName() { return printName(); } 00146 inline StDbType StDbNode::getDbType() const { return mdbType;} 00147 inline StDbDomain StDbNode::getDbDomain() const { return mdbDomain; } 00148 inline void StDbNode::setDbType(StDbType type) { mdbType=type;} 00149 inline void StDbNode::setDbDomain(StDbDomain domain) { mdbDomain=domain; } 00150 inline int StDbNode::getNodeID() const { return mnodeID; } 00151 inline void StDbNode::setNodeID(int id ) {mnodeID = id; } 00152 inline void StDbNode::setConfigured(bool isC){ misConfigured=isC; } 00153 inline bool StDbNode::IsConfigured() const { return misConfigured; } 00154 inline bool StDbNode::isNode(StDbType type, StDbDomain domain){ 00155 return ( (type==mdbType) && (domain==mdbDomain) ) ? true : false; 00156 } 00157 inline bool StDbNode::canRollBack() const { return mcanRollBack; } 00158 inline void StDbNode::addWrittenNode(int dataID){ 00159 mcanRollBack=true; 00160 mnodeID=dataID; 00161 } 00162 inline void StDbNode::commit() { mcanRollBack = false; } 00163 inline bool StDbNode::checkName(const char* nodeName) const { 00164 return (mname && (strcmp(mname,nodeName)==0)) ? true : false; 00165 } 00166 inline bool StDbNode::checkVersion(const char* nodeVersion) const { 00167 return (mversion && (strcmp(mversion,nodeVersion)==0)) ? true : false; 00168 } 00169 inline bool StDbNode::checkNode(const char* name, const char* version) const { 00170 return (checkName(name) && checkVersion(version)) ? true : false; 00171 } 00172 inline bool StDbNode::IsTable() const { return false; } 00173 #endif

Generated on Thu Aug 24 14:45:26 2006 for Doxygen by doxygen 1.3.7