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 C , typename T >
QueryaddCondition (const T &value, const std::string condition="=")
 
template<typename C1 , typename C2 >
QueryaddCondition (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 404 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 506 of file DbCore.h.

507  : m_coralQuery(schema.newQuery()), m_whereData(), m_whereClause(""), m_tables() {
508  _Query<0, Types...>();
509  if (distinct)
510  m_coralQuery->setDistinct();
511  }
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:69
Definition: Types.py:1
coral::AttributeList m_whereData
Definition: DbCore.h:604
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601
std::string m_whereClause
Definition: DbCore.h:605
std::set< std::string > m_tables
Definition: DbCore.h:606

◆ ~Query()

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

Definition at line 513 of file DbCore.h.

513 {}

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 528 of file DbCore.h.

528  {
529  addTable<Arg1>();
530  DefineQueryOutput<typename Arg1::type>::make(*m_coralQuery, Arg1::fullyQualifiedName());
531  _Query<n + 1, Args...>();
532  }
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:462
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601

◆ addCondition() [1/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 535 of file DbCore.h.

Referenced by cond::persistency::RUN_INFO::Table::getInclusiveTimeRange(), and cond::persistency::IOV::Table::getRange().

535  {
536  addTable<C>();
537  f_add_condition_data<C>(m_whereData, m_whereClause, value, condition);
538  return *this;
539  }
coral::AttributeList m_whereData
Definition: DbCore.h:604
std::string m_whereClause
Definition: DbCore.h:605

◆ addCondition() [2/2]

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

Definition at line 542 of file DbCore.h.

542  {
543  addTable<C1>();
544  addTable<C2>();
545  f_add_condition<C1, C2>(m_whereClause, condition);
546  return *this;
547  }
std::string m_whereClause
Definition: DbCore.h:605

◆ addOrderClause()

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

Definition at line 550 of file DbCore.h.

Referenced by cond::persistency::IOV::Table::getRange().

550  {
551  std::string orderClause(C::fullyQualifiedName());
552  if (!ascending)
553  orderClause += " DESC";
554  m_coralQuery->addToOrderList(orderClause);
555  return *this;
556  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601

◆ addTable()

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

Definition at line 516 of file DbCore.h.

516  {
517  if (m_tables.find(Col::tableName()) == m_tables.end()) {
518  m_coralQuery->addToTableList(Col::tableName());
519  m_tables.insert(Col::tableName());
520  }
521  return *this;
522  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601
std::set< std::string > m_tables
Definition: DbCore.h:606

◆ begin()

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

Definition at line 588 of file DbCore.h.

588  {
589  m_coralQuery->setCondition(m_whereClause, m_whereData);
590  m_cursor = &m_coralQuery->execute();
591  m_retrievedRows = 0;
592  QueryIterator<Types...> ret(this);
593  return ++ret;
594  }
ret
prodAgent to be discontinued
Definition: Types.py:1
coral::AttributeList m_whereData
Definition: DbCore.h:604
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601
std::string m_whereClause
Definition: DbCore.h:605
coral::ICursor * m_cursor
Definition: DbCore.h:602

◆ currentRow()

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

Definition at line 582 of file DbCore.h.

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

582  {
583  if (!m_cursor)
584  throwException("The query has not been executed.", "Query::currentRow");
585  return m_cursor->currentRow();
586  }
coral::ICursor * m_cursor
Definition: DbCore.h:602
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ end()

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

Definition at line 596 of file DbCore.h.

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

596 { return QueryIterator<Types...>(this); }
Definition: Types.py:1

◆ groupBy()

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

Definition at line 558 of file DbCore.h.

Referenced by SpecificationBuilder_cfi.Specification::saveAll().

558  {
559  m_coralQuery->groupBy(expression);
560  return *this;
561  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601

◆ limitReturnedRows()

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

Definition at line 568 of file DbCore.h.

568  {
569  m_coralQuery->limitReturnedRows(nrows);
570  return *this;
571  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601

◆ next()

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

Definition at line 573 of file DbCore.h.

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

573  {
574  if (!m_cursor)
575  throwException("The query has not been executed.", "Query::currentRow");
576  bool ret = m_cursor->next();
577  if (ret)
578  m_retrievedRows++;
579  return ret;
580  }
ret
prodAgent to be discontinued
coral::ICursor * m_cursor
Definition: DbCore.h:602
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ retrievedRows()

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

Definition at line 598 of file DbCore.h.

598 { return m_retrievedRows; }

◆ setForUpdate()

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

Definition at line 563 of file DbCore.h.

563  {
564  m_coralQuery->setForUpdate();
565  return *this;
566  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:601

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 606 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