StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDbServerImpl.hh
1 /***************************************************************************
2  *
3  * $Id: StDbServerImpl.hh,v 1.2 2006/08/17 02:58:58 deph Exp $
4  *
5  * Author: R. Jeff Porter
6  ***************************************************************************
7  *
8  * Description: Implements Server Interface class for DB-access
9  *
10  * A Server is specified in StDbServer base class by :
11  * name, host, unix-socket, port-number
12  * A Server contains a list of databases distinquishable by names.
13  * The currentDb us specified by "useDb" methods
14  * The Server knows only the db-list built via "add" methods.
15  *
16  ***************************************************************************
17  *
18  * $Log: StDbServerImpl.hh,v $
19  * Revision 1.2 2006/08/17 02:58:58 deph
20  * updated load balancer - removing hard-coded nodes from API to xml
21  *
22  * Revision 1.1 2001/01/22 18:37:59 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 STDBSERVERIMPL_HH
41 #define STDBSERVERIMPL_HH
42 
43 #include "StDbServer.hh"
44 #include "MysqlDb.h"
45 #include "StDbBuffer.h"
46 
47 #include <list>
48 #ifdef ST_NO_TEMPLATE_DEF_ARGS
49 typedef list<StDataBaseI*,allocator<StDataBaseI*> > DbList;
50 #else
51 #if !defined(ST_NO_NAMESPACES)
52 using std::list;
53 #endif
54 typedef list<StDataBaseI*> DbList;
55 #endif
56 
57 class StDbServerImpl : public StDbServer {
58 
59 protected:
60 
61  MysqlDb Db;
62  StDbBuffer buff;
63 
64  StDataBaseI* mcurrentDb;
65  DbList mdataBases;
66 
67  void deleteDataBases();
68 
69 
70 public:
71 
73  StDbServerImpl(const char* name, const char* host,
74  const char* socket, int port);
76  virtual ~StDbServerImpl();
77 
78  virtual void addDataBase(StDbType type, StDbDomain domain);
79  virtual void addDataBase(const char* typeName, const char* domName);
80  virtual StDataBaseI* useDb(StDbType type, StDbDomain domain);
81  virtual StDataBaseI* useDb(const char* typeName, const char* domName);
82  virtual StDataBaseI* useDb();
83  virtual bool isConnected();
84  virtual void closeConnection();
85  virtual void setTimeLogging(bool isTimeLogged);
86  virtual double getQueryTimes();
87  virtual double getSocketTimes();
88  virtual double getConnectTimes();
89 
90  void PointMysqlDb(StDbManagerImpl* m) {Db.my_manager = m;}
91 
92 };
93 
94 #endif