An auxiliary data store that holds data internally. More...
#include <AuxStoreInternal.h>
Classes | |
struct | TSAuxidSet |
Thread-local versions of the auxid set. | |
Public Member Functions | |
AuxStoreInternal (bool standalone=false) | |
Constructor. | |
virtual | ~AuxStoreInternal () |
Destructor. | |
AuxStoreInternal (const AuxStoreInternal &orig) | |
Copy constructor. | |
bool | standalone () const |
Return the standalone flag. | |
virtual const void * | getData (SG::auxid_t auxid) const ATH_OVERRIDE |
Return the data vector for one aux data item. | |
virtual void * | getData (SG::auxid_t auxid, size_t size, size_t capacity) ATH_OVERRIDE |
Return the data vector for one aux data item. | |
virtual void * | getDecoration (auxid_t auxid, size_t size, size_t capacity) ATH_OVERRIDE |
Return the data vector for one aux data decoration item. | |
virtual void | resize (size_t sz) ATH_OVERRIDE |
Change the size of all aux data vectors. | |
virtual void | reserve (size_t sz) ATH_OVERRIDE |
Change the capacity of all aux data vectors. | |
virtual void | shift (size_t pos, ptrdiff_t offs) ATH_OVERRIDE |
Shift the elements of the container. | |
virtual const SG::auxid_set_t & | getAuxIDs () const ATH_OVERRIDE |
Return a set of identifiers for existing data items in this store. | |
virtual const SG::auxid_set_t & | getWritableAuxIDs () const ATH_OVERRIDE |
Return a set of identifiers for writable data items in this store. | |
virtual const void * | getIOData (SG::auxid_t auxid) const ATH_OVERRIDE |
Return a pointer to the data to be stored for one aux data item. | |
virtual const std::type_info * | getIOType (SG::auxid_t auxid) const ATH_OVERRIDE |
Return the type of the data to be stored for one aux data item. | |
virtual const SG::auxid_set_t & | getDynamicAuxIDs () const ATH_OVERRIDE |
Get the list of all variables that need to be handled. | |
virtual void | lock () ATH_OVERRIDE |
Lock the container. | |
virtual void | clearDecorations () ATH_OVERRIDE |
Clear all decorations. | |
virtual size_t | size () const ATH_OVERRIDE |
Return the number of elements in the store. | |
virtual bool | setOption (auxid_t id, const AuxDataOption &option) ATH_OVERRIDE |
Set an option for an auxiliary data variable. | |
Protected Member Functions | |
const void * | getIODataInternal (auxid_t auxid, bool quiet) const |
Return a pointer to the data to be stored for one aux data item. | |
void | addAuxID (auxid_t auxid) |
Add a new auxid to the set of those being managed by this store. | |
virtual void * | getDataInternal (SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check) |
Return the data vector for one aux data item. |
An auxiliary data store that holds data internally.
When auxiliary data are associated with a container, the data themselves are managed by a separate `store' object, described by the interfaces SG::IAuxStore
and SG::IConstAuxStore
.
This class is an implementation of those interfaces that stores the data itself. This is suitable, for example, for transient auxiliary data.
SG::AuxStoreInternal::AuxStoreInternal | ( | bool | standalone = false |
) |
Constructor.
standalone | If true, then write this in standalone mode. |
SG::AuxStoreInternal::~AuxStoreInternal | ( | ) | [virtual] |
Destructor.
All contained data will be deleted.
void SG::AuxStoreInternal::addAuxID | ( | auxid_t | auxid | ) | [protected] |
Add a new auxid to the set of those being managed by this store.
auxid | The auxid to add. |
void SG::AuxStoreInternal::clearDecorations | ( | ) | [virtual] |
Clear all decorations.
Erase all decorations from the store, restoring the state to when lock
was called. Be sure to clear the cache of the referencing container!
Implements SG::IConstAuxStore.
const SG::auxid_set_t & SG::AuxStoreInternal::getAuxIDs | ( | ) | const [virtual] |
Return a set of identifiers for existing data items in this store.
This should include identifiers for all items, const and non-const.
Implements SG::IConstAuxStore.
void * SG::AuxStoreInternal::getData | ( | SG::auxid_t | auxid, | |
size_t | size, | |||
size_t | capacity | |||
) | [virtual] |
Return the data vector for one aux data item.
auxid | The identifier of the desired aux data item. | |
size | The current size of the container (in case the data item does not already exist). | |
capacity | The current capacity of the container (in case the data item does not already exist). |
Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.
If the data item does not exist, it should be created and initialized to default values. size
and capacity
give the size for the new aux data item vector.
Implements SG::IAuxStore.
const void * SG::AuxStoreInternal::getData | ( | SG::auxid_t | auxid | ) | const [virtual] |
Return the data vector for one aux data item.
auxid | The identifier of the desired aux data item. |
Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.
This should return 0 if the item doesn't exist.
Implements SG::IConstAuxStore.
void * SG::AuxStoreInternal::getDataInternal | ( | SG::auxid_t | auxid, | |
size_t | size, | |||
size_t | capacity, | |||
bool | no_lock_check | |||
) | [protected, virtual] |
Return the data vector for one aux data item.
auxid | The identifier of the desired aux data item. | |
size | The current size of the container (in case the data item does not already exist). | |
capacity | The current capacity of the container (in case the data item does not already exist). | |
no_lock_check | If true, then skip the test for a locked container. |
Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.
If the data item does not exist, it should be created and initialized to default values. size
and capacity
give the size for the new aux data item vector.
void * SG::AuxStoreInternal::getDecoration | ( | auxid_t | auxid, | |
size_t | size, | |||
size_t | capacity | |||
) | [virtual] |
Return the data vector for one aux data decoration item.
auxid | The identifier of the desired aux data item. | |
size | The current size of the container (in case the data item does not already exist). | |
capacity | The current capacity of the container (in case the data item does not already exist). |
Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.
If the data item does not exist, it then it will be created and initialized with default values. If the container is locked, then the new item will be marked as a decoration. size
and capacity
give the size for the new aux data item vector.
If the data item already exists, then we return it if either the container is not locked or the item is marked as a decoration. Otherwise we throw an exception.
Implements SG::IConstAuxStore.
const void * SG::AuxStoreInternal::getIOData | ( | SG::auxid_t | auxid | ) | const [virtual] |
Return a pointer to the data to be stored for one aux data item.
auxid | The identifier of the desired aux data item. |
This will usually be a pointer to a std::vector
; however, it may be something different for a standalone object.
Returns 0 and reports an error if the requested aux data item does not exist.
Implements SG::IAuxStoreIO.
const void * SG::AuxStoreInternal::getIODataInternal | ( | auxid_t | auxid, | |
bool | quiet | |||
) | const [protected] |
Return a pointer to the data to be stored for one aux data item.
auxid | The identifier of the desired aux data item. | |
quiet | If true, then don't print an error on failure. |
This will usually be a pointer to a std::vector
; however, it may be something different for a standalone object.
Returns 0 and reports an error if the requested aux data item does not exist.
const std::type_info * SG::AuxStoreInternal::getIOType | ( | SG::auxid_t | auxid | ) | const [virtual] |
Return the type of the data to be stored for one aux data item.
auxid | The identifier of the desired aux data item. |
For an aux data item of type T
, this will usually be std::vector<T>
. For standalone objects, however, it will usually be T
; and std::vector<char>
will be used instead of std::vector<bool>
.
Returns 0 if the requested aux data item does not exist.
Implements SG::IAuxStoreIO.
const SG::auxid_set_t & SG::AuxStoreInternal::getWritableAuxIDs | ( | ) | const [virtual] |
Return a set of identifiers for writable data items in this store.
This should include only non-const identifiers.
Implements SG::IAuxStore.
void SG::AuxStoreInternal::lock | ( | ) | [virtual] |
Lock the container.
After this, only decorations can be changed/modified. If the container is already locked, this is a no-op.
Implements SG::IConstAuxStore.
void SG::AuxStoreInternal::reserve | ( | size_t | sz | ) | [virtual] |
Change the capacity of all aux data vectors.
sz | The new capacity. |
This should be called when the capacity of the container changes (by reserve
). This should change the capacity for the vectors for all aux data items.
Implements SG::IAuxStore.
void SG::AuxStoreInternal::resize | ( | size_t | sz | ) | [virtual] |
Change the size of all aux data vectors.
sz | The new size. |
This should be called when the size of the container changes. This should resize the vectors for all aux data items.
If the size of the container grows, the new elements should be default-initialized; if it shrinks, destructors should be run as appropriate.
Implements SG::IAuxStore.
bool SG::AuxStoreInternal::setOption | ( | auxid_t | id, | |
const AuxDataOption & | option | |||
) | [virtual] |
Set an option for an auxiliary data variable.
id | The variable for which we want to set the option. | |
option | The option setting to make. |
The interpretation of option
depends on the associated auxiliary store. See PackedParameters.h for option settings for writing packed data. Returns true
on success, false
otherwise.
Reimplemented from SG::IAuxStore.
void SG::AuxStoreInternal::shift | ( | size_t | pos, | |
ptrdiff_t | offs | |||
) | [virtual] |
Shift the elements of the container.
pos | The starting index for the shift. | |
offs | The (signed) amount of the shift. |
This operation shifts the elements in the vectors for all aux data items, to implement an insertion or deletion. offs
may be either positive or negative.
If offs
is positive, then the container is growing. The container size should be increased by offs
, the element at pos
moved to pos
+ offs
, and similarly for following elements. The elements between pos
and pos
+ offs
should be default-initialized.
If offs
is negative, then the container is shrinking. The element at pos
should be moved to pos
+ offs
, and similarly for following elements. The container should then be shrunk by -offs
elements (running destructors as appropriate).
Implements SG::IAuxStore.
size_t SG::AuxStoreInternal::size | ( | ) | const [virtual] |
Return the number of elements in the store.
May return 0 for a store with no aux data.
Implements SG::IConstAuxStore.