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)
 
const coral::AttributeList & data () const
 
bool isEmpty () const
 
const std::vector< std::pair
< std::string, std::string > > & 
items () const
 
 Selection ()
 
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

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

Detailed Description

Definition at line 15 of file Selection.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file Selection.cc.

28  :m_items(),m_data(){
29 }
coral::AttributeList m_data
Definition: Selection.h:46
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:45
Selection< C, Selector, StoreContainer >::~Selection ( )
virtual

Definition at line 31 of file Selection.cc.

31  {
32 }

Member Function Documentation

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

Definition at line 51 of file Selection.h.

References m_data, m_items, selectionTypes(), and uniqueVariableName().

51  {
52  std::string varName = uniqueVariableName( dataMemberName );
53  m_items.push_back(std::make_pair(varName,selectionTypes()[stype]));
54  m_data.extend<Prim>(varName);
55  m_data[varName].data<Prim>()=selectionData;
56 }
std::string uniqueVariableName(const std::string &varName) const
Definition: Selection.cc:35
static std::vector< std::string > & selectionTypes()
Definition: Selection.cc:6
coral::AttributeList m_data
Definition: Selection.h:46
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:45
void Selection< C, Selector, StoreContainer >::addIndexItem ( int  startIndex,
int  endIndex = endOfRange 
)

Definition at line 54 of file Selection.cc.

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

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

54  {
55  if(endIndex<startIndex && endIndex>=0) {
56  throwException("Cannot select with endIndex<startIndex.",
57  "Selection::addIndexItem");
58  } else if( startIndex==endIndex && endIndex>=0){
59  std::string varName = uniqueVariableName( indexVariable() );
60  SelectionItemType selType = ora::EQ;
61  m_items.push_back(std::make_pair(varName,selectionTypes()[selType]));
62  m_data.extend<int>(varName);
63  m_data[varName].data<int>() = startIndex;
64  } else {
65  if(startIndex>0){
66  std::string varName0 = uniqueVariableName( indexVariable() );
67  SelectionItemType firstType = ora::GE;
68  m_items.push_back(std::make_pair(varName0,selectionTypes()[firstType]));
69  m_data.extend<int>(varName0);
70  m_data[varName0].data<int>() = startIndex;
71  }
72  if(endIndex>0){
73  std::string varName1 = uniqueVariableName( indexVariable() );
74  SelectionItemType secondType = ora::LE;
75  m_items.push_back(std::make_pair(varName1,selectionTypes()[secondType]));
76  m_data.extend<int>(varName1);
77  m_data[varName1].data<int>() = endIndex;
78  }
79  }
80 }
std::string uniqueVariableName(const std::string &varName) const
Definition: Selection.cc:35
static std::vector< std::string > & selectionTypes()
Definition: Selection.cc:6
coral::AttributeList m_data
Definition: Selection.h:46
static std::string indexVariable()
Definition: Selection.cc:23
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:45
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
SelectionItemType
Definition: Selection.h:13
const coral::AttributeList & Selection< C, Selector, StoreContainer >::data ( ) const

Definition at line 93 of file Selection.cc.

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

93  {
94  return m_data;
95 }
coral::AttributeList m_data
Definition: Selection.h:46
std::string Selection< C, Selector, StoreContainer >::indexVariable ( )
static

Definition at line 23 of file Selection.cc.

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

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

Definition at line 83 of file Selection.cc.

83  {
84  return m_items.empty();
85 }
std::vector< std::pair< std::string, std::string > > m_items
Definition: Selection.h:45
const std::vector< std::pair< std::string, std::string > > & Selection< C, Selector, StoreContainer >::items ( ) const
std::vector< std::string > & Selection< C, Selector, StoreContainer >::selectionTypes ( )
static

Definition at line 6 of file Selection.cc.

Referenced by addDataItem().

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

Definition at line 35 of file Selection.cc.

References newFWLiteAna::found, and i.

Referenced by addDataItem().

35  {
36  std::stringstream uniqueVarName;
37  unsigned int i = 0;
38  bool notUnique = true;
39  while(notUnique){
40  bool found = false;
41  uniqueVarName.str("");
42  uniqueVarName << varName;
43  uniqueVarName << "_" << i;
44  for(coral::AttributeList::const_iterator iAttr = m_data.begin();
45  iAttr!=m_data.end() && !found; ++iAttr){
46  if( iAttr->specification().name() == uniqueVarName.str() ) found = true;
47  }
48  notUnique = found;
49  i++;
50  }
51  return uniqueVarName.str();
52 }
int i
Definition: DBlmapReader.cc:9
coral::AttributeList m_data
Definition: Selection.h:46
std::string Selection< C, Selector, StoreContainer >::variableNameFromUniqueString ( const std::string &  uniqueString)
static

Definition at line 17 of file Selection.cc.

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

18 {
19  size_t ind = uniqueString.rfind("_");
20  return uniqueString.substr(0,ind);
21 }

Member Data Documentation

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

Definition at line 18 of file Selection.h.

coral::AttributeList ora::Selection::m_data
private

Definition at line 46 of file Selection.h.

Referenced by addDataItem().

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

Definition at line 45 of file Selection.h.

Referenced by addDataItem().