CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes

ora::Selection Class Reference

#include <Selection.h>

List of all members.

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.

                       :m_items(),m_data( new coral::AttributeList ){
}
Selection< C, Selector, StoreContainer >::~Selection ( ) [virtual]

Definition at line 34 of file Selection.cc.

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

Definition at line 37 of file Selection.cc.

                                                :
  m_items( rhs.m_items ),
  m_data( new coral::AttributeList( *rhs.m_data )){
}

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().

                                                                                                                                      {
  addUntypedDataItem( dataMemberName, stype, typeid( Prim ), &selectionData );
}
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().

                                                 {
  if(endIndex<startIndex && endIndex>=0) {
    throwException("Cannot select with endIndex<startIndex.",
                   "Selection::addIndexItem");
  } else if( startIndex==endIndex && endIndex>=0){
    std::string varName = uniqueVariableName( indexVariable() );
    SelectionItemType selType = ora::EQ;
    m_items.push_back(std::make_pair(varName,selectionTypes()[selType]));
    m_data->extend<int>(varName);
    (*m_data)[varName].data<int>() = startIndex;    
  } else {
    if(startIndex>0){
      std::string varName0 = uniqueVariableName( indexVariable() );
      SelectionItemType firstType = ora::GE;
      m_items.push_back(std::make_pair(varName0,selectionTypes()[firstType]));
      m_data->extend<int>(varName0);
      (*m_data)[varName0].data<int>() = startIndex;
    }
    if(endIndex>0){
      std::string varName1 = uniqueVariableName( indexVariable() );
      SelectionItemType secondType = ora::LE;
      m_items.push_back(std::make_pair(varName1,selectionTypes()[secondType]));
      m_data->extend<int>(varName1);
      (*m_data)[varName1].data<int>() = endIndex;
    }
  }
}
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().

                                                      {
  std::string varName = uniqueVariableName( dataMemberName );
  m_items.push_back(std::make_pair(varName,selectionTypes()[stype]));
  m_data->extend( varName, primitiveType );
  (*m_data)[varName].setValueFromAddress( data );
}
const coral::AttributeList & Selection< C, Selector, StoreContainer >::data ( ) const

Definition at line 118 of file Selection.cc.

                         {
  return *m_data;
}
std::string Selection< C, Selector, StoreContainer >::indexVariable ( ) [static]

Definition at line 26 of file Selection.cc.

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

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

Definition at line 108 of file Selection.cc.

                            {
  return m_items.empty();
}
const std::vector< std::pair< std::string, std::string > > & Selection< C, Selector, StoreContainer >::items ( ) const

Definition at line 113 of file Selection.cc.

                          {
  return m_items;
}
ora::Selection & Selection< C, Selector, StoreContainer >::operator= ( const Selection rhs)

Definition at line 42 of file Selection.cc.

References m_data, and m_items.

                                                              {
  m_items = rhs.m_items;
  m_data.reset( new coral::AttributeList( *rhs.m_data ) );
  return *this;
}
std::vector< std::string > & Selection< C, Selector, StoreContainer >::selectionTypes ( ) [static]

Definition at line 9 of file Selection.cc.

                                                  {
  static std::vector<std::string> types;
  types.push_back("=");
  types.push_back("!=");
  types.push_back(">");
  types.push_back(">=");
  types.push_back("<");
  types.push_back("<=");
  return types;
}
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.

                                                               {
  std::stringstream uniqueVarName;
  unsigned int i = 0;
  bool notUnique = true;
  while(notUnique){
    bool found = false;
    uniqueVarName.str("");
    uniqueVarName << varName;
    uniqueVarName << "_" << i;
    for(coral::AttributeList::const_iterator iAttr = m_data->begin();
        iAttr!=m_data->end() && !found; ++iAttr){
      if( iAttr->specification().name() == uniqueVarName.str() ) found = true;
    }
    notUnique = found;
    i++;
  }
  return uniqueVarName.str();
}
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().

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

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=().