StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDbConfigNode.hh
1 /***************************************************************************
2  *
3  * $Id: StDbConfigNode.hh,v 1.17 2011/11/28 17:03:08 dmitry Exp $
4  *
5  * Author: R. Jeff Porter
6  ***************************************************************************
7  *
8  * Description: Node (directory) & db handle to hold list of dbtables
9  * Now (Dec2000) pure-virtual for hiding db & table (stl) part
10  *
11  ***************************************************************************
12  *
13  * $Log: StDbConfigNode.hh,v $
14  * Revision 1.17 2011/11/28 17:03:08 dmitry
15  * dbv override support in StDbLib,StDbBroker,St_db_Maker
16  *
17  * Revision 1.16 2001/01/22 18:37:52 porter
18  * Update of code needed in next year running. This update has little
19  * effect on the interface (only 1 method has been changed in the interface).
20  * Code also preserves backwards compatibility so that old versions of
21  * StDbLib can read new table structures.
22  * -Important features:
23  * a. more efficient low-level table structure (see StDbSql.cc)
24  * b. more flexible indexing for new systems (see StDbElememtIndex.cc)
25  * c. environment variable override KEYS for each database
26  * d. StMessage support & clock-time logging diagnostics
27  * -Cosmetic features
28  * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access
29  * f. removed codes that have been obsolete for awhile (e.g. db factories)
30  * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI
31  * and mysqlAccessor became StDbSql)
32  *
33  * Revision 1.15 2000/04/25 18:26:02 porter
34  * added flavor & production time as settable query fields in
35  * table &/or node. Associated SQL updated in mysqlAccessor.
36  * Flavor key supports "+" as an OR symbol.
37  *
38  * Revision 1.14 2000/03/28 17:03:18 porter
39  * Several upgrades:
40  * 1. configuration by timestamp for Conditions
41  * 2. query by whereClause made more systematic
42  * 3. conflict between db-stored comments & number lists resolved
43  * 4. ensure endtime is correct for certain query falures
44  * 5. dbstl.h->handles ObjectSpace & RogueWave difference (Online vs Offline)
45  *
46  * Revision 1.13 2000/01/27 05:54:33 porter
47  * Updated for compiling on CC5 + HPUX-aCC + KCC (when flags are reset)
48  * Fixed reConnect()+transaction model mismatch
49  * added some in-code comments
50  *
51  * Revision 1.12 2000/01/19 20:20:05 porter
52  * - finished transaction model needed by online
53  * - fixed CC5 compile problem in StDbNodeInfo.cc
54  * - replace TableIter class by StDbTableIter to prevent name problems
55  *
56  * Revision 1.11 2000/01/14 14:50:52 porter
57  * expanded use of verbose mode & fixed inconsistency in
58  * StDbNodeInfo::getElementID
59  *
60  * Revision 1.10 2000/01/10 20:37:53 porter
61  * expanded functionality based on planned additions or feedback from Online work.
62  * update includes:
63  * 1. basis for real transaction model with roll-back
64  * 2. limited SQL access via the manager for run-log & tagDb
65  * 3. balance obtained between enumerated & string access to databases
66  * 4. 3-levels of diagnostic output: Quiet, Normal, Verbose
67  * 5. restructured Node model for better XML support
68  *
69  * Revision 1.9 1999/12/28 21:31:41 porter
70  * added 'using std::vector' and 'using std::list' for Solaris CC5 compilation.
71  * Also fixed some warnings arising from the CC5 compiles
72  *
73  * Revision 1.8 1999/12/03 22:24:01 porter
74  * expanded functionality used by online, fixed bug in
75  * mysqlAccessor::getElementID(char*), & update StDbDataSet to
76  * conform to changes in Xml reader & writer
77  *
78  * Revision 1.7 1999/10/19 14:30:38 porter
79  * modifications relevant to use with StDbBroker and future merging with
80  * "params" database structure + some docs + suppressing diagnostics messages
81  *
82  * Revision 1.6 1999/09/30 02:06:03 porter
83  * add StDbTime to better handle timestamps, modify SQL content (mysqlAccessor)
84  * allow multiple rows (StDbTable), & Added the comment sections at top of
85  * each header and src file
86  *
87  **************************************************************************/
88 #ifndef STDBCONFIGNODE_HH
89 #define STDBCONFIGNODE_HH
90 
91 #include "StDbNode.hh"
92 #include "StDbTableIter.hh"
93 
94 class dbEnvList;
95 class StDbElementIndex;
96 class StDbTable;
97 
98 #ifdef __ROOT_
99 #include "TROOT.h"
100 #endif
101 
102 class StDbConfigNode : public StDbNode {
103 
104 protected:
105 
106  StDbConfigNode* mfirstChildNode;
107  StDbConfigNode* mnextNode;
108  StDbConfigNode* mparentNode;
109 
110  bool mhasData;
111  int mbranchID;
112  bool misDbNode;
113  void zeroNodes();
114 
115 public:
116 
117  StDbConfigNode( StDbConfigNode* parent,
118  const char* nodeName, const char* configName);
119  StDbConfigNode( StDbConfigNode* parent, StDbNode& node);
120  StDbConfigNode( StDbType type, StDbDomain domain,
121  const char* nodeName, const char* configName="none");
122  virtual ~StDbConfigNode();
123 
124  // node & tree operations
125  void setNextNode(StDbConfigNode* node);
126  void setParentNode(StDbConfigNode* node);
127  void setFirstChildNode(StDbConfigNode* node);
128  virtual void setChildNode(StDbConfigNode* node);
129  void appendNode(StDbConfigNode* node);
130  StDbConfigNode* getNextNode();
131  StDbConfigNode* getParentNode();
132  StDbConfigNode* getFirstChildNode();
133  void deleteTree();
134  virtual void addChildren(dbEnvList* elist) = 0;
135  void deleteChildren();
136 
137  // check container status
138  bool hasChildren();
139  bool hasData();
140  int getBranchID();
141  void setBranchID(int branchID);
142  void setIsDbNode(bool isDbNode);
143  bool isDbNode();
144  void printTree(int depth);
145 
146  // DB & Table Index operations
147  virtual void resetConfig(const char* config, int opt=0) =0;
148  virtual int buildTree(int opt=0) =0;
149  virtual StDbElementIndex* getElementIndex() =0;
150  virtual void setElementIndexInfo(const char* indexName, int indexID) =0;
151  virtual void getElementIndexInfo(char*& indexname, int& indexID) =0;
152  virtual int getNumIndeces() const =0;
153 
154  // Table operations --> pure virtual for db & stl dependencies
155  virtual StDbTable* addDbTable(const char* tableName,
156  const char* version="default") =0;
157  virtual StDbTable* addTable (const char* tableName,
158  const char* version="default") =0;
159  virtual StDbTable* addTable(StDbNode* node) =0;
160  virtual StDbTable* findTable(const char* name, const char* sPath="/")=0;
161  virtual StDbTable* findLocalTable(const char* name) =0;
162  virtual void removeTable(StDbTable* table) =0;
163  virtual StDbTableIter* getStDbTableIter() =0;
164  virtual bool compareTables(StDbTable* tab1, StDbTable* tab2) =0;
165  virtual void printTables(int depth) =0;
166  virtual void printNumberStats() =0;
167  virtual void getNumberStats(unsigned int& nNodes,
168  unsigned int& ntables,
169  unsigned int& numBytes) =0;
170 
171  // set the table flavors in full sub-tree or local list
172  virtual void setTablesFlavor(const char* flavor) =0;
173  virtual void setTablesProdTime(unsigned int ptime) =0;
174  virtual void setTablesProdTimeOverride(unsigned int ptime, char* dbType = 0, char* dbDomain = 0) =0;
175  void setFlavor(const char* flavor);
176  void setProdTime(unsigned int ptime);
177  void setProdTimeOverride(unsigned int ptime, char* dbType = 0, char* dbDomain = 0);
178 
179  // More node operations
180  StDbConfigNode* findConfigNode(StDbType t, StDbDomain d, const char* sPath);
181  StDbConfigNode* findConfigNode(StDbType t, StDbDomain d);
182  StDbConfigNode* findConfigNode(const char* sPath);
183  StDbConfigNode* findChildConfigNode(const char* nodeName);
184 #ifdef __ROOT__
185  ClassDef(StDbConfigNode,0)
186 #endif
187 
188 };
189 
190 inline void StDbConfigNode::setNextNode(StDbConfigNode* node){ mnextNode=node;}
191 inline StDbConfigNode* StDbConfigNode::getNextNode() { return mnextNode; };
192 inline StDbConfigNode* StDbConfigNode::getParentNode() { return mparentNode; };
193 inline StDbConfigNode* StDbConfigNode::getFirstChildNode(){ return mfirstChildNode; };
194 inline bool StDbConfigNode::hasData(){ return mhasData;};
195 inline int StDbConfigNode::getBranchID() { return mbranchID; };
196 inline void StDbConfigNode::setBranchID(int branchID) { mbranchID=branchID; };
197 inline void StDbConfigNode::setIsDbNode(bool isDbNode){misDbNode=isDbNode; };
198 inline bool StDbConfigNode::isDbNode() { return misDbNode; };
199 inline bool StDbConfigNode::hasChildren(){return (mfirstChildNode) ? true : false; };
200 
201 #endif
202 
203 
204 
205 
206