#include <Rebinder.h>
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, TPtr > | MapType |
Map associating pairs of objects. | |
typedef MapType::const_iterator | const_iterator |
The iterator of the underlying map. | |
Public Member Functions | |
Rebinder () | |
Default constructor. | |
TPtr & | operator[] (tcTPtr t) |
Return a pointer to the object associated with the argument. | |
template<typename R> | |
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> | |
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 MapType & | map () const |
Acces the underlying map representation. | |
Private Member Functions | |
Rebinder (const Rebinder &) | |
The copy constructor is private and not implemented. | |
Rebinder & | operator= (const Rebinder &) |
The assignment operator is private and not implemented. | |
Private Attributes | |
MapType | theMap |
The underlying map representation. |
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.
typedef ThePEG::Ptr< T >::pointer ThePEG::Rebinder< T >::TPtr |
typedef ThePEG::Ptr< T >::const_pointer ThePEG::Rebinder< T >::cTPtr |
typedef ThePEG::Ptr< T >::transient_pointer ThePEG::Rebinder< T >::tTPtr |
typedef ThePEG::Ptr< T >::transient_const_pointer ThePEG::Rebinder< T >::tcTPtr |
typedef std::map<cTPtr,TPtr> ThePEG::Rebinder< T >::MapType |
typedef MapType::const_iterator ThePEG::Rebinder< T >::const_iterator |
ThePEG::Rebinder< T >::Rebinder | ( | ) | [inline] |
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.
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().
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().
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.
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().
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().