CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
ora::Selection Class Reference

#include <Selection.h>

Public Member Functions

template<typename Prim >
void addDataItem (const std::string &dataMemberName, SelectionItemType stype, Prim selectionData)
 
void addIndexItem (int startIndex, int endIndex=endOfRange)
 
void addUntypedDataItem (const std::string &dataMemberName, SelectionItemType stype, const std::type_info &primitiveType, void *data)
 
const coral::AttributeList & data () const
 
bool isEmpty () const
 
const std::vector< std::pair
< std::string, std::string > > & 
items () const
 
Selectionoperator= (const Selection &rhs)
 
 Selection ()
 
 Selection (const Selection &rhs)
 
virtual ~Selection ()
 

Static Public Member Functions

static std::string indexVariable ()
 
static std::vector< std::string > & selectionTypes ()
 
static std::string variableNameFromUniqueString (const std::string &uniqueString)
 

Static Public Attributes

static const int endOfRange = -1
 

Private Member Functions

std::string uniqueVariableName (const std::string &varName) const
 

Private Attributes

std::auto_ptr
< coral::AttributeList > 
m_data
 
std::vector< std::pair
< std::string, std::string > > 
m_items
 

Detailed Description

Definition at line 18 of file Selection.h.

Constructor & Destructor Documentation

Selection< C, Selector, StoreContainer >::Selection ( )

Definition at line 31 of file Selection.cc.

31  :m_items(),m_data( new coral::AttributeList ){
32 }
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:54
std::auto_ptr< coral::AttributeList > m_data
Definition: Selection.h:55
Selection< C, Selector, StoreContainer >::~Selection ( )
virtual

Definition at line 34 of file Selection.cc.

34  {
35 }
Selection< C, Selector, StoreContainer >::Selection ( const Selection rhs)

Definition at line 37 of file Selection.cc.

37  :
38  m_items( rhs.m_items ),
39  m_data( new coral::AttributeList( *rhs.m_data )){
40 }
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:54
std::auto_ptr< coral::AttributeList > m_data
Definition: Selection.h:55

Member Function Documentation

template<typename Prim >
void Selection< Prim >::addDataItem ( const std::string &  dataMemberName,
ora::SelectionItemType  stype,
Prim  selectionData 
)

Definition at line 60 of file Selection.h.

References addUntypedDataItem().

60  {
61  addUntypedDataItem( dataMemberName, stype, typeid( Prim ), &selectionData );
62 }
void addUntypedDataItem(const std::string &dataMemberName, SelectionItemType stype, const std::type_info &primitiveType, void *data)
Definition: Selection.cc:97
void Selection< C, Selector, StoreContainer >::addIndexItem ( int  startIndex,
int  endIndex = endOfRange 
)

Definition at line 68 of file Selection.cc.

References ora::EQ, ora::GE, ora::LE, and ora::throwException().

Referenced by ora::QueryableVector< Tp >::select().

69  {
70  if(endIndex<startIndex && endIndex>=0) {
71  throwException("Cannot select with endIndex<startIndex.",
72  "Selection::addIndexItem");
73  } else if( startIndex==endIndex && endIndex>=0){
74  std::string varName = uniqueVariableName( indexVariable() );
75  SelectionItemType selType = ora::EQ;
76  m_items.push_back(std::make_pair(varName,selectionTypes()[selType]));
77  m_data->extend<int>(varName);
78  (*m_data)[varName].data<int>() = startIndex;
79  } else {
80  if(startIndex>0){
81  std::string varName0 = uniqueVariableName( indexVariable() );
82  SelectionItemType firstType = ora::GE;
83  m_items.push_back(std::make_pair(varName0,selectionTypes()[firstType]));
84  m_data->extend<int>(varName0);
85  (*m_data)[varName0].data<int>() = startIndex;
86  }
87  if(endIndex>0){
88  std::string varName1 = uniqueVariableName( indexVariable() );
89  SelectionItemType secondType = ora::LE;
90  m_items.push_back(std::make_pair(varName1,selectionTypes()[secondType]));
91  m_data->extend<int>(varName1);
92  (*m_data)[varName1].data<int>() = endIndex;
93  }
94  }
95 }
std::string uniqueVariableName(const std::string &varName) const
Definition: Selection.cc:49
static std::vector< std::string > & selectionTypes()
Definition: Selection.cc:9
static std::string indexVariable()
Definition: Selection.cc:26
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:54
std::auto_ptr< coral::AttributeList > m_data
Definition: Selection.h:55
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
SelectionItemType
Definition: Selection.h:16
void Selection< C, Selector, StoreContainer >::addUntypedDataItem ( const std::string &  dataMemberName,
SelectionItemType  stype,
const std::type_info &  primitiveType,
void *  data 
)

Definition at line 97 of file Selection.cc.

Referenced by addDataItem().

100  {
101  std::string varName = uniqueVariableName( dataMemberName );
102  m_items.push_back(std::make_pair(varName,selectionTypes()[stype]));
103  m_data->extend( varName, primitiveType );
104  (*m_data)[varName].setValueFromAddress( data );
105 }
std::string uniqueVariableName(const std::string &varName) const
Definition: Selection.cc:49
const coral::AttributeList & data() const
Definition: Selection.cc:118
static std::vector< std::string > & selectionTypes()
Definition: Selection.cc:9
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:54
std::auto_ptr< coral::AttributeList > m_data
Definition: Selection.h:55
const coral::AttributeList & Selection< C, Selector, StoreContainer >::data ( ) const

Definition at line 118 of file Selection.cc.

Referenced by ora::QVQueryMaker::setQueryCondition().

118  {
119  return *m_data;
120 }
std::auto_ptr< coral::AttributeList > m_data
Definition: Selection.h:55
std::string Selection< C, Selector, StoreContainer >::indexVariable ( )
static

Definition at line 26 of file Selection.cc.

Referenced by ora::QVQueryMaker::setQueryCondition().

26  {
27  static std::string s_var("ora::ContainerIndex");
28  return s_var;
29 }
bool Selection< C, Selector, StoreContainer >::isEmpty ( ) const

Definition at line 108 of file Selection.cc.

108  {
109  return m_items.empty();
110 }
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:54
const std::vector< std::pair< std::string, std::string > > & Selection< C, Selector, StoreContainer >::items ( ) const
ora::Selection & Selection< C, Selector, StoreContainer >::operator= ( const Selection rhs)

Definition at line 42 of file Selection.cc.

References m_data, and m_items.

42  {
43  m_items = rhs.m_items;
44  m_data.reset( new coral::AttributeList( *rhs.m_data ) );
45  return *this;
46 }
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:54
std::auto_ptr< coral::AttributeList > m_data
Definition: Selection.h:55
std::vector< std::string > & Selection< C, Selector, StoreContainer >::selectionTypes ( )
static

Definition at line 9 of file Selection.cc.

9  {
10  static std::vector<std::string> types;
11  types.push_back("=");
12  types.push_back("!=");
13  types.push_back(">");
14  types.push_back(">=");
15  types.push_back("<");
16  types.push_back("<=");
17  return types;
18 }
std::string Selection< C, Selector, StoreContainer >::uniqueVariableName ( const std::string &  varName) const
private

Definition at line 49 of file Selection.cc.

References newFWLiteAna::found, and i.

49  {
50  std::stringstream uniqueVarName;
51  unsigned int i = 0;
52  bool notUnique = true;
53  while(notUnique){
54  bool found = false;
55  uniqueVarName.str("");
56  uniqueVarName << varName;
57  uniqueVarName << "_" << i;
58  for(coral::AttributeList::const_iterator iAttr = m_data->begin();
59  iAttr!=m_data->end() && !found; ++iAttr){
60  if( iAttr->specification().name() == uniqueVarName.str() ) found = true;
61  }
62  notUnique = found;
63  i++;
64  }
65  return uniqueVarName.str();
66 }
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< coral::AttributeList > m_data
Definition: Selection.h:55
std::string Selection< C, Selector, StoreContainer >::variableNameFromUniqueString ( const std::string &  uniqueString)
static

Definition at line 20 of file Selection.cc.

Referenced by ora::QVQueryMaker::setQueryCondition().

21 {
22  size_t ind = uniqueString.rfind("_");
23  return uniqueString.substr(0,ind);
24 }

Member Data Documentation

const int ora::Selection::endOfRange = -1
static

Definition at line 21 of file Selection.h.

std::auto_ptr<coral::AttributeList> ora::Selection::m_data
private

Definition at line 55 of file Selection.h.

Referenced by operator=().

std::vector<std::pair<std::string,std::string> > ora::Selection::m_items
private

Definition at line 54 of file Selection.h.

Referenced by operator=().