StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDataBaseI.hh
1 /***************************************************************************
2  *
3  * $Id: StDataBaseI.hh,v 1.3 2003/01/10 04:19:19 porter Exp $
4  *
5  * Author: R. Jeff Porter
6  ***************************************************************************
7  *
8  * Description: Abstract class for Star specific SQL queries
9  *
10  ***************************************************************************
11  *
12  * $Log: StDataBaseI.hh,v $
13  * Revision 1.3 2003/01/10 04:19:19 porter
14  * added feature of getting timestamp list (but no data) for a table.
15  * fixed 2 features sometimes used in online in query-by-whereclause.
16  * removed a stray 'cout' in a routine that is rarely accessed
17  *
18  * Revision 1.2 2001/10/26 20:59:46 porter
19  * fixed new endtime flag from previous checkin. made StDataBaseI available
20  * at root-cli.
21  *
22  * Revision 1.1 2001/01/22 18:37:50 porter
23  * Update of code needed in next year running. This update has little
24  * effect on the interface (only 1 method has been changed in the interface).
25  * Code also preserves backwards compatibility so that old versions of
26  * StDbLib can read new table structures.
27  * -Important features:
28  * a. more efficient low-level table structure (see StDbSql.cc)
29  * b. more flexible indexing for new systems (see StDbElememtIndex.cc)
30  * c. environment variable override KEYS for each database
31  * d. StMessage support & clock-time logging diagnostics
32  * -Cosmetic features
33  * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access
34  * f. removed codes that have been obsolete for awhile (e.g. db factories)
35  * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI
36  * and mysqlAccessor became StDbSql)
37  *
38  *
39  **************************************************************************/
40 #ifndef STDATABASEI_HH
41 #define STDATABASEI_HH
42 
43 class StDbNode;
44 class StDbTable;
45 class StDbConfigNode;
46 class StDbElementIndex;
47 
48 #include "StDbDefs.hh"
49 
50 #ifdef __ROOT__
51 #include "TROOT.h"
52 #endif
53 
54 class StDataBaseI {
55 
56 protected:
57  // enumerated database specification
58  StDbType mdbType;
59  StDbDomain mdbDomain;
60 
61  //
62  // dbName = "typeName_domainName" or "typeName" if domainName=Star
63  // typeName => mapped from dbType
64  // domainName => mapped from dbDomain
65  //
66 
67  char* mdbName;
68  char* mtypeName;
69  char* mdomainName;
70 
71  StDbStoreType mdbStore; // for future evolution of changes in internal
72  // storage structure & different SQL
73 public:
74 
75  StDataBaseI();
76  StDataBaseI(StDbType type, StDbDomain domain);
77  StDataBaseI(const char* typeName, const char* domainName);
78 
79  virtual ~StDataBaseI();
80 
81  virtual void setDataBase(StDbType type, StDbDomain domain);
82  virtual void setDataBase(const char* typeName, const char* domainName);
83  virtual void setDataBase(const char* dbName);
84 
85  virtual void setDbType(StDbType type);
86  virtual void setDbDomain(StDbDomain domain);
87  virtual StDbType getDbType() const ;
88  virtual StDbDomain getDbDomain() const ;
89 
90  virtual void setDbName(const char* dbName);
91  virtual void setTypeName(const char* typeName);
92  virtual void setDomainName(const char* domainName);
93  virtual char* getDbName() const ;
94  virtual char* getTypeName() const ;
95  virtual char* getDomainName() const ;
96  virtual char* printDbName();
97  virtual char* printTypeName();
98  virtual char* printDomainName();
99  virtual bool checkDbName(const char* name);
100  virtual bool checkDbType(const char* type);
101  virtual bool checkDbDomain(const char* domain);
102 
103  virtual StDbStoreType getDbStoreType() const;
104  virtual void setDbStoreType(StDbStoreType type);
105 
106  // DB-Implementation Specific methods
107  virtual void use() = 0;
108  virtual void close() = 0;
109  virtual int QueryDb(StDbConfigNode* node) = 0;
110  virtual int QueryDb(StDbNode* node) = 0;
111  virtual int QueryDb(StDbTable* table, unsigned int reqTime) = 0;
112  virtual int QueryDb(StDbTable* table, const char* whereClause) = 0;
113  virtual unsigned int* QueryDbTimes(StDbTable* table,
114  const char* whereClause, int opt=0) = 0;
115  virtual int QueryDbFunction(StDbTable* table,
116  const char* whereClause, char* funcName) = 0;
117  virtual int QueryDescriptor(StDbTable* table) = 0;
118  virtual int WriteDb(StDbTable* table, unsigned int storeTime) = 0;
119  virtual int WriteDb(StDbConfigNode* node, int parentID, int& configID) = 0;
120 
121  virtual int storeConfigNode(StDbConfigNode* node) = 0;
122  virtual int storeTableNode(StDbTable* table) = 0;
123  virtual bool insertNodeRelation(int configID, int parent, int child) = 0;
124  virtual bool rollBack(StDbNode* node) = 0;
125  virtual bool rollBack(StDbTable* table) = 0;
126 
127  virtual unsigned int getUnixTime(const char* time) = 0;
128  virtual char* getDateTime(unsigned int time) = 0;
129  virtual int* selectElements(const char* elementName,
130  StDbElementIndex* inval,
131  int& numElements) = 0;
132 #ifdef __ROOT__
133  ClassDef(StDataBaseI,0)
134 #endif
135 
136 };
137 
138 inline void StDataBaseI::setDbType(StDbType type) {mdbType = type; };
139 inline void StDataBaseI::setDbDomain(StDbDomain domain) {mdbDomain = domain; }
140 inline StDbType StDataBaseI::getDbType() const { return mdbType; };
141 inline StDbDomain StDataBaseI::getDbDomain() const { return mdbDomain; };
142 inline StDbStoreType StDataBaseI::getDbStoreType() const {return mdbStore;};
143 inline void StDataBaseI::setDbStoreType(StDbStoreType type) {mdbStore=type; };
144 
145 #endif