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

500  : m_coralQuery(schema.newQuery()), m_whereData(), m_whereClause(""), m_tables() {
501  _Query<0, Types...>();
502  if (distinct)
503  m_coralQuery->setDistinct();
504  }
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:69
Definition: Types.py:1
coral::AttributeList m_whereData
Definition: DbCore.h:597
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594
std::string m_whereClause
Definition: DbCore.h:598
std::set< std::string > m_tables
Definition: DbCore.h:599

◆ ~Query()

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

Definition at line 506 of file DbCore.h.

506 {}

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

521  {
522  addTable<Arg1>();
523  DefineQueryOutput<typename Arg1::type>::make(*m_coralQuery, Arg1::fullyQualifiedName());
524  _Query<n + 1, Args...>();
525  }
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:455
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594

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

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

528  {
529  addTable<C>();
530  f_add_condition_data<C>(m_whereData, m_whereClause, value, condition);
531  return *this;
532  }
coral::AttributeList m_whereData
Definition: DbCore.h:597
std::string m_whereClause
Definition: DbCore.h:598

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

535  {
536  addTable<C1>();
537  addTable<C2>();
538  f_add_condition<C1, C2>(m_whereClause, condition);
539  return *this;
540  }
std::string m_whereClause
Definition: DbCore.h:598

◆ addOrderClause()

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

Definition at line 543 of file DbCore.h.

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

543  {
544  std::string orderClause(C::fullyQualifiedName());
545  if (!ascending)
546  orderClause += " DESC";
547  m_coralQuery->addToOrderList(orderClause);
548  return *this;
549  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594

◆ addTable()

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

Definition at line 509 of file DbCore.h.

509  {
510  if (m_tables.find(Col::tableName()) == m_tables.end()) {
511  m_coralQuery->addToTableList(Col::tableName());
512  m_tables.insert(Col::tableName());
513  }
514  return *this;
515  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594
std::set< std::string > m_tables
Definition: DbCore.h:599

◆ begin()

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

Definition at line 581 of file DbCore.h.

581  {
582  m_coralQuery->setCondition(m_whereClause, m_whereData);
583  m_cursor = &m_coralQuery->execute();
584  m_retrievedRows = 0;
585  QueryIterator<Types...> ret(this);
586  return ++ret;
587  }
ret
prodAgent to be discontinued
Definition: Types.py:1
coral::AttributeList m_whereData
Definition: DbCore.h:597
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594
std::string m_whereClause
Definition: DbCore.h:598
coral::ICursor * m_cursor
Definition: DbCore.h:595

◆ currentRow()

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

Definition at line 575 of file DbCore.h.

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

575  {
576  if (!m_cursor)
577  throwException("The query has not been executed.", "Query::currentRow");
578  return m_cursor->currentRow();
579  }
coral::ICursor * m_cursor
Definition: DbCore.h:595
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 589 of file DbCore.h.

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

589 { 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 551 of file DbCore.h.

Referenced by SpecificationBuilder_cfi.Specification::saveAll().

551  {
552  m_coralQuery->groupBy(expression);
553  return *this;
554  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594

◆ limitReturnedRows()

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

Definition at line 561 of file DbCore.h.

561  {
562  m_coralQuery->limitReturnedRows(nrows);
563  return *this;
564  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594

◆ next()

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

Definition at line 566 of file DbCore.h.

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

566  {
567  if (!m_cursor)
568  throwException("The query has not been executed.", "Query::currentRow");
569  bool ret = m_cursor->next();
570  if (ret)
571  m_retrievedRows++;
572  return ret;
573  }
ret
prodAgent to be discontinued
coral::ICursor * m_cursor
Definition: DbCore.h:595
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 591 of file DbCore.h.

591 { return m_retrievedRows; }

◆ setForUpdate()

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

Definition at line 556 of file DbCore.h.

556  {
557  m_coralQuery->setForUpdate();
558  return *this;
559  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:594

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