1 #ifndef CondTools_L1Trigger_OMDSReader_h
2 #define CondTools_L1Trigger_OMDSReader_h
24 #include "boost/shared_ptr.hpp"
28 #include "RelationalAccess/IQuery.h"
29 #include "CoralBase/AttributeList.h"
30 #include "CoralBase/AttributeSpecification.h"
31 #include "CoralBase/Attribute.h"
33 #include "RelationalAccess/ITable.h"
34 #include "RelationalAccess/IView.h"
35 #include "RelationalAccess/ISchema.h"
36 #include "RelationalAccess/ISessionProxy.h"
37 #include "RelationalAccess/ICursor.h"
58 const std::vector< coral::AttributeList >& attLists )
73 T& outputVariable )
const ;
78 T& outputVariable )
const ;
86 T& outputVariable )
const ;
96 const std::string& authenticationPath ) ;
114 const std::string& schemaName,
115 const std::string& tableName,
116 const std::string& conditionLHS =
"",
119 const std::string& conditionRHSName =
""
125 const std::string& columnName,
126 const std::string& schemaName,
127 const std::string& tableName,
128 const std::string& conditionLHS =
"",
131 const std::string& conditionRHSName =
""
138 const std::vector< std::string >& columnNames,
139 const std::string& schemaName,
140 const std::string& viewName,
141 const std::string& conditionLHS =
"",
144 const std::string& conditionRHSName =
""
150 const std::string& columnName,
151 const std::string& schemaName,
152 const std::string& viewName,
153 const std::string& conditionLHS =
"",
156 const std::string& conditionRHSName =
""
165 const std::vector< std::string >& columnNames,
166 const std::string& schemaName,
167 const std::string& tableName,
168 const std::string& conditionLHS =
"",
171 const std::string& conditionRHSName =
""
180 const std::string& columnName,
181 const std::string& schemaName,
182 const std::string& tableName,
183 const std::string& conditionLHS =
"",
186 const std::string& conditionRHSName =
""
194 const std::string& schemaName,
195 const std::string& tableName )
const ;
198 const std::string& schemaName,
199 const std::string& viewName )
const ;
205 void connect(
const std::string& connectString,
206 const std::string& authenticationPath ) ;
218 const std::vector< std::string >& columnNames,
219 const std::string& schemaName,
220 const std::string& tableName,
221 const std::string& conditionLHS,
223 const std::string& conditionRHSName )
const
225 coral::ISchema&
schema = schemaName.empty() ?
229 coral::ITable&
table = schema.tableHandle( tableName ) ;
232 boost::shared_ptr< coral::IQuery >
query( table.newQuery() ) ;
235 std::vector< std::string >::const_iterator it = columnNames.begin() ;
236 std::vector< std::string >::const_iterator
end = columnNames.end() ;
237 for( ; it !=
end ; ++it )
239 query->addToOutputList( *it ) ;
243 if( !conditionLHS.empty() && conditionRHS.
numberRows() == 1 )
245 if( !conditionRHSName.empty() )
248 coral::AttributeList attList ;
249 attList.extend( conditionRHSName,
typeid(
T ) ) ;
252 attList[ conditionRHSName ].data<
T >() = tmp ;
254 query->setCondition( conditionLHS +
" = :" + conditionRHSName,
260 query->setCondition( conditionLHS +
" = :" +
266 coral::ICursor& cursor =
query->execute() ;
270 std::vector< coral::AttributeList > atts ;
271 while( cursor.next() )
273 atts.push_back( cursor.currentRow() ) ;
281 const std::string& columnName,
282 const std::string& schemaName,
283 const std::string& tableName,
284 const std::string& conditionLHS,
286 const std::string& conditionRHSName )
const
289 columnNames.push_back( columnName ) ;
290 return basicQueryGenericKey< T >(
columnNames, schemaName, tableName,
291 conditionLHS, conditionRHS, conditionRHSName);
297 std::vector< std::string >
names ;
298 names.push_back(
"dummy" ) ;
300 coral::AttributeList attList ;
301 attList.extend(
"dummy",
typeid(
T ) ) ;
302 attList[
"dummy" ].data<
T >() = data ;
304 std::vector< coral::AttributeList > atts ;
305 atts.push_back( attList ) ;
310 template<
class T >
bool
312 const std::string& columnName,
313 T& outputVariable )
const
318 template<
class T >
bool
320 const std::string& columnName,
322 T& outputVariable )
const
325 if( rowNumber < 0 || rowNumber >= numberRows() )
return false ;
326 const coral::AttributeList& row = m_attributeLists[ rowNumber ] ;
327 if( row[ columnName ].isNull() )
return false ;
328 outputVariable = row[ columnName ].template data< T >() ;
332 template<
class T >
bool
335 return fillVariableFromRow( 0, outputVariable ) ;
338 template<
class T >
bool
340 T& outputVariable )
const
343 if( rowNumber < 0 || rowNumber >= numberRows() ||
344 m_columnNames.size() != 1 )
return false ;
345 const coral::AttributeList& row = m_attributeLists[ rowNumber ] ;
346 if( row[ m_columnNames.front() ].isNull() )
return false ;
347 outputVariable = row[ m_columnNames.front() ].template data< T >() ;
std::vector< std::string > m_columnNames
bool fillVariable(const std::string &columnName, T &outputVariable) const
const QueryResults singleAttribute(const T &data) const
std::vector< std::string > columnNamesView(const std::string &schemaName, const std::string &viewName) const
coral::ISchema & schema(const std::string &schemaName)
std::vector< coral::AttributeList > m_attributeLists
QueryResults(const std::vector< std::string > &columnNames, const std::vector< coral::AttributeList > &attLists)
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) const
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
const std::vector< coral::AttributeList > & attributeLists() const
const std::vector< std::string > & columnNames() const
void connect(const std::string &connectString, const std::string &authenticationPath)
coral::ISchema & nominalSchema()
std::vector< std::vector< double > > tmp
char data[epos_bytes_allocation]
const QueryResults basicQueryGenericKey(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
static const HistoName names[]
std::vector< std::string > columnNames(const std::string &schemaName, const std::string &tableName) const
cond::DbSession * session
const QueryResults basicQueryView(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &viewName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
const OMDSReader & operator=(const OMDSReader &)