CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
Column.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/rdbModel/src/Tables/Column.cxx,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $
2
7
8#include <algorithm>
9namespace rdbModel {
10
12 delete m_type;
13 }
14
15 Enum* Column::getEnum() const {return m_type->getEnum();}
16
17 const std::string& Column::getTableName() const {
18 return m_myTable->getName();
19 }
20
21 bool Column::okValue(const std::string& val, bool set) const {
22 // auto increment and datetime values are established by rdbms
23 if (set) {
24
25 if ( (m_from == FROMautoIncrement) ||
26 (m_from == FROMnow)) return false;
27 }
28
29 return m_type->okValue(val);
30 }
31
32 bool Column::isCompatible(const Column* otherCol) const {
33 return m_type->isCompatible(otherCol->m_type);
34 }
35
36
38 return (m_from == FROMautoIncrement);
39 }
40
41 bool Column::interpret(const std::string& interpType, std::string& val) {
42 // Currently only interpretation is for timestamp-like columns.
43 // Value of interpType must be "time" and val must be "NOW".
44 // In this case, substitute ascii current time
45 if (interpType.compare(std::string("time")) != 0) return false;
46
47 Datatype::TYPES dtype = m_type->getType();
48 if ((dtype != Datatype::TYPEdatetime) &&
49 (dtype != Datatype::TYPEtimestamp)) {
50 return false;
51 }
52 if (val.compare(std::string("NOW")) != 0) return false;
53
55 return true;
56 }
57
59
60 Visitor::VisitorState state = v->visitColumn(this);
61 if (state == Visitor::VBRANCHDONE) return Visitor::VCONTINUE;
62 return state;
63 }
64
65 void Row::rowSort() {
66 if (m_sorted) return;
67
69 std::sort(m_fields.begin(), m_fields.end(), cmp);
70 m_sorted = true;
71 }
72
73 FieldVal* Row::find(std::string colname) {
74 unsigned nField = m_fields.size();
75 unsigned minI = 0;
76 unsigned maxI = nField;
77
78 unsigned guess = maxI/2;
79 unsigned oldGuess = nField;
80
81 int cmp = colname.compare(m_fields[guess].m_colname);
82
83 while (cmp != 0) {
84 if (guess == oldGuess) return 0; // not found
85
86 if (cmp < 0 ) { // thing we tried is > colName, so decrease maxI
87 maxI = guess;
88 } else { // thing we tried is > colName, so increase minI
89 minI = guess;
90 }
91 oldGuess = guess;
92 guess = (minI + maxI)/2;
93 cmp = colname.compare(m_fields[guess].m_colname);
94 }
95 return &m_fields[guess];
96 }
97
98 void Row::regroup(std::vector<std::string>& colNames,
99 std::vector<std::string>& colVals,
100 std::vector<std::string>& nullCols) const {
101 unsigned nFields = m_fields.size();
102 colNames.reserve(nFields);
103 colVals.reserve(nFields);
104
105 for (unsigned i = 0; i < nFields; i++) {
106 if (m_fields[i].m_null) {
107 nullCols.push_back(m_fields[i].m_colname);
108 }
109 else {
110 colNames.push_back(m_fields[i].m_colname);
111 colVals.push_back(m_fields[i].m_val);
112 }
113 }
114 }
115
116}
**********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
std::string getString() const
Return string representation of time, not including nanoseconds;.
Definition Timestamp.cxx:92
bool isAutoIncrement() const
Definition Column.cxx:37
Enum * getEnum() const
Definition Column.cxx:15
const std::string & getTableName() const
Definition Column.cxx:17
Visitor::VisitorState accept(Visitor *v)
Definition Column.cxx:58
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
TYPES getType() const
Definition Datatype.h:59
bool okValue(const std::string &val) const
Definition Datatype.cxx:164
bool isCompatible(const Datatype *other) const
Definition Datatype.cxx:237
Enum * getEnum() const
Definition Datatype.h:64
Function object used to sort FieldValPar objects by column name.
Definition Column.h:137
FieldVal * find(std::string colname)
Definition Column.cxx:73
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
const std::string & getName() const
Definition Table.h:40