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