List of all members | Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Attributes | Static Private Attributes
evt::ComponentGroup< Component > Class Template Reference

Common class for groups of components of the Event hierarchy. More...

#include "evt/ComponentGroup.h"

Inheritance diagram for evt::ComponentGroup< Component >:
Inheritance graph
[legend]

Classes

struct  SecondResolver
 

Public Types

typedef
boost::transform_iterator
< ConstComponentResolver,
PairConstIterator
ComponentConstIterator
 Alias for constant iterator over contained components. More...
 
typedef
boost::transform_iterator
< ComponentResolver,
PairIterator
ComponentIterator
 Alias for non-constant iterator over contained components. More...
 

Public Member Functions

ComponentIterator Begin ()
 
ComponentConstIterator Begin () const
 
 Check (i, e, id)
 
ComponentIterator End ()
 
ComponentConstIterator End () const
 
Component & Get (const int id)
 Retrieve by id. More...
 
int GetNumberOf () const
 Query quantity. More...
 
bool Has (const int id) const
 Query existence. More...
 
void Make (int id)
 Construct by id. More...
 

Public Attributes

const Component & const
 Retrieve by id. More...
 
const PairConstIterator e = fComponents.end()
 
return *i second
 

Private Types

typedef SecondResolver
< MappedReference, Reference
ComponentResolver
 
typedef SecondResolver
< ConstMappedReference,
ConstReference
ConstComponentResolver
 
typedef
InternalComponentCollection::const_mapped_reference 
ConstMappedReference
 
typedef const Component * ConstMappedType
 
typedef
InternalComponentCollection::const_reference 
ConstReference
 
typedef boost::ptr_map< int,
Component > 
InternalComponentCollection
 
typedef
InternalComponentCollection::key_type 
KeyType
 
typedef
InternalComponentCollection::mapped_reference 
MappedReference
 
typedef
InternalComponentCollection::mapped_type 
MappedType
 
typedef
InternalComponentCollection::const_iterator 
PairConstIterator
 
typedef
InternalComponentCollection::iterator 
PairIterator
 
typedef
InternalComponentCollection::reference 
Reference
 

Private Attributes

InternalComponentCollection fComponents
 

Static Private Attributes

static constexpr const
ConstComponentResolver 
kConstResolver = ConstComponentResolver()
 Instance of the (stateless) helper class (stored on a class for the containing class) for const component resolving. More...
 
static constexpr const
ComponentResolver 
kResolver = ComponentResolver()
 Non-const resolving. More...
 

Detailed Description

template<class Component>
class evt::ComponentGroup< Component >

Common class for groups of components of the Event hierarchy.

Groups elements of the event hierarchy and responds to the has/make/get interface.

Parameters
ComponentThe actual type of the component. Its instances are constructed here with the following expression
Component* c = new Component(id);
where id is of const int type.

Since the objects will be owned, they must be feasible to be destructed. In particular, given the innards of this class the destruction is perfomed, at last, by

template<class T> void boost::checked_delete(T*);

so the destructor must be accesible at least by that function.

Todo:
The friend declation that may be needed to be granted to checked_delete reveals the implementation of this class. It's somewhat the same that happens in this Event hierarchy with utl::LameShadowPtr in the sense that the class that will be buried inside the ShadowPtr gives friendship to ShadowPtr because it happens that ShadowPtr it's used to contain that class' instances in the parent object within the hierarchy. Another possibility is to leave the destructors public (but, of course, keeping restricted the means of construction), it doesn't seem likely that, by chance, the destructor is called from client code. Another last possibility (in the case of having to grant friendship to a type) would have been to allow typedef-names in friend declaration, so that an appropiate alias is declared and then friendship is declared using that alias: so that the real underlying type is hidden. Unfortunately up to now it isn't allowed, see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf
Author
Rodolfo Federico Gamarra
Date
03 Mar 2009

Definition at line 80 of file Event/ComponentGroup.h.

Member Typedef Documentation

template<class Component>
typedef boost::transform_iterator<ConstComponentResolver, PairConstIterator> evt::ComponentGroup< Component >::ComponentConstIterator

Alias for constant iterator over contained components.

See Also
ComponentIterator

Definition at line 140 of file Event/ComponentGroup.h.

template<class Component>
typedef boost::transform_iterator<ComponentResolver, PairIterator> evt::ComponentGroup< Component >::ComponentIterator

Alias for non-constant iterator over contained components.

See Also
ComponentConstIterator

Definition at line 146 of file Event/ComponentGroup.h.

template<class Component>
typedef SecondResolver<MappedReference, Reference> evt::ComponentGroup< Component >::ComponentResolver
private

Definition at line 122 of file Event/ComponentGroup.h.

template<class Component>
typedef SecondResolver<ConstMappedReference, ConstReference> evt::ComponentGroup< Component >::ConstComponentResolver
private

Definition at line 121 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::const_mapped_reference evt::ComponentGroup< Component >::ConstMappedReference
private

Definition at line 114 of file Event/ComponentGroup.h.

template<class Component>
typedef const Component* evt::ComponentGroup< Component >::ConstMappedType
private

Definition at line 112 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::const_reference evt::ComponentGroup< Component >::ConstReference
private

Definition at line 115 of file Event/ComponentGroup.h.

template<class Component>
typedef boost::ptr_map<int, Component> evt::ComponentGroup< Component >::InternalComponentCollection
private

Given the usage context where id-lookup is performed then seems better to introduce a map instead of a vector and using linear-search. On the other hand the iteration over the map should be still equally performing than the one over the vector. Then the map holds the relation id->Component.

Since the objects will be heap-allocated (and owned) favor Boost's ptr container instead a home-cooked raw * container.

Definition at line 108 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::key_type evt::ComponentGroup< Component >::KeyType
private

Definition at line 110 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::mapped_reference evt::ComponentGroup< Component >::MappedReference
private

Definition at line 113 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::mapped_type evt::ComponentGroup< Component >::MappedType
private

Definition at line 111 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::const_iterator evt::ComponentGroup< Component >::PairConstIterator
private

Definition at line 117 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::iterator evt::ComponentGroup< Component >::PairIterator
private

Definition at line 118 of file Event/ComponentGroup.h.

template<class Component>
typedef InternalComponentCollection::reference evt::ComponentGroup< Component >::Reference
private

Definition at line 116 of file Event/ComponentGroup.h.

Member Function Documentation

template<class Component>
ComponentIterator evt::ComponentGroup< Component >::Begin ( )
inline
template<class Component>
ComponentConstIterator evt::ComponentGroup< Component >::Begin ( ) const
inline

Definition at line 214 of file Event/ComponentGroup.h.

template<class Component>
evt::ComponentGroup< Component >::Check ( ,
e  ,
id   
)
template<class Component>
ComponentIterator evt::ComponentGroup< Component >::End ( )
inline
template<class Component>
ComponentConstIterator evt::ComponentGroup< Component >::End ( ) const
inline

Definition at line 217 of file Event/ComponentGroup.h.

template<class Component>
Component& evt::ComponentGroup< Component >::Get ( const int  id)
inline
template<class Component>
int evt::ComponentGroup< Component >::GetNumberOf ( ) const
inline
template<class Component>
bool evt::ComponentGroup< Component >::Has ( const int  id) const
inline
template<class Component>
void evt::ComponentGroup< Component >::Make ( int  id)
inline

Member Data Documentation

template<class Component>
const Component& evt::ComponentGroup< Component >::const
Initial value:
{
const PairConstIterator i = fComponents.find(id)

Retrieve by id.

Definition at line 153 of file Event/ComponentGroup.h.

template<class Component>
const PairConstIterator evt::ComponentGroup< Component >::e = fComponents.end()

Definition at line 155 of file Event/ComponentGroup.h.

template<class Component>
InternalComponentCollection evt::ComponentGroup< Component >::fComponents
private
template<class Component>
constexpr const ConstComponentResolver evt::ComponentGroup< Component >::kConstResolver = ConstComponentResolver()
staticprivate

Instance of the (stateless) helper class (stored on a class for the containing class) for const component resolving.

Definition at line 128 of file Event/ComponentGroup.h.

Referenced by evt::ComponentGroup< Scintillator >::Begin(), and evt::ComponentGroup< Scintillator >::End().

template<class Component>
constexpr const ComponentResolver evt::ComponentGroup< Component >::kResolver = ComponentResolver()
staticprivate

Non-const resolving.

See Also
fConstResolver

Definition at line 133 of file Event/ComponentGroup.h.

Referenced by evt::ComponentGroup< Scintillator >::Begin(), and evt::ComponentGroup< Scintillator >::End().

template<class Component>
return* i evt::ComponentGroup< Component >::second

Definition at line 157 of file Event/ComponentGroup.h.


The documentation for this class was generated from the following file:

, generated on Tue Sep 26 2023.