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

StDbManager.cc

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * 00003 * $Id: StDbManager.cc,v 1.31 2004/01/15 00:02:25 fisyak Exp $ 00004 * 00005 * Author: R. Jeff Porter 00006 *************************************************************************** 00007 * 00008 * Description: Manages access to Servers and passes Query-by-Table to db 00009 * 00010 *************************************************************************** 00011 * 00012 * $Log: StDbManager.cc,v $ 00013 * Revision 1.31 2004/01/15 00:02:25 fisyak 00014 * Replace ostringstream => StString, add option for alpha 00015 * 00016 * Revision 1.30 2003/09/16 22:44:17 porter 00017 * got rid of all ostrstream objects; replaced with StString+string. 00018 * modified rules.make and added file stdb_streams.h for standalone compilation 00019 * 00020 * Revision 1.29 2003/09/02 17:57:49 perev 00021 * gcc 3.2 updates + WarnOff 00022 * 00023 * Revision 1.28 2002/01/30 15:40:47 porter 00024 * changed limits on flavor tag & made defaults retrieving more readable 00025 * 00026 * Revision 1.27 2001/01/22 18:37:55 porter 00027 * Update of code needed in next year running. This update has little 00028 * effect on the interface (only 1 method has been changed in the interface). 00029 * Code also preserves backwards compatibility so that old versions of 00030 * StDbLib can read new table structures. 00031 * -Important features: 00032 * a. more efficient low-level table structure (see StDbSql.cc) 00033 * b. more flexible indexing for new systems (see StDbElememtIndex.cc) 00034 * c. environment variable override KEYS for each database 00035 * d. StMessage support & clock-time logging diagnostics 00036 * -Cosmetic features 00037 * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access 00038 * f. removed codes that have been obsolete for awhile (e.g. db factories) 00039 * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI 00040 * and mysqlAccessor became StDbSql) 00041 * 00042 * Revision 1.26 2000/08/15 22:51:51 porter 00043 * Added Root2DB class from Masashi Kaneta 00044 * + made code more robust against requesting data from non-existent databases 00045 * 00046 * Revision 1.25 2000/06/30 01:57:02 porter 00047 * fixed a delete bug & small memory leak found by Akio via Insure++ , 00048 * updated SetTable() method for containing idList, corrected enumeration 00049 * map to rhic domain for Conditions_rhic database 00050 * 00051 * Revision 1.24 2000/06/02 13:37:36 porter 00052 * built up list of minor changes: 00053 * - made buffer more robust for certain null inputs 00054 * - fixed small leak in StDbTables & restructure call to createMemory 00055 * - added dbRhic as a database domain in StDbDefs 00056 * - added setUser() in StDbManager 00057 * - added more diagnostic printouts in mysqlAccessor.cc 00058 * 00059 * Revision 1.23 2000/05/04 15:13:11 porter 00060 * added dbOnl, dbRich, dbMwc domains as standards 00061 * 00062 * Revision 1.22 2000/04/25 18:26:03 porter 00063 * added flavor & production time as settable query fields in 00064 * table &/or node. Associated SQL updated in mysqlAccessor. 00065 * Flavor key supports "+" as an OR symbol. 00066 * 00067 * Revision 1.21 2000/03/28 17:03:18 porter 00068 * Several upgrades: 00069 * 1. configuration by timestamp for Conditions 00070 * 2. query by whereClause made more systematic 00071 * 3. conflict between db-stored comments & number lists resolved 00072 * 4. ensure endtime is correct for certain query falures 00073 * 5. dbstl.h->handles ObjectSpace & RogueWave difference (Online vs Offline) 00074 * 00075 * Revision 1.20 2000/03/01 20:56:16 porter 00076 * 3 items: 00077 * 1. activated reConnect for server timeouts 00078 * 2. activated connection sharing; better resource utilization but poorer 00079 * logging 00080 * 3. made rollback method in mysqlAccessor more robust (affects writes only) 00081 * 00082 * Revision 1.19 2000/02/24 20:30:45 porter 00083 * fixed padding for uchar; beginTime in mysqlAccessor; 00084 * added rollback safety checkes in StDbManger 00085 * 00086 * Revision 1.18 2000/02/18 16:58:09 porter 00087 * optimization of table-query, + whereClause gets timeStamp if indexed 00088 * + fix to write multiple rows algorithm 00089 * 00090 * Revision 1.17 2000/02/15 20:27:44 porter 00091 * Some updates to writing to the database(s) via an ensemble (should 00092 * not affect read methods & haven't in my tests. 00093 * - closeAllConnections(node) & closeConnection(table) method to mgr. 00094 * - 'NullEntry' version to write, with setStoreMode in table; 00095 * - updated both StDbTable's & StDbTableDescriptor's copy-constructor 00096 * 00097 * Revision 1.16 2000/01/27 20:27:17 porter 00098 * fixed error logic for table, config, or table-list not-found 00099 * 00100 * Revision 1.15 2000/01/27 05:54:34 porter 00101 * Updated for compiling on CC5 + HPUX-aCC + KCC (when flags are reset) 00102 * Fixed reConnect()+transaction model mismatch 00103 * added some in-code comments 00104 * 00105 * Revision 1.14 2000/01/19 20:20:05 porter 00106 * - finished transaction model needed by online 00107 * - fixed CC5 compile problem in StDbNodeInfo.cc 00108 * - replace TableIter class by StDbTableIter to prevent name problems 00109 * 00110 * Revision 1.13 2000/01/14 14:50:52 porter 00111 * expanded use of verbose mode & fixed inconsistency in 00112 * StDbNodeInfo::getElementID 00113 * 00114 * Revision 1.12 2000/01/10 20:37:54 porter 00115 * expanded functionality based on planned additions or feedback from Online work. 00116 * update includes: 00117 * 1. basis for real transaction model with roll-back 00118 * 2. limited SQL access via the manager for run-log & tagDb 00119 * 3. balance obtained between enumerated & string access to databases 00120 * 4. 3-levels of diagnostic output: Quiet, Normal, Verbose 00121 * 5. restructured Node model for better XML support 00122 * 00123 * Revision 1.11 1999/12/28 21:31:42 porter 00124 * added 'using std::vector' and 'using std::list' for Solaris CC5 compilation. 00125 * Also fixed some warnings arising from the CC5 compiles 00126 * 00127 * Revision 1.10 1999/12/03 22:24:01 porter 00128 * expanded functionality used by online, fixed bug in 00129 * mysqlAccessor::getElementID(char*), & update StDbDataSet to 00130 * conform to changes in Xml reader & writer 00131 * 00132 * Revision 1.9 1999/10/19 14:30:39 porter 00133 * modifications relevant to use with StDbBroker and future merging with 00134 * "params" database structure + some docs + suppressing diagnostics messages 00135 * 00136 * Revision 1.8 1999/09/30 02:06:07 porter 00137 * add StDbTime to better handle timestamps, modify SQL content (mysqlAccessor) 00138 * allow multiple rows (StDbTable), & Added the comment sections at top of 00139 * each header and src file 00140 * 00141 **************************************************************************/ 00142 #include "StDbManager.hh" 00143 #include "StDbManagerImpl.hh" // for new method only 00144 #include "StDbMessenger.hh" 00145 #include "stdb_streams.h" 00146 #ifdef __ROOT__ 00147 ClassImp(StDbManager) 00148 #endif 00149 00150 StDbManager* StDbManager::mInstance=0; 00152 StDbManager* StDbManager::Instance(){ 00153 if(!mInstance)mInstance=new StDbManagerImpl(); 00154 return mInstance; 00155 } 00156 00157 StDbManager::StDbManager(): misVerbose(false), misQuiet(false), muserName(0), mpWord(0), misTimeLogged(true ) { 00158 Messenger=new StDbMessenger(); 00159 updateMessLevel(); 00160 }; 00161 StDbManager::~StDbManager(){ 00162 if(muserName) delete [] muserName; 00163 if(mpWord) delete [] mpWord; 00164 mInstance=0; 00165 } 00166 00168 void 00169 StDbManager::turnOffTimeLogging(){ misTimeLogged=false; } 00170 00172 char* 00173 StDbManager::mstringDup(const char* str){ 00174 00175 char* retString=0; 00176 if(!str)return retString; 00177 retString = new char[strlen(str)+1]; 00178 strcpy(retString,str); 00179 00180 return retString; 00181 } 00182 00184 int 00185 StDbManager::printInfo(const char* m1, StDbMessLevel ml, int lineNumber, const char* className, const char* methodName){ 00186 00187 Messenger->printMessage(m1,ml,lineNumber,className,methodName); 00188 return 0; 00189 } 00190 00192 int 00193 StDbManager::printInfo(const char* m1, const char* m2, StDbMessLevel ml, int lineNumber, const char* className, const char* methodName){ 00194 00195 StString ms; 00196 ms<<m1<<" "<<m2; 00197 printInfo((ms.str()).c_str(),ml,lineNumber,className,methodName); 00198 return 0; 00199 } 00200 00201 00202 00204 void 00205 StDbManager::setUser(const char* userName, const char* pWord){ 00206 00207 if(userName){ 00208 if(muserName) delete [] muserName; 00209 muserName=mstringDup(userName); 00210 } 00211 if(pWord){ 00212 if(mpWord) delete [] mpWord; 00213 mpWord = mstringDup(pWord); 00214 } 00215 } 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225

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