CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 >
void addCondition (const T &value, const std::string condition="=")
 
template<typename C1 , typename C2 >
void addCondition (const std::string condition="=")
 
template<typename C >
void addOrderClause (bool ascending=true)
 
template<typename Col >
void addTable ()
 
const QueryIterator< Types...> begin ()
 
const coral::AttributeList & currentRow () const
 
const QueryIterator< Types...> end ()
 
bool next ()
 
 Query (const coral::ISchema &schema, bool distinct=false)
 
size_t retrievedRows () const
 
void setForUpdate ()
 
 ~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 311 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 399 of file DbCore.h.

399  :
400  m_coralQuery( schema.newQuery() ),
401  m_whereData(),
402  m_whereClause(""),
403  m_tables(){
404  _Query<0, Types...>();
405  if( distinct ) m_coralQuery->setDistinct();
406  }
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:72
coral::AttributeList m_whereData
Definition: DbCore.h:481
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:478
std::string m_whereClause
Definition: DbCore.h:482
std::set< std::string > m_tables
Definition: DbCore.h:483
template<typename... Types>
cond::persistency::Query< Types >::~Query ( )
inline

Definition at line 408 of file DbCore.h.

408  {
409  }

Member Function Documentation

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

Definition at line 422 of file DbCore.h.

422  {
423  addTable<Arg1>();
424  DefineQueryOutput<typename Arg1::type>::make( *m_coralQuery, Arg1::fullyQualifiedName() );
425  _Query<n+1, Args...>();
426  }
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:371
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:478
template<typename... Types>
template<typename C , typename T >
void cond::persistency::Query< Types >::addCondition ( const T value,
const std::string  condition = "=" 
)
inline
template<typename... Types>
template<typename C1 , typename C2 >
void cond::persistency::Query< Types >::addCondition ( const std::string  condition = "=")
inline

Definition at line 433 of file DbCore.h.

433  {
434  addTable<C1>();
435  addTable<C2>();
436  f_add_condition<C1,C2>( m_whereClause, condition );
437  }
std::string m_whereClause
Definition: DbCore.h:482
template<typename... Types>
template<typename C >
void cond::persistency::Query< Types >::addOrderClause ( bool  ascending = true)
inline
template<typename... Types>
template<typename Col >
void cond::persistency::Query< Types >::addTable ( )
inline

Definition at line 411 of file DbCore.h.

411  {
412  if( m_tables.find( Col::tableName() )==m_tables.end() ){
413  m_coralQuery->addToTableList( Col::tableName() );
414  m_tables.insert( Col::tableName() );
415  }
416  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:478
std::set< std::string > m_tables
Definition: DbCore.h:483
template<typename... Types>
const QueryIterator<Types...> cond::persistency::Query< Types >::begin ( void  )
inline

Definition at line 461 of file DbCore.h.

461  {
462  m_coralQuery->setCondition( m_whereClause, m_whereData );
463  m_cursor = &m_coralQuery->execute();
464  m_retrievedRows = 0;
465  QueryIterator<Types...> ret ( this );
466  return ++ret;
467  }
coral::AttributeList m_whereData
Definition: DbCore.h:481
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:478
std::string m_whereClause
Definition: DbCore.h:482
coral::ICursor * m_cursor
Definition: DbCore.h:479
template<typename... Types>
const coral::AttributeList& cond::persistency::Query< Types >::currentRow ( ) const
inline

Definition at line 456 of file DbCore.h.

Referenced by Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::itemClicked(), Vispa.Views.TableView.TableView::itemSelectionChanged(), and cond::persistency::QueryIterator< Types >::operator++().

456  {
457  if(!m_cursor) throwException( "The query has not been executed.","Query::currentRow");
458  return m_cursor->currentRow();
459  }
coral::ICursor * m_cursor
Definition: DbCore.h:479
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
template<typename... Types>
const QueryIterator<Types...> cond::persistency::Query< Types >::end ( void  )
inline

Definition at line 469 of file DbCore.h.

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

469  {
470  return QueryIterator<Types...>( this );
471  }
template<typename... Types>
bool cond::persistency::Query< Types >::next ( void  )
inline

Definition at line 449 of file DbCore.h.

Referenced by BeautifulSoup.PageElement::_invert(), and cond::persistency::QueryIterator< Types >::operator++().

449  {
450  if(!m_cursor) throwException( "The query has not been executed.","Query::currentRow");
451  bool ret = m_cursor->next();
452  if( ret ) m_retrievedRows++;
453  return ret;
454  }
coral::ICursor * m_cursor
Definition: DbCore.h:479
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
template<typename... Types>
size_t cond::persistency::Query< Types >::retrievedRows ( ) const
inline

Definition at line 473 of file DbCore.h.

473  {
474  return m_retrievedRows;
475  }
template<typename... Types>
void cond::persistency::Query< Types >::setForUpdate ( )
inline

Definition at line 445 of file DbCore.h.

445  {
446  m_coralQuery->setForUpdate();
447  }
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:478

Member Data Documentation

template<typename... Types>
std::unique_ptr<coral::IQuery> cond::persistency::Query< Types >::m_coralQuery
private
template<typename... Types>
coral::ICursor* cond::persistency::Query< Types >::m_cursor = 0
private
template<typename... Types>
size_t cond::persistency::Query< Types >::m_retrievedRows = 0
private
template<typename... Types>
std::set<std::string> cond::persistency::Query< Types >::m_tables
private

Definition at line 483 of file DbCore.h.

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

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