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 ;
138 const std::vector< std::string >& columnNames,
165 const std::vector< std::string >& columnNames,
218 const std::vector< std::string >& columnNames,
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() ) ;
289 columnNames.push_back( columnName ) ;
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
313 T& outputVariable )
const
318 template<
class T >
bool
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
static const HistoName names[]
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]
volatile std::atomic< bool > shutdown_flag false
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
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 &)