BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/rdbModel/rdbModel/Rdb.h
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/rdbModel/rdbModel/Rdb.h,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $
2#ifndef RDBMODEL_RDB_H
3#define RDBMODEL_RDB_H
4#include <vector>
5#include <string>
6// #include "detModel/Sections/Section.h"
7
8#include "rdbModel/Management/Visitor.h"
9
10namespace rdbModel {
11
12 class Table;
13 class Column;
14 class Index;
15 // class Assertion;
16 class XercesBuilder;
17 class Connection;
18 class Row;
19
20 // Values for database fields may be specified in various ways
21 enum FIELDTYPE {
22 FIELDTYPElit = 0, // literal value
23 FIELDTYPEold, // col name, refers to (value of) col in existing row
24 FIELDTYPEtoBe, // col name, refers to (value of) col in proposed row
25 FIELDTYPEask, // supply value at the time of the operation
26 FIELDTYPElitDef, // literal but may be overridden
27 FIELDTYPEoldDef, // comes from existing row, may be overridden
28 FIELDTYPEtoBeDef // comes from proposed row, may be overridden
29 };
30
31 /**
32 * This is the main container of all the rdb description.
33 * The Manager is responsible for its creation and destruction.
34 * Provide both a query interface (provide various functions
35 * to look up components by name) and also accept visitors.
36 *
37 * Adapted from detModel::Gdd class, written by R. Giannitrapani
38 * and D. Favretto
39 * @author J. Bogart
40 */
41 class Rdb {
42 public:
43 /** This is the destructor; it should be called only by the manager
44 * destructor. It starts the destruction of all the objects created
45 * by the builder
46 */
47 virtual ~Rdb();
48 Rdb() : m_connection(0) { }
49
50
51 unsigned getMajorVersion(){return m_majorVersion;};
52 unsigned getMinorVersion(){return m_minorVersion;};
53
54 const std::string& getCVSid(){return m_CVSid;};
55
56 const std::string& getDbName(){return m_dbName;};
57 // Not sure we want to expose this:
58 // This method gives back a pointer to the tables vector
59 // std::vector <Table*> getTables(){return m_tables;};
60
61 Table* getTable(const std::string& name) const;
62 Column* getColumn(const std::string& tableName,
63 const std::string& colName) const;
64
65 Index* getIndex(const std::string& tableName,
66 const std::string& indexName) const;
67
68 unsigned int getNTable() const {return m_tables.size();}
69
70 // Do we want an unset as well? Or just call this with arg == 0 ?
71 void setConnection(Connection* connection);
72
73 /**
74 insertRow has only one value-added feature as compared to
75 an SQL insert: it will take care of fields intended to be
76 filled by the service (e.g., insert and update timestamps)
77 */
78 int insertRow(const std::string& tName, Row& row, int* serial=0) const;
79
80 /**
81 The two forms of smart insert, in addition to filling in the
82 service fields, as insertRow does, do various forms of
83 consistency checking and may even update pre-existing
84 rows.
85 */
86 int insertLatest(Table* t, Row& row, int* serial=0) const;
87 int insertLatest(const std::string& tName, Row& row, int* serial=0) const;
88
89 int supersedeRow(const std::string& tName, Row& row, int oldKey,
90 int* newKey=0) const;
91
92 /**
93 Fills in service fields, then invokes Connection::update
94 */
95 int updateRows(const std::string& tName, Row& row, Assertion* where) const;
96
97
98 /// This is the recursive accept for the visitor pattern
99 unsigned int accept(Visitor* v);
100 // This is the non recursive accept for the visitor pattern
101 // Not yet sure we need it
102 // Visitor::VisitorState acceptNotRec(Visitor* v);
103
104 // This method builds a global volumes map for all the sections
105 // void buildVolumeMap();
106 // This method builds the global constants maps for all the constants
107 //void buildConstantsMap();
108
109 private:
110 // Must make each concrete implementation of Builder a friend since
111 // derived classes don't inherit friendliness.
112 friend class rdbModel::XercesBuilder;
113
114 // void setDTDversion(std::string pdtd){m_DTDversion = pdtd;};
115 void setCVSid(std::string pcvs){m_CVSid = pcvs;};
116
117 void addTable(Table* t){m_tables.push_back(t);};
118
119 // Maybe have private table map to support look-up by name?
120 // Or maybe don't bother. The target application will have
121 // a very small number of tables, so a linear search is
122 // perfectly ok.
123
124 std::vector<Table* > m_tables;
125
126 /// SQL database name (e.g., "calib")
127 std::string m_dbName;
128 /// The Schema version from the input xml description
129 unsigned m_majorVersion;
130 unsigned m_minorVersion;
131 // std::string m_DTDversion;
132 /// The CVSid from the input xml description
133 std::string m_CVSid;
134 Connection* m_connection;
135
136 };
137}
138
139#endif //RDB_H
140
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
int supersedeRow(const std::string &tName, Row &row, int oldKey, int *newKey=0) const
Table * getTable(const std::string &name) const
int insertLatest(Table *t, Row &row, int *serial=0) const
Index * getIndex(const std::string &tableName, const std::string &indexName) const
void setConnection(Connection *connection)
virtual ~Rdb()
int updateRows(const std::string &tName, Row &row, Assertion *where) const
int insertLatest(const std::string &tName, Row &row, int *serial=0) const
Column * getColumn(const std::string &tableName, const std::string &colName) const
int insertRow(const std::string &tName, Row &row, int *serial=0) const
unsigned int accept(Visitor *v)
This is the recursive accept for the visitor pattern.
int t()
Definition: t.c:1