CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions
FWItemDetSetAccessor< C, COLL, V > Class Template Reference

#include <FWItemRandomAccessor.h>

Inheritance diagram for FWItemDetSetAccessor< C, COLL, V >:
FWItemRandomAccessorBase FWItemAccessorBase

Public Types

typedef COLL collection_type
 
typedef V collection_value_type
 
typedef C container_type
 

Public Member Functions

 FWItemDetSetAccessor (const TClass *iClass)
 
const void * modelData (int iIndex) const
 
 REGISTER_FWITEMACCESSOR_METHODS ()
 
unsigned int size () const
 
- Public Member Functions inherited from FWItemRandomAccessorBase
const void * data () const
 
bool isCollection () const
 
const TClass * modelType () const
 
virtual void reset ()
 
void setData (const edm::ObjectWithDict &)
 override if id of an object should be different than the index More...
 
const TClass * type () const
 
virtual ~FWItemRandomAccessorBase ()
 
- Public Member Functions inherited from FWItemAccessorBase
 FWItemAccessorBase ()
 
virtual ~FWItemAccessorBase ()
 

Additional Inherited Members

- Protected Member Functions inherited from FWItemRandomAccessorBase
 FWItemRandomAccessorBase (const TClass *type, const type_info &modelTypeName)
 
void * getDataPtr () const
 
- Protected Attributes inherited from FWItemRandomAccessorBase
void * m_data
 
const TClass * m_modelType
 
const TClass * m_type
 

Detailed Description

template<class C, class COLL = typename C::value_type, class V = typename COLL::value_type>
class FWItemDetSetAccessor< C, COLL, V >

Generic class for creating accessors for containers which are implemented as a container of containers. This for example includes DetSetVector hence the name. Both the outer and the inner containers must follow the Random Access Container model and in particular must have a size() method. The outer collection must be iterable, while the inner collections must have an array subscript operator.

Definition at line 109 of file FWItemRandomAccessor.h.

Member Typedef Documentation

template<class C , class COLL = typename C::value_type, class V = typename COLL::value_type>
typedef COLL FWItemDetSetAccessor< C, COLL, V >::collection_type

Definition at line 113 of file FWItemRandomAccessor.h.

template<class C , class COLL = typename C::value_type, class V = typename COLL::value_type>
typedef V FWItemDetSetAccessor< C, COLL, V >::collection_value_type

Definition at line 114 of file FWItemRandomAccessor.h.

template<class C , class COLL = typename C::value_type, class V = typename COLL::value_type>
typedef C FWItemDetSetAccessor< C, COLL, V >::container_type

Definition at line 112 of file FWItemRandomAccessor.h.

Constructor & Destructor Documentation

template<class C , class COLL = typename C::value_type, class V = typename COLL::value_type>
FWItemDetSetAccessor< C, COLL, V >::FWItemDetSetAccessor ( const TClass *  iClass)
inline

Definition at line 116 of file FWItemRandomAccessor.h.

118  {}
FWItemRandomAccessorBase(const TClass *type, const type_info &modelTypeName)

Member Function Documentation

template<class C , class COLL = typename C::value_type, class V = typename COLL::value_type>
const void* FWItemDetSetAccessor< C, COLL, V >::modelData ( int  iIndex) const
inlinevirtual

Implements FWItemAccessorBase.

Definition at line 122 of file FWItemRandomAccessor.h.

References trackerHits::c, FWItemRandomAccessorBase::getDataPtr(), i, and FWItemDetSetAccessor< C, COLL, V >::size().

123  {
124  if (!getDataPtr())
125  return 0;
126  const container_type *c = reinterpret_cast<const container_type*>(getDataPtr());
127  size_t collectionOffset = 0;
128  for (typename container_type::const_iterator ci = c->begin(), ce = c->end(); ci != ce; ++ci)
129  {
130  size_t i = iIndex - collectionOffset;
131  if (i < ci->size())
132  return &(ci->operator[](i));
133  collectionOffset += ci->size();
134  }
135 
136  return 0;
137  }
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
template<class C , class COLL = typename C::value_type, class V = typename COLL::value_type>
FWItemDetSetAccessor< C, COLL, V >::REGISTER_FWITEMACCESSOR_METHODS ( )
template<class C , class COLL = typename C::value_type, class V = typename COLL::value_type>
unsigned int FWItemDetSetAccessor< C, COLL, V >::size ( void  ) const
inlinevirtual

Implements FWItemAccessorBase.

Definition at line 139 of file FWItemRandomAccessor.h.

References trackerHits::c, alignCSCRings::e, FWItemRandomAccessorBase::getDataPtr(), and i.

Referenced by FWItemDetSetAccessor< C, COLL, V >::modelData().

140  {
141  if (!getDataPtr())
142  return 0;
143  const container_type *c = reinterpret_cast<const container_type*>(getDataPtr());
144  size_t finalSize = 0;
145 
146  for (typename container_type::const_iterator i = c->begin(), e = c->end(); i != e; ++i)
147  finalSize += i->size();
148 
149  return finalSize;
150  }
int i
Definition: DBlmapReader.cc:9