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,
226 coral::ISchema&
schema = schemaName.empty() ?
227 coralSession.nominalSchema() :
228 coralSession.schema( schemaName ) ;
230 coral::ITable&
table = schema.tableHandle( tableName ) ;
233 boost::shared_ptr< coral::IQuery >
query( table.newQuery() ) ;
236 std::vector< std::string >::const_iterator it = columnNames.begin() ;
237 std::vector< std::string >::const_iterator
end = columnNames.end() ;
238 for( ; it !=
end ; ++it )
240 query->addToOutputList( *it ) ;
244 if( !conditionLHS.empty() && conditionRHS.
numberRows() == 1 )
246 if( !conditionRHSName.empty() )
249 coral::AttributeList attList ;
250 attList.extend( conditionRHSName,
typeid(
T ) ) ;
253 attList[ conditionRHSName ].data<
T >() = tmp ;
255 query->setCondition( conditionLHS +
" = :" + conditionRHSName,
261 query->setCondition( conditionLHS +
" = :" +
267 coral::ICursor& cursor =
query->execute() ;
271 std::vector< coral::AttributeList > atts ;
272 while( cursor.next() )
274 atts.push_back( cursor.currentRow() ) ;
290 columnNames.push_back( columnName ) ;
292 conditionLHS, conditionRHS, conditionRHSName);
298 std::vector< std::string >
names ;
299 names.push_back(
"dummy" ) ;
301 coral::AttributeList attList ;
302 attList.extend(
"dummy",
typeid(
T ) ) ;
303 attList[
"dummy" ].data<
T >() = data ;
305 std::vector< coral::AttributeList > atts ;
306 atts.push_back( attList ) ;
311 template<
class T >
bool
314 T& outputVariable )
const
319 template<
class T >
bool
323 T& outputVariable )
const
326 if( rowNumber < 0 || rowNumber >= numberRows() )
return false ;
327 const coral::AttributeList& row = m_attributeLists[ rowNumber ] ;
328 if( row[ columnName ].isNull() )
return false ;
329 outputVariable = row[ columnName ].template data< T >() ;
333 template<
class T >
bool
336 return fillVariableFromRow( 0, outputVariable ) ;
339 template<
class T >
bool
341 T& outputVariable )
const
344 if( rowNumber < 0 || rowNumber >= numberRows() ||
345 m_columnNames.size() != 1 )
return false ;
346 const coral::AttributeList& row = m_attributeLists[ rowNumber ] ;
347 if( row[ m_columnNames.front() ].isNull() )
return false ;
348 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< coral::AttributeList > m_attributeLists
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="")
QueryResults(const std::vector< std::string > &columnNames, const std::vector< coral::AttributeList > &attLists)
std::vector< std::string > columnNames(const std::string &schemaName, const std::string &tableName)
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) const
const std::vector< coral::AttributeList > & attributeLists() 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 std::vector< std::string > & columnNames() const
void connect(const std::string &connectString, const std::string &authenticationPath)
std::vector< std::string > columnNamesView(const std::string &schemaName, const std::string &viewName)
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="")
coral::ISessionProxy & coralSession()
std::vector< std::vector< double > > tmp
volatile std::atomic< bool > shutdown_flag false
cond::persistency::Session session
const OMDSReader & operator=(const OMDSReader &)