thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
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 . More...
 
typedef ThePEG::Ptr< ObjT >::const_pointer cTPtr
 Alias for a reference counted pointer to a const ObjT . More...
 
typedef ThePEG::Ptr< ObjT >::transient_pointer tTPtr
 Alias for a transient pointer to ObjT . More...
 
typedef ThePEG::Ptr< ObjT >::transient_const_pointer tcTPtr
 Alias for a transient pointer to a const ObjT . More...
 
typedef map< IntT, tTPtrIndexObjectMap
 Map of objects to indices.
 
typedef map< TPtr, IntT > ObjectIndexMap
 Map of indices to objects. More...
 

Public Member Functions

 ObjectIndexer ()
 Empty constructor.
 
IntT operator() (tTPtr o)
 Return the index for the given object. More...
 
IntT operator() (tTPtr o) const
 Return the index for the given object. More...
 
IntT find (tTPtr o) const
 Return the index for the given object. More...
 
tTPtr operator() (IntT i)
 Return the object for the given index. More...
 
tTPtr operator() (IntT i) const
 Return the object for the given index. More...
 
tTPtr find (IntT i) const
 Return the object for the given index. More...
 
void operator() (IntT i, tTPtr o)
 Associate the given object with the given index. More...
 
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.

◆ 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.

Member Function Documentation

◆ find() [1/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.

Referenced by ThePEG::ObjectIndexer< long, ThePEG::ColourLine >::operator()().

◆ find() [2/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.

◆ operator()() [1/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.

◆ operator()() [2/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.

◆ operator()() [3/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.

◆ operator()() [4/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.

◆ operator()() [5/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.


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