SG::AuxElement::Decorator< T > Class Template Reference

Helper class to provide type-safe access to aux data. More...

#include <AuxElement.h>

List of all members.

Public Types

typedef AuxDataTraits< T >
::reference_type 
reference_type
 Type referencing an item.
typedef AuxDataTraits< T >
::element_type 
element_type
 Type the user sees.
typedef AuxDataTraits< T >
::container_pointer_type 
container_pointer_type
 Pointer into the container holding this item.
typedef AuxDataTraits< T >
::const_container_pointer_type 
const_container_pointer_type

Public Member Functions

 Decorator (const std::string &name)
 Constructor.
 Decorator (const std::string &name, const std::string &clsname)
 Constructor.
reference_type operator() (const AuxElement &e) const
 Fetch the variable for one element, as a non-const reference.
reference_type operator() (const AuxVectorData &container, size_t index) const
 Fetch the variable for one element, as a non-const reference.
void set (const AuxElement &e, const element_type &x) const
 Set the variable for one element.
const_container_pointer_type getDataArray (const AuxVectorData &container) const
 Get a pointer to the start of the auxiliary data array.
bool isAvailable (const AuxElement &e) const
 Test to see if this variable exists in the store.
bool isAvailableWritable (const AuxElement &e) const
 Test to see if this variable exists in the store and is writable.
SG::auxid_t auxid () const
 Return the aux id for this variable.

Detailed Description

template<class T>
class SG::AuxElement::Decorator< T >

Helper class to provide type-safe access to aux data.

This is like Accessor, except that it only `decorates' the container. What this means is that this object can operate on a const container and return a non-const reference. However, if the container is locked, this will only work if either this is a reference to a new variable, in which case it is marked as a decoration, or it is a reference to a variable already marked as a decoration.

This is written as a separate class in order to be able to cache the name -> auxid lookup.

You might use this something like this:

   // Only need to do this once.
   Myclass::Decorator<int> vint1 ("myInt");
   ...
   const Myclass* m = ...;
   vint1 (*m) = 123;

Constructor & Destructor Documentation

template<class T >
SG::AuxElement::Decorator< T >::Decorator ( const std::string &  name  )  [inline]

Constructor.

Parameters:
name Name of this aux variable.

The name -> auxid lookup is done here.

template<class T >
SG::AuxElement::Decorator< T >::Decorator ( const std::string &  name,
const std::string &  clsname 
) [inline]

Constructor.

Parameters:
name Name of this aux variable.
clsname The name of its associated class. May be blank.

The name -> auxid lookup is done here.


Member Function Documentation

template<class T >
AuxElement::Decorator< T >::const_container_pointer_type SG::AuxElement::Decorator< T >::getDataArray ( const AuxVectorData container  )  const [inline]

Get a pointer to the start of the auxiliary data array.

Parameters:
container The container from which to fetch the variable.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

template<class T >
bool SG::AuxElement::Decorator< T >::isAvailable ( const AuxElement e  )  const [inline]

Test to see if this variable exists in the store.

Parameters:
e An element of the container which to test the variable.
template<class T >
bool SG::AuxElement::Decorator< T >::isAvailableWritable ( const AuxElement e  )  const [inline]

Test to see if this variable exists in the store and is writable.

Parameters:
e An element of the container which to test the variable.
template<class T >
AuxElement::Decorator< T >::reference_type SG::AuxElement::Decorator< T >::operator() ( const AuxVectorData container,
size_t  index 
) const [inline]

Fetch the variable for one element, as a non-const reference.

Parameters:
container The container from which to fetch the variable.
index The index of the desired element.

This allows retrieving aux data by container / index. Looping over the index via this method will be faster then looping over the elements of the container.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

template<class T >
AuxElement::Decorator< T >::reference_type SG::AuxElement::Decorator< T >::operator() ( const AuxElement e  )  const [inline]

Fetch the variable for one element, as a non-const reference.

Parameters:
e The element for which to fetch the variable.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

template<class T >
void SG::AuxElement::Decorator< T >::set ( const AuxElement e,
const element_type x 
) const [inline]

Set the variable for one element.

Parameters:
e The element for which to fetch the variable.
x The variable value to set.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1