thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ThePEG::ObjectIndexer< IntT, ObjT, NoIndex > Class Template Reference

This is a templated class which dynamically associates (reference counted) objects to integer indices. More...

#include <ObjectIndexer.h>

Inheritance diagram for ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >:

Public Types

typedef ThePEG::Ptr< ObjT >::pointer TPtr
 Alias for a reference counted pointer to ObjT .
 
typedef ThePEG::Ptr< ObjT >::const_pointer cTPtr
 Alias for a reference counted pointer to a const ObjT .
 
typedef ThePEG::Ptr< ObjT >::transient_pointer tTPtr
 Alias for a transient pointer to ObjT .
 
typedef ThePEG::Ptr< ObjT >::transient_const_pointer tcTPtr
 Alias for a transient pointer to a const ObjT .
 
typedef map< IntT, tTPtrIndexObjectMap
 Map of objects to indices.
 
typedef map< TPtr, IntT > ObjectIndexMap
 Map of indices to objects.
 

Public Member Functions

 ObjectIndexer ()
 Empty constructor.
 
IntT operator() (tTPtr o)
 Return the index for the given object.
 
IntT operator() (tTPtr o) const
 Return the index for the given object.
 
IntT find (tTPtr o) const
 Return the index for the given object.
 
tTPtr operator() (IntT i)
 Return the object for the given index.
 
tTPtr operator() (IntT i) const
 Return the object for the given index.
 
tTPtr find (IntT i) const
 Return the object for the given index.
 
void operator() (IntT i, tTPtr o)
 Associate the given object with the given index.
 
bool included (tTPtr o) const
 Return true if the given object is known.
 
bool included (IntT i) const
 Return true if the given index is known.
 
void clear ()
 Remove all associations.
 
bool empty () const
 Return true if no associations has been made.
 

Private Member Functions

ObjectIndexeroperator= (const ObjectIndexer &)=delete
 Private and non-existent assignment operator.
 

Private Attributes

IndexObjectMap indexObject
 All known objects keyed by their indices.
 
ObjectIndexMap objectIndex
 All known indices keyed by the corresponding objects.
 
IntT next
 The next index to be used.
 

Detailed Description

template<typename IntT, typename ObjT, IntT NoIndex = static_cast<IntT>(-1)>
class ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >

This is a templated class which dynamically associates (reference counted) objects to integer indices.

By default, all indices will be non-negative, but explicit usage of negative indices is allowed as long as they do not include NoIndex.

Definition at line 25 of file ObjectIndexer.h.

Member Typedef Documentation

◆ cTPtr

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
typedef ThePEG::Ptr<ObjT>::const_pointer ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::cTPtr

Alias for a reference counted pointer to a const ObjT .

Definition at line 29 of file ObjectIndexer.h.

◆ IndexObjectMap

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
typedef map<IntT,tTPtr> ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::IndexObjectMap

Map of objects to indices.

Definition at line 32 of file ObjectIndexer.h.

◆ ObjectIndexMap

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
typedef map<TPtr,IntT> ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::ObjectIndexMap

Map of indices to objects.

Definition at line 35 of file ObjectIndexer.h.

◆ tcTPtr

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
typedef ThePEG::Ptr<ObjT>::transient_const_pointer ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::tcTPtr

Alias for a transient pointer to a const ObjT .

Definition at line 29 of file ObjectIndexer.h.

◆ TPtr

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
typedef ThePEG::Ptr<ObjT>::pointer ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::TPtr

Alias for a reference counted pointer to ObjT .

Definition at line 29 of file ObjectIndexer.h.

◆ tTPtr

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
typedef ThePEG::Ptr<ObjT>::transient_pointer ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::tTPtr

Alias for a transient pointer to ObjT .

Definition at line 29 of file ObjectIndexer.h.

Constructor & Destructor Documentation

◆ ObjectIndexer()

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::ObjectIndexer ( )
inline

Empty constructor.

Definition at line 42 of file ObjectIndexer.h.

Member Function Documentation

◆ clear()

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
void ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::clear ( )
inline

◆ empty()

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
bool ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::empty ( ) const
inline

Return true if no associations has been made.

Definition at line 152 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::indexObject, and ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::objectIndex.

◆ find() [1/2]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
tTPtr ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::find ( IntT  i) const
inline

Return the object for the given index.

If the index is not known, a null pointer will be returned.

Definition at line 106 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::indexObject.

◆ find() [2/2]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
IntT ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::find ( tTPtr  o) const
inline

Return the index for the given object.

If the object is not known, NoIndex will be returned.

Definition at line 71 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::objectIndex.

Referenced by ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::operator()().

◆ included() [1/2]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
bool ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::included ( IntT  i) const
inline

Return true if the given index is known.

Definition at line 137 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::indexObject.

◆ included() [2/2]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
bool ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::included ( tTPtr  o) const
inline

Return true if the given object is known.

Definition at line 130 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::objectIndex.

◆ operator()() [1/5]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
tTPtr ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::operator() ( IntT  i)
inline

Return the object for the given index.

If the index is not known, a new object will be (default) created.

Definition at line 80 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::indexObject, ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::next, and ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::objectIndex.

◆ operator()() [2/5]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
tTPtr ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::operator() ( IntT  i) const
inline

Return the object for the given index.

If the index is not known, a null pointer will be returned.

Definition at line 98 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::find().

◆ operator()() [3/5]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
void ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::operator() ( IntT  i,
tTPtr  o 
)
inline

Associate the given object with the given index.

Possible other associations involving the index or the object is removed. If the given index is NoIndex, this function does nothing.

Definition at line 116 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::indexObject, ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::next, and ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::objectIndex.

◆ operator()() [4/5]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
IntT ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::operator() ( tTPtr  o)
inline

Return the index for the given object.

If the object is not known, a new index will be created.

Definition at line 48 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::indexObject, ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::next, and ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::objectIndex.

◆ operator()() [5/5]

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
IntT ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::operator() ( tTPtr  o) const
inline

Return the index for the given object.

If the object is not known, NoIndex will be returned.

Definition at line 63 of file ObjectIndexer.h.

References ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::find().

Member Data Documentation

◆ indexObject

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
IndexObjectMap ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::indexObject
private

◆ next

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
IntT ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::next
private

The next index to be used.

Definition at line 171 of file ObjectIndexer.h.

Referenced by ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::operator()().

◆ objectIndex

template<typename IntT , typename ObjT , IntT NoIndex = static_cast<IntT>(-1)>
ObjectIndexMap ThePEG::ObjectIndexer< IntT, ObjT, NoIndex >::objectIndex
private

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