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

StDbServer.cc

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * 00003 * $Id: StDbServer.cc,v 1.14 2001/01/22 18:37:58 porter Exp $ 00004 * 00005 * Author: R. Jeff Porter 00006 *************************************************************************** 00007 * 00008 * Description: Server class for DB-access 00009 * 00010 *************************************************************************** 00011 * 00012 * $Log: StDbServer.cc,v $ 00013 * Revision 1.14 2001/01/22 18:37:58 porter 00014 * Update of code needed in next year running. This update has little 00015 * effect on the interface (only 1 method has been changed in the interface). 00016 * Code also preserves backwards compatibility so that old versions of 00017 * StDbLib can read new table structures. 00018 * -Important features: 00019 * a. more efficient low-level table structure (see StDbSql.cc) 00020 * b. more flexible indexing for new systems (see StDbElememtIndex.cc) 00021 * c. environment variable override KEYS for each database 00022 * d. StMessage support & clock-time logging diagnostics 00023 * -Cosmetic features 00024 * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access 00025 * f. removed codes that have been obsolete for awhile (e.g. db factories) 00026 * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI 00027 * and mysqlAccessor became StDbSql) 00028 * 00029 * Revision 1.13 2000/08/15 22:51:52 porter 00030 * Added Root2DB class from Masashi Kaneta 00031 * + made code more robust against requesting data from non-existent databases 00032 * 00033 * Revision 1.12 2000/03/01 20:56:16 porter 00034 * 3 items: 00035 * 1. activated reConnect for server timeouts 00036 * 2. activated connection sharing; better resource utilization but poorer 00037 * logging 00038 * 3. made rollback method in mysqlAccessor more robust (affects writes only) 00039 * 00040 * Revision 1.11 2000/02/24 20:30:47 porter 00041 * fixed padding for uchar; beginTime in mysqlAccessor; 00042 * added rollback safety checkes in StDbManger 00043 * 00044 * Revision 1.10 2000/02/15 20:27:44 porter 00045 * Some updates to writing to the database(s) via an ensemble (should 00046 * not affect read methods & haven't in my tests. 00047 * - closeAllConnections(node) & closeConnection(table) method to mgr. 00048 * - 'NullEntry' version to write, with setStoreMode in table; 00049 * - updated both StDbTable's & StDbTableDescriptor's copy-constructor 00050 * 00051 * Revision 1.9 2000/01/27 05:54:34 porter 00052 * Updated for compiling on CC5 + HPUX-aCC + KCC (when flags are reset) 00053 * Fixed reConnect()+transaction model mismatch 00054 * added some in-code comments 00055 * 00056 * Revision 1.8 2000/01/19 20:20:06 porter 00057 * - finished transaction model needed by online 00058 * - fixed CC5 compile problem in StDbNodeInfo.cc 00059 * - replace TableIter class by StDbTableIter to prevent name problems 00060 * 00061 * Revision 1.7 2000/01/10 20:37:54 porter 00062 * expanded functionality based on planned additions or feedback from Online work. 00063 * update includes: 00064 * 1. basis for real transaction model with roll-back 00065 * 2. limited SQL access via the manager for run-log & tagDb 00066 * 3. balance obtained between enumerated & string access to databases 00067 * 4. 3-levels of diagnostic output: Quiet, Normal, Verbose 00068 * 5. restructured Node model for better XML support 00069 * 00070 * Revision 1.6 1999/12/03 22:24:01 porter 00071 * expanded functionality used by online, fixed bug in 00072 * mysqlAccessor::getElementID(char*), & update StDbDataSet to 00073 * conform to changes in Xml reader & writer 00074 * 00075 * Revision 1.5 1999/09/30 02:06:08 porter 00076 * add StDbTime to better handle timestamps, modify SQL content (mysqlAccessor) 00077 * allow multiple rows (StDbTable), & Added the comment sections at top of 00078 * each header and src file 00079 * 00080 **************************************************************************/ 00081 #include "StDbServer.hh" 00082 #include "StDbTable.h" 00083 #include "StDbConfigNode.hh" 00084 #include <string.h> 00085 00086 #define __CLASS__ "StDbServer" 00087 00089 00090 StDbServer::StDbServer(): mserverName(0),mhostName(0), munixSocket(0), muserName(0), mpword(0), misDefault(false){}; 00091 00092 StDbServer::StDbServer(const char* name, const char* host, const char* sock, int port) : mserverName(0),mhostName(0), munixSocket(0), muserName(0), mpword(0), mportNumber(port), misDefault(false) { 00093 00094 setServerName(name); 00095 setHostName(host); 00096 setUnixSocket(sock); 00097 }; 00098 00099 StDbServer::StDbServer(StDbServer& server) : mserverName(0), mhostName(0), munixSocket(0) , muserName(0), mpword(0), misDefault(false) { 00100 00101 setServerName(server.printServerName()); 00102 setHostName(server.printHostName()); 00103 setUnixSocket(server.printUnixSocket()); 00104 setPortNumber(server.getPortNumber()); 00105 } 00107 00108 StDbServer::~StDbServer(){ 00109 if(mserverName)delete [] mserverName; 00110 if(mhostName) delete [] mhostName; 00111 if(munixSocket)delete [] munixSocket; 00112 if(muserName) delete [] muserName; 00113 if(mpword) delete [] mpword; 00114 } 00116 00117 void StDbServer::setHostName(const char* name) {mhostName=mstringDup(name); } 00118 void StDbServer::setUnixSocket(const char* name){munixSocket=mstringDup(name);} 00119 void StDbServer::setServerName(const char* name){mserverName=mstringDup(name);} 00120 00122 00123 void 00124 StDbServer::setUser(const char* name, const char* pword){ 00125 muserName=mstringDup(name); 00126 mpword=mstringDup(pword); 00127 } 00128 00130 00131 char* StDbServer::getHostName() const { return mstringDup(mhostName); }; 00132 char* StDbServer::getUnixSocket() const { return mstringDup(munixSocket); } 00133 char* StDbServer::getServerName() const { return mstringDup(mserverName); } 00134 00136 00137 char* StDbServer::mstringDup(const char* str) const { 00138 00139 char* retString=0; 00140 if(!str)return retString; 00141 retString = new char[strlen(str)+1]; 00142 strcpy(retString,str); 00143 return retString; 00144 } 00145 00146 #undef __CLASS__

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