CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cond::persistency::Query< Types > Class Template Reference

#include <DbCore.h>

Public Member Functions

template<int n>
void _Query ()
 
template<int n, typename Arg1 , typename... Args>
void _Query ()
 
template<typename C1 , typename C2 >
QueryaddCondition (const std::string condition="=")
 
template<typename C , typename T >
QueryaddCondition (const T &value, const std::string condition="=")
 
template<typename C >
QueryaddOrderClause (bool ascending=true)
 
template<typename Col >
QueryaddTable ()
 
const QueryIterator< Types... > begin ()
 
const coral::AttributeList & currentRow () const
 
const QueryIterator< Types... > end ()
 
QuerygroupBy (const std::string &expression)
 
QuerylimitReturnedRows (size_t nrows)
 
bool next ()
 
 Query (const coral::ISchema &schema, bool distinct=false)
 
size_t retrievedRows () const
 
QuerysetForUpdate ()
 
 ~Query ()
 

Private Attributes

std::unique_ptr< coral::IQuery > m_coralQuery
 
coral::ICursor * m_cursor = nullptr
 
size_t m_retrievedRows = 0
 
std::set< std::string > m_tables
 
std::string m_whereClause
 
coral::AttributeList m_whereData
 

Detailed Description

template<typename... Types>
class cond::persistency::Query< Types >

Definition at line 403 of file DbCore.h.

Constructor & Destructor Documentation

◆ Query()

template<typename... Types>
cond::persistency::Query< Types >::Query ( const coral::ISchema &  schema,
bool  distinct = false 
)
inline

Definition at line 498 of file DbCore.h.

499  : m_coralQuery(schema.newQuery()), m_whereData(), m_whereClause(""), m_tables() {
500  _Query<0, Types...>();
501  if (distinct)
502  m_coralQuery->setDistinct();
503  }

◆ ~Query()

template<typename... Types>
cond::persistency::Query< Types >::~Query ( )
inline

Definition at line 505 of file DbCore.h.

505 {}

Member Function Documentation

◆ _Query() [1/2]

template<typename... Types>
template<int n>
void cond::persistency::Query< Types >::_Query ( )
inline

◆ _Query() [2/2]

template<typename... Types>
template<int n, typename Arg1 , typename... Args>
void cond::persistency::Query< Types >::_Query ( )
inline

Definition at line 520 of file DbCore.h.

520  {
521  addTable<Arg1>();
522  DefineQueryOutput<typename Arg1::type>::make(*m_coralQuery, Arg1::fullyQualifiedName());
523  _Query<n + 1, Args...>();
524  }

◆ addCondition() [1/2]

template<typename... Types>
template<typename C1 , typename C2 >
Query& cond::persistency::Query< Types >::addCondition ( const std::string  condition = "=")
inline

Definition at line 534 of file DbCore.h.

534  {
535  addTable<C1>();
536  addTable<C2>();
537  f_add_condition<C1, C2>(m_whereClause, condition);
538  return *this;
539  }

◆ addCondition() [2/2]

template<typename... Types>
template<typename C , typename T >
Query& cond::persistency::Query< Types >::addCondition ( const T value,
const std::string  condition = "=" 
)
inline

Definition at line 527 of file DbCore.h.

527  {
528  addTable<C>();
529  f_add_condition_data<C>(m_whereData, m_whereClause, value, condition);
530  return *this;
531  }

◆ addOrderClause()

template<typename... Types>
template<typename C >
Query& cond::persistency::Query< Types >::addOrderClause ( bool  ascending = true)
inline

Definition at line 542 of file DbCore.h.

542  {
543  std::string orderClause(C::fullyQualifiedName());
544  if (!ascending)
545  orderClause += " DESC";
546  m_coralQuery->addToOrderList(orderClause);
547  return *this;
548  }

◆ addTable()

template<typename... Types>
template<typename Col >
Query& cond::persistency::Query< Types >::addTable ( )
inline

Definition at line 508 of file DbCore.h.

508  {
509  if (m_tables.find(Col::tableName()) == m_tables.end()) {
510  m_coralQuery->addToTableList(Col::tableName());
511  m_tables.insert(Col::tableName());
512  }
513  return *this;
514  }

◆ begin()

template<typename... Types>
const QueryIterator<Types...> cond::persistency::Query< Types >::begin ( void  )
inline

Definition at line 580 of file DbCore.h.

580  {
581  m_coralQuery->setCondition(m_whereClause, m_whereData);
582  m_cursor = &m_coralQuery->execute();
583  m_retrievedRows = 0;
584  QueryIterator<Types...> ret(this);
585  return ++ret;
586  }

◆ currentRow()

template<typename... Types>
const coral::AttributeList& cond::persistency::Query< Types >::currentRow ( ) const
inline

Definition at line 574 of file DbCore.h.

574  {
575  if (!m_cursor)
576  throwException("The query has not been executed.", "Query::currentRow");
577  return m_cursor->currentRow();
578  }

Referenced by cond::persistency::QueryIterator< Types >::operator++().

◆ end()

template<typename... Types>
const QueryIterator<Types...> cond::persistency::Query< Types >::end ( void  )
inline

Definition at line 588 of file DbCore.h.

588 { return QueryIterator<Types...>(this); }

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

◆ groupBy()

template<typename... Types>
Query& cond::persistency::Query< Types >::groupBy ( const std::string &  expression)
inline

Definition at line 550 of file DbCore.h.

550  {
551  m_coralQuery->groupBy(expression);
552  return *this;
553  }

Referenced by SpecificationBuilder_cfi.Specification::saveAll().

◆ limitReturnedRows()

template<typename... Types>
Query& cond::persistency::Query< Types >::limitReturnedRows ( size_t  nrows)
inline

Definition at line 560 of file DbCore.h.

560  {
561  m_coralQuery->limitReturnedRows(nrows);
562  return *this;
563  }

◆ next()

template<typename... Types>
bool cond::persistency::Query< Types >::next ( void  )
inline

Definition at line 565 of file DbCore.h.

565  {
566  if (!m_cursor)
567  throwException("The query has not been executed.", "Query::currentRow");
568  bool ret = m_cursor->next();
569  if (ret)
570  m_retrievedRows++;
571  return ret;
572  }

Referenced by cond::persistency::QueryIterator< Types >::operator++().

◆ retrievedRows()

template<typename... Types>
size_t cond::persistency::Query< Types >::retrievedRows ( ) const
inline

Definition at line 590 of file DbCore.h.

590 { return m_retrievedRows; }

◆ setForUpdate()

template<typename... Types>
Query& cond::persistency::Query< Types >::setForUpdate ( )
inline

Definition at line 555 of file DbCore.h.

555  {
556  m_coralQuery->setForUpdate();
557  return *this;
558  }

Member Data Documentation

◆ m_coralQuery

template<typename... Types>
std::unique_ptr<coral::IQuery> cond::persistency::Query< Types >::m_coralQuery
private

◆ m_cursor

template<typename... Types>
coral::ICursor* cond::persistency::Query< Types >::m_cursor = nullptr
private

◆ m_retrievedRows

template<typename... Types>
size_t cond::persistency::Query< Types >::m_retrievedRows = 0
private

◆ m_tables

template<typename... Types>
std::set<std::string> cond::persistency::Query< Types >::m_tables
private

Definition at line 598 of file DbCore.h.

Referenced by cond::persistency::Query< Types... >::addTable().

◆ m_whereClause

template<typename... Types>
std::string cond::persistency::Query< Types >::m_whereClause
private

◆ m_whereData

template<typename... Types>
coral::AttributeList cond::persistency::Query< Types >::m_whereData
private
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::distinct
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:69
cond::persistency::Query::m_whereData
coral::AttributeList m_whereData
Definition: DbCore.h:596
HLT_2018_cff.tableName
tableName
Definition: HLT_2018_cff.py:10
cond::persistency::DefineQueryOutput::make
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:454
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::Query::_Query
void _Query()
Definition: DbCore.h:517
cond::persistency::Query::m_retrievedRows
size_t m_retrievedRows
Definition: DbCore.h:595
value
Definition: value.py:1
cond::persistency::Query::m_tables
std::set< std::string > m_tables
Definition: DbCore.h:598
cond::persistency::Query::m_coralQuery
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:593
cond::persistency::Query::m_whereClause
std::string m_whereClause
Definition: DbCore.h:597
goodZToMuMu_cfi.condition
condition
Definition: goodZToMuMu_cfi.py:37
Types
Definition: Types.py:1
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
cond::persistency::Query::m_cursor
coral::ICursor * m_cursor
Definition: DbCore.h:594