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)
 
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 = 0
 
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 365 of file DbCore.h.

Constructor & Destructor Documentation

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

Definition at line 460 of file DbCore.h.

461  : m_coralQuery(schema.newQuery()), m_whereData(), m_whereClause(""), m_tables() {
462  _Query<0, Types...>();
463  if (distinct)
464  m_coralQuery->setDistinct();
465  }
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:69
Definition: Types.py:1
coral::AttributeList m_whereData
Definition: DbCore.h:553
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:550
std::string m_whereClause
Definition: DbCore.h:554
std::set< std::string > m_tables
Definition: DbCore.h:555
template<typename... Types>
cond::persistency::Query< Types >::~Query ( )
inline

Definition at line 467 of file DbCore.h.

467 {}

Member Function Documentation

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

Definition at line 479 of file DbCore.h.

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

Definition at line 482 of file DbCore.h.

482  {
483  addTable<Arg1>();
484  DefineQueryOutput<typename Arg1::type>::make(*m_coralQuery, Arg1::fullyQualifiedName());
485  _Query<n + 1, Args...>();
486  }
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:416
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:550
template<typename... Types>
template<typename C , typename T >
Query& cond::persistency::Query< Types >::addCondition ( const T value,
const std::string  condition = "=" 
)
inline
template<typename... Types>
template<typename C1 , typename C2 >
Query& cond::persistency::Query< Types >::addCondition ( const std::string  condition = "=")
inline

Definition at line 496 of file DbCore.h.

496  {
497  addTable<C1>();
498  addTable<C2>();
499  f_add_condition<C1, C2>(m_whereClause, condition);
500  return *this;
501  }
std::string m_whereClause
Definition: DbCore.h:554
template<typename... Types>
template<typename C >
Query& cond::persistency::Query< Types >::addOrderClause ( bool  ascending = true)
inline

Definition at line 504 of file DbCore.h.

Referenced by cond::persistency::IOV::Table::getGroups(), cond::persistency::IOV::Table::getLastIov(), cond::persistency::IOV::Table::getRange(), cond::persistency::GLOBAL_TAG_MAP::Table::select(), and cond::persistency::IOV::Table::select().

504  {
505  std::string orderClause(C::fullyQualifiedName());
506  if (!ascending)
507  orderClause += " DESC";
508  m_coralQuery->addToOrderList(orderClause);
509  return *this;
510  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:550
template<typename... Types>
template<typename Col >
Query& cond::persistency::Query< Types >::addTable ( )
inline

Definition at line 470 of file DbCore.h.

470  {
471  if (m_tables.find(Col::tableName()) == m_tables.end()) {
472  m_coralQuery->addToTableList(Col::tableName());
473  m_tables.insert(Col::tableName());
474  }
475  return *this;
476  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:550
std::set< std::string > m_tables
Definition: DbCore.h:555
template<typename... Types>
const QueryIterator<Types...> cond::persistency::Query< Types >::begin ( void  )
inline

Definition at line 537 of file DbCore.h.

537  {
538  m_coralQuery->setCondition(m_whereClause, m_whereData);
539  m_cursor = &m_coralQuery->execute();
540  m_retrievedRows = 0;
541  QueryIterator<Types...> ret(this);
542  return ++ret;
543  }
ret
prodAgent to be discontinued
Definition: Types.py:1
coral::AttributeList m_whereData
Definition: DbCore.h:553
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:550
std::string m_whereClause
Definition: DbCore.h:554
coral::ICursor * m_cursor
Definition: DbCore.h:551
template<typename... Types>
const coral::AttributeList& cond::persistency::Query< Types >::currentRow ( ) const
inline

Definition at line 531 of file DbCore.h.

Referenced by Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::itemClicked(), and Vispa.Views.TableView.TableView::itemSelectionChanged().

531  {
532  if (!m_cursor)
533  throwException("The query has not been executed.", "Query::currentRow");
534  return m_cursor->currentRow();
535  }
coral::ICursor * m_cursor
Definition: DbCore.h:551
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
template<typename... Types>
const QueryIterator<Types...> cond::persistency::Query< Types >::end ( void  )
inline

Definition at line 545 of file DbCore.h.

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

545 { return QueryIterator<Types...>(this); }
Definition: Types.py:1
template<typename... Types>
Query& cond::persistency::Query< Types >::groupBy ( const std::string &  expression)
inline

Definition at line 512 of file DbCore.h.

Referenced by cond::persistency::IOV::Table::getGroups(), cond::persistency::Query< Types... >::groupBy(), and SpecificationBuilder_cfi.Specification::saveAll().

512  {
513  m_coralQuery->groupBy(expression);
514  return *this;
515  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:550
template<typename... Types>
bool cond::persistency::Query< Types >::next ( void  )
inline

Definition at line 522 of file DbCore.h.

522  {
523  if (!m_cursor)
524  throwException("The query has not been executed.", "Query::currentRow");
525  bool ret = m_cursor->next();
526  if (ret)
527  m_retrievedRows++;
528  return ret;
529  }
ret
prodAgent to be discontinued
coral::ICursor * m_cursor
Definition: DbCore.h:551
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
template<typename... Types>
size_t cond::persistency::Query< Types >::retrievedRows ( ) const
inline

Definition at line 547 of file DbCore.h.

547 { return m_retrievedRows; }
template<typename... Types>
Query& cond::persistency::Query< Types >::setForUpdate ( )
inline

Definition at line 517 of file DbCore.h.

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

517  {
518  m_coralQuery->setForUpdate();
519  return *this;
520  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:550

Member Data Documentation

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

Definition at line 550 of file DbCore.h.

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

Definition at line 551 of file DbCore.h.

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

Definition at line 552 of file DbCore.h.

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

Definition at line 555 of file DbCore.h.

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

Definition at line 554 of file DbCore.h.

template<typename... Types>
coral::AttributeList cond::persistency::Query< Types >::m_whereData
private

Definition at line 553 of file DbCore.h.