BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
Column.h
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/rdbModel/rdbModel/Tables/Column.h,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $
2#ifndef RDBMODEL_COLUMN_H
3#define RDBMODEL_COLUMN_H
4#include <vector>
5#include <string>
6#include <utility>
8// #include "rdbModel/Tables/Table.h"
9
10namespace rdbModel {
11
12 // class Table;
13 class Datatype;
14 class Enum;
15 class Table;
16 class XercesBuilder;
17
18
19
20 /**
21 * rdbModel representation of a(n SQL-like) table description
22 */
23 class Column {
24 // class ColumnSource; // embedded class, described below
25
26 public:
27 /// Source of value. Note timestamp with value current time should
28 /// be indicated by contents value CONTENTSupdateTime or (if only
29 /// upon insert) CONTENTS enterTime
30 enum FROM {
31 FROMdefault = 1, // enduser can override default, however
33 FROMnow, // datatype must be timestamp - deprecated
36 };
37
38 /// Hints to program in case FROM field is FROMprogram
39 enum CONTENTS {
45
46 };
47
48 Column(Table* myTable=0) : m_myTable(myTable), m_type(0),
49 m_isPrimaryKey(false) {
50 m_contents = CONTENTSunspecified;
51 m_default = std::string("");};
52 // Column(Table* myTable=0) : m_myTable(myTable), m_type(0), m_source(0) {};
53 ~Column();
54
55
56 const std::string& getName() const {return m_name; };
57 const std::string& getComment() const {return m_comment;};
58
59 const std::string& getDefault() const {return m_default;}
60
61 const std::string& getTableName() const;
62
63 Datatype* getDatatype() const {return m_type;};
64
65 /// Return pointer to Enum object associated with this column (if
66 /// none, return null pointer).
67 Enum* getEnum() const;
68
69 /** See if supplied value meets constraints of column definition
70 * @arg val std::string representation of value to be checked
71 * @arg set true if value is to be written to column; false
72 * if just being used, e.g. in "where" clause
73 */
74 bool okValue(const std::string& val, bool set=true) const;
75
76 /// Return true if otherCol and this have compatible datatypes
77 bool isCompatible(const Column* otherCol) const;
78
79 /// Returns true if column may take on value NULL
80 bool nullAllowed() const { return m_null;}
81
82 bool stickyInsert() const { return m_stickyInsert;}
83
84 bool isPrimaryKey() const {return m_isPrimaryKey;}
85
86 bool isAutoIncrement() const;
87
88 FROM getSourceType() const {return m_from;}
89 CONTENTS getContentsType() const {return m_contents;}
90
91 /**
92 Handle special literal values, depending loosely on column datatype.
93 Most Column objects won't do any interpretation, but, for example,
94 timestamp-like columns may substitute for "NOW"
95 Return true if any substitution was done
96 */
97 bool interpret(const std::string& interpType, std::string&val);
98
100
101 private:
102 friend class rdbModel::XercesBuilder; // needs access to add.. methods
103
104 Table* m_myTable;
105
106 std::string m_name;
107 std::string m_comment;
108 Datatype* m_type;
109
110 std::string m_default;
111 FROM m_from;
112 CONTENTS m_contents;
113
114 /// Can this field have the value NULL?
115 bool m_null;
116 /// For multi-insert, does this column normally keep same value
117 /// for all the inserts?
118 bool m_stickyInsert;
119
120 /// Is this column a primary key?
121 bool m_isPrimaryKey;
122
123 };
124
125 // Do we want Column* for first component or just the column name?
126 class FieldVal {
127 // Column* m_pCol;
128 public:
129 FieldVal(std::string colname, std::string val, bool isNull=false) :
130 m_colname(colname), m_val(val), m_null(isNull) { }
131 std::string m_colname;
132 std::string m_val;
133 bool m_null; // true if field val is NULL; then will ignore m_val
134 };
135
136 /// Function object used to sort FieldValPar objects by column name
138 public:
139 // bool operator() (const Column* a, const Column* b) {
140 bool operator() (const FieldVal& a, const FieldVal& b) {
141 return ((a.m_colname).compare(b.m_colname) < 0);
142 // return (a.first->getName().compare(b.first->getName()) < 0);
143 }
144 };
145
146 /**
147 @class Row
148 A collection of column names and values.
149 */
150 class Row {
151 public:
152 Row() : m_sorted(false) {m_fields.clear();}
153 Row(std::vector<FieldVal>& fields) : m_fields(fields), m_sorted(false) {}
154
155 ~Row() { m_fields.clear(); }
156 void rowSort();
157 void addField(const FieldVal& f) {m_fields.push_back(f); m_sorted = false;}
158 void clear() {m_fields.clear();}
159
160 FieldVal* find(std::string colname);
161
162 /// Reorder information suitable for Connection::insert
163 void regroup(std::vector<std::string>& colNames,
164 std::vector<std::string>& colVals,
165 std::vector<std::string>& nullCols) const;
166 private:
167 std::vector<FieldVal> m_fields;
168 bool m_sorted;
169 };
170}
171#endif
**********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
bool isPrimaryKey() const
Definition: Column.h:84
Datatype * getDatatype() const
Definition: Column.h:63
Column(Table *myTable=0)
Definition: Column.h:48
CONTENTS getContentsType() const
Definition: Column.h:89
const std::string & getDefault() const
Definition: Column.h:59
bool isAutoIncrement() const
Definition: Column.cxx:37
@ FROMautoIncrement
Definition: Column.h:32
const std::string & getComment() const
Definition: Column.h:57
Enum * getEnum() const
Definition: Column.cxx:15
const std::string & getTableName() const
Definition: Column.cxx:17
const std::string & getName() const
Definition: Column.h:56
FROM getSourceType() const
Definition: Column.h:88
Visitor::VisitorState accept(Visitor *v)
Definition: Column.cxx:58
bool nullAllowed() const
Returns true if column may take on value NULL.
Definition: Column.h:80
bool stickyInsert() const
Definition: Column.h:82
bool isCompatible(const Column *otherCol) const
Return true if otherCol and this have compatible datatypes.
Definition: Column.cxx:32
bool interpret(const std::string &interpType, std::string &val)
Definition: Column.cxx:41
bool okValue(const std::string &val, bool set=true) const
Definition: Column.cxx:21
CONTENTS
Hints to program in case FROM field is FROMprogram.
Definition: Column.h:39
@ CONTENTSupdateTime
Definition: Column.h:44
@ CONTENTSserviceName
Definition: Column.h:41
@ CONTENTSinsertTime
Definition: Column.h:43
@ CONTENTSunspecified
Definition: Column.h:40
@ CONTENTSusername
Definition: Column.h:42
Function object used to sort FieldValPar objects by column name.
Definition: Column.h:137
bool operator()(const FieldVal &a, const FieldVal &b)
Definition: Column.h:140
FieldVal(std::string colname, std::string val, bool isNull=false)
Definition: Column.h:129
std::string m_val
Definition: Column.h:132
std::string m_colname
Definition: Column.h:131
FieldVal * find(std::string colname)
Definition: Column.cxx:73
Row(std::vector< FieldVal > &fields)
Definition: Column.h:153
void rowSort()
Definition: Column.cxx:65
void regroup(std::vector< std::string > &colNames, std::vector< std::string > &colVals, std::vector< std::string > &nullCols) const
Reorder information suitable for Connection::insert.
Definition: Column.cxx:98
void addField(const FieldVal &f)
Definition: Column.h:157
void clear()
Definition: Column.h:158
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
const double b
Definition: slope.cxx:9