CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TableRegister.cc
Go to the documentation of this file.
2 #include "TableRegister.h"
3 // externals
4 #include "RelationalAccess/IColumn.h"
5 #include "RelationalAccess/ISchema.h"
6 #include "RelationalAccess/ITable.h"
7 #include "RelationalAccess/ITableDescription.h"
8 
10  m_schema( schema ),m_init(false),m_register(),m_currentTable(0),m_currentColumns(0){
11 }
12 
14 }
15 
17  if(!m_init){
18  std::set<std::string> tableList = m_schema.listTables();
19  for( std::set<std::string>::const_iterator iT = tableList.begin(); iT != tableList.end(); ++iT ){
20  coral::ITable& table = m_schema.tableHandle( *iT );
21  std::map<std::string,std::set<std::string> >::iterator iEntry =
22  m_register.insert( std::make_pair( *iT, std::set<std::string>() ) ).first;
23  int ncols = table.description().numberOfColumns();
24  for(int i=0;i<ncols;i++){
25  iEntry->second.insert( table.description().columnDescription( i ).name() );
26  }
27  }
28  m_init = true;
29  }
30 }
31 
33  init();
34  if(!m_currentTable || (tableName!=*m_currentTable)){
35  std::map<std::string, std::set<std::string> >::iterator iT = m_register.find( tableName );
36  if(iT==m_register.end()) {
37  m_currentTable = 0;
38  m_currentColumns = 0;
39  return false;
40  }
41  m_currentTable = &iT->first;
42  m_currentColumns = &iT->second;
43  }
44  return true;
45 }
46 
48  const std::string& columnName){
49  init();
50  if(!m_currentTable || (tableName!=*m_currentTable)){
51  std::map<std::string, std::set<std::string> >::iterator iT = m_register.find( tableName );
52  if(iT==m_register.end()) {
53  m_currentTable = 0;
54  m_currentColumns = 0;
55  return false;
56  }
57  m_currentTable = &iT->first;
58  m_currentColumns = &iT->second;
59  }
60  return m_currentColumns->find(columnName)!=m_currentColumns->end();
61 }
62 
63 void
65  init();
66  m_register.insert( std::make_pair(tableName, std::set<std::string>()) );
67  m_currentTable = 0;
68  m_currentColumns = 0;
69 }
70 
72  const std::string& columnName){
73  init();
74  if(!m_currentTable || (tableName!=*m_currentTable)){
75  std::map<std::string, std::set<std::string> >::iterator iT = m_register.find( tableName );
76  if(iT==m_register.end()) {
77  m_currentTable = 0;
78  m_currentColumns = 0;
79  return false;
80  }
81  m_currentTable = &iT->first;
82  m_currentColumns = &iT->second;
83  }
84  m_currentColumns->insert( columnName );
85  return true;
86 }
87 
89  const std::vector<std::string>& columns ){
90 
91  init();
92  if(!m_currentTable || (tableName!=*m_currentTable)){
93  std::map<std::string, std::set<std::string> >::iterator iT = m_register.find( tableName );
94  if(iT==m_register.end()) {
95  m_currentTable = 0;
96  m_currentColumns = 0;
97  return false;
98  }
99  m_currentTable = &iT->first;
100  m_currentColumns = &iT->second;
101  }
102  for( std::vector<std::string>::const_iterator iC = columns.begin(); iC != columns.end(); iC++ ){
103  m_currentColumns->insert( *iC );
104  }
105  return true;
106 }
107 
109  init();
110  if(!m_currentTable || (tableName!=*m_currentTable)){
111  std::map<std::string, std::set<std::string> >::iterator iT = m_register.find( tableName );
112  if(iT==m_register.end()) {
113  m_currentTable = 0;
114  m_currentColumns = 0;
115  return 0;
116  }
117  m_currentTable = &iT->first;
118  m_currentColumns = &iT->second;
119  }
120  return m_currentColumns->size();
121 }
122 
123 
int i
Definition: DBlmapReader.cc:9
TableRegister(coral::ISchema &schema)
Definition: TableRegister.cc:9
virtual ~TableRegister()
bool insertColumns(const std::string &tableName, const std::vector< std::string > &columns)
int init
Definition: HydjetWrapper.h:62
bool insertColumn(const std::string &tableName, const std::string &columnName)
size_t numberOfColumns(const std::string &tableName)
void insertTable(const std::string &tableName)
#define table(NAME)
Definition: DbCore.h:49
bool checkColumn(const std::string &tableName, const std::string &columnName)
volatile std::atomic< bool > shutdown_flag false
bool checkTable(const std::string &tableName)