ThePEG::Rebinder< T > Class Template Reference

Rebinder is a class associating pairs of pointers to objects. More...

#include <Rebinder.h>

List of all members.

Public Types

typedef ThePEG::Ptr< T >::pointer TPtr
 Alias for a reference counted pointer to T .
typedef ThePEG::Ptr< T >
::const_pointer 
cTPtr
 Alias for a reference counted pointer to a const T .
typedef ThePEG::Ptr< T >
::transient_pointer 
tTPtr
 Alias for a transient pointer to T .
typedef ThePEG::Ptr< T >
::transient_const_pointer 
tcTPtr
 Alias for a transient pointer to a const T .
typedef std::map< cTPtr, TPtrMapType
 Map associating pairs of objects.
typedef MapType::const_iterator const_iterator
 The iterator of the underlying map.

Public Member Functions

 Rebinder ()
 Default constructor.
TPtroperator[] (tcTPtr t)
 Return a pointer to the object associated with the argument.
template<typename R>
translate (const R &r) const
 Return a pointer to the object associated with the argument.
template<typename OutputIterator, typename InputIterator>
void translate (OutputIterator r, InputIterator first, InputIterator last) const
 Insert pointers to objects into the output iterator, pointers to objects corresponding to the ones given by the range of input iterators.
template<typename R>
alwaysTranslate (const R &r) const throw (std::runtime_error)
 Return a pointer to the object associated with the argument.
template<typename OutputIterator, typename InputIterator>
void alwaysTranslate (OutputIterator r, InputIterator first, InputIterator last) const throw (std::runtime_error)
 Insert pointers to objects into the output iterator, pointers to objects corresponding to the ones given by the range of input iterators.
const MapTypemap () const
 Acces the underlying map representation.

Private Member Functions

 Rebinder (const Rebinder &)
 The copy constructor is private and not implemented.
Rebinderoperator= (const Rebinder &)
 The assignment operator is private and not implemented.

Private Attributes

MapType theMap
 The underlying map representation.


Detailed Description

template<typename T>
class ThePEG::Rebinder< T >

Rebinder is a class associating pairs of pointers to objects.

It is typically used when cloning a set of objects which have pointers to eachother. The Rebinder is then set up so that a cloned object can easily be retrieved given a pointer to the original one. The cloned objects can then use the Rebinder to change their pointers so that they henceforth points to the cloned copies.

Definition at line 27 of file Rebinder.h.


Member Typedef Documentation

template<typename T>
typedef ThePEG::Ptr< T >::pointer ThePEG::Rebinder< T >::TPtr

Alias for a reference counted pointer to T .

Definition at line 36 of file Rebinder.h.

template<typename T>
typedef ThePEG::Ptr< T >::const_pointer ThePEG::Rebinder< T >::cTPtr

Alias for a reference counted pointer to a const T .

Definition at line 36 of file Rebinder.h.

template<typename T>
typedef ThePEG::Ptr< T >::transient_pointer ThePEG::Rebinder< T >::tTPtr

Alias for a transient pointer to T .

Definition at line 36 of file Rebinder.h.

template<typename T>
typedef ThePEG::Ptr< T >::transient_const_pointer ThePEG::Rebinder< T >::tcTPtr

Alias for a transient pointer to a const T .

Definition at line 36 of file Rebinder.h.

template<typename T>
typedef std::map<cTPtr,TPtr> ThePEG::Rebinder< T >::MapType

Map associating pairs of objects.

Definition at line 39 of file Rebinder.h.

template<typename T>
typedef MapType::const_iterator ThePEG::Rebinder< T >::const_iterator

The iterator of the underlying map.

Definition at line 42 of file Rebinder.h.


Constructor & Destructor Documentation

template<typename T>
ThePEG::Rebinder< T >::Rebinder (  )  [inline]

Default constructor.

Definition at line 32 of file Rebinder.h.


Member Function Documentation

template<typename T>
template<typename R>
R ThePEG::Rebinder< T >::translate ( const R &  r  )  const [inline]

Return a pointer to the object associated with the argument.

If no corresponding object is found a null pointer given by R() is returned.

Parameters:
r a pointer to an object of a type which is derived from T.

Definition at line 58 of file Rebinder.h.

References ThePEG::Pointer::dynamic_ptr_cast(), and ThePEG::Rebinder< T >::theMap.

Referenced by ThePEG::Rebinder< T >::translate().

template<typename T>
template<typename OutputIterator, typename InputIterator>
void ThePEG::Rebinder< T >::translate ( OutputIterator  r,
InputIterator  first,
InputIterator  last 
) const [inline]

Insert pointers to objects into the output iterator, pointers to objects corresponding to the ones given by the range of input iterators.

If a given object in the input iterator range does not exists, a null pointer will be inserted in the output iterator.

Definition at line 70 of file Rebinder.h.

References ThePEG::Rebinder< T >::translate().

template<typename T>
template<typename R>
R ThePEG::Rebinder< T >::alwaysTranslate ( const R &  r  )  const throw (std::runtime_error) [inline]

Return a pointer to the object associated with the argument.

If no corresponding object is found an exception is thrown.

Parameters:
r a pointer to an object of a type which is derived from T.

Definition at line 81 of file Rebinder.h.

References ThePEG::Pointer::dynamic_ptr_cast(), and ThePEG::Rebinder< T >::theMap.

Referenced by ThePEG::Rebinder< T >::alwaysTranslate().

template<typename T>
template<typename OutputIterator, typename InputIterator>
void ThePEG::Rebinder< T >::alwaysTranslate ( OutputIterator  r,
InputIterator  first,
InputIterator  last 
) const throw (std::runtime_error) [inline]

Insert pointers to objects into the output iterator, pointers to objects corresponding to the ones given by the range of input iterators.

If a given object in the input iterator range does not exists, an exception will be thrown.

Definition at line 97 of file Rebinder.h.

References ThePEG::Rebinder< T >::alwaysTranslate().


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

Generated on Thu Apr 29 12:43:25 2010 for ThePEG by  doxygen 1.5.5