1 #ifndef CondTools_L1Trigger_OMDSReader_h 2 #define CondTools_L1Trigger_OMDSReader_h 27 #include "RelationalAccess/IQuery.h" 28 #include "CoralBase/AttributeList.h" 29 #include "CoralBase/AttributeSpecification.h" 30 #include "CoralBase/Attribute.h" 32 #include "RelationalAccess/ITable.h" 33 #include "RelationalAccess/IView.h" 34 #include "RelationalAccess/ISchema.h" 35 #include "RelationalAccess/ISessionProxy.h" 36 #include "RelationalAccess/ICursor.h" 57 const std::vector< coral::AttributeList >& attLists )
72 T& outputVariable )
const ;
77 T& outputVariable )
const ;
85 T& outputVariable )
const ;
137 const std::vector< std::string >& columnNames,
164 const std::vector< std::string >& columnNames,
217 const std::vector< std::string >& columnNames,
225 coral::ISchema&
schema = schemaName.empty() ?
226 coralSession.nominalSchema() :
227 coralSession.schema( schemaName ) ;
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 ) ;
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 313 T& outputVariable )
const 318 template<
class T >
bool 322 T& outputVariable )
const 327 if( row[ columnName ].isNull() )
return false ;
328 outputVariable = row[ columnName ].template data< T >() ;
332 template<
class T >
bool 338 template<
class T >
bool 340 T& outputVariable )
const 343 if( rowNumber < 0 || rowNumber >=
numberRows() ||
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< coral::AttributeList > m_attributeLists
def query(query_str, verbose=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="")
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 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
char data[epos_bytes_allocation]
cond::persistency::Session session
const OMDSReader & operator=(const OMDSReader &)