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