Teuchos - Trilinos Tools Package
Version of the Day
|
Simple object object database. More...
#include <Teuchos_SimpleObjectDB.hpp>
Public Member Functions | |
SimpleObjectDB () | |
Construct an empty DB. More... | |
int | tableSize () const |
Return the current size of the table. More... | |
int | numFreeIndexes () const |
Return number of free indexes. More... | |
int | numObjects () const |
Return number of non-null stored objects. More... | |
int | storeNonconstObj (const RCP< T > &obj) |
Store a non-const object. More... | |
int | storeConstObj (const RCP< const T > &obj) |
Store a const object. More... | |
template<class TOld > | |
int | storeCastedNonconstObj (const RCP< TOld > &robj_old) |
Performs an rcp_dynamic_cast<>() to store the obejct. More... | |
void | removeObj (const int index) |
Remove a stored object without returning it. More... | |
RCP< T > | removeNonconstObj (const int index) |
RCP< const T > | removeConstObj (const int index) |
int | removeRCP (int &index) |
Remove an indexed object from the table. More... | |
RCP< T > | getNonconstObjRCP (const int index) |
Get an object (nonconst persisting association). More... | |
RCP< const T > | getConstObjRCP (const int index) const |
Get an object (const persisting association). More... | |
Ptr< T > | getNonconstObjPtr (const int index) |
Get an object (nonconst semi-persisting association). More... | |
Ptr< const T > | getConstObjPtr (const int index) const |
Get an object (const semi-persisting association). More... | |
void | purge () |
Clear out all storage. More... | |
Simple object object database.
This class provides a central place to store objects.
This simple class stores and retrieves objects (using an simple integral type index).
The main advantages of using this class over a simple Teuchos::Array<RCP<T>
object are:
Object indexes are reused to allow large numbers of store[Nonconst,Const]Obj()/removeObj() calls without growing memory. A simple Teuchos::Array implementation would not allow for that.
Seemlessly handle both const and non-const objects using the runtime protection of const.
NOTE: The type should always be a nonconst type (i.e. T=SomeType
) and not a const type (i.e. not T=const SomeType
). The class will not compile if given a const type.
Definition at line 54 of file Teuchos_SimpleObjectDB.hpp.
Teuchos::SimpleObjectDB< T >::SimpleObjectDB | ( | ) |
Construct an empty DB.
Definition at line 189 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::tableSize | ( | ) | const |
Return the current size of the table.
This number will be greater or equal to the number of currently stored objects. This function is really only of interest to unit testing code.
Definition at line 194 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::numFreeIndexes | ( | ) | const |
Return number of free indexes.
This is the number of free table indexes that are ready to be recycled for objects to be added.
Definition at line 201 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::numObjects | ( | ) | const |
Return number of non-null stored objects.
Definition at line 208 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::storeNonconstObj | ( | const RCP< T > & | obj | ) |
Store a non-const object.
Definition at line 215 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::storeConstObj | ( | const RCP< const T > & | obj | ) |
Store a const object.
Definition at line 222 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::storeCastedNonconstObj | ( | const RCP< TOld > & | robj_old | ) |
Performs an rcp_dynamic_cast<>() to store the obejct.
If the dynamic cast fails, then an exception is thrown.
Definition at line 230 of file Teuchos_SimpleObjectDB.hpp.
void Teuchos::SimpleObjectDB< T >::removeObj | ( | const int | index | ) |
Remove a stored object without returning it.
This function avoids reference counting overhead when the user just wants the object to go away and does not care to grab it.
Definition at line 237 of file Teuchos_SimpleObjectDB.hpp.
RCP< T > Teuchos::SimpleObjectDB< T >::removeNonconstObj | ( | const int | index | ) |
Remove a stored non-const object from the table and return it.
This will throw NonconstAccessError if a const object was added with storeConstObj()
.
Definition at line 245 of file Teuchos_SimpleObjectDB.hpp.
RCP< const T > Teuchos::SimpleObjectDB< T >::removeConstObj | ( | const int | index | ) |
Remove a stored const object from the table and return it.
Definition at line 255 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::removeRCP | ( | int & | index | ) |
Remove an indexed object from the table.
If this object is solely owned by this table, then it will be destroyed according to the embedded RCP destruction policy object.
Definition at line 265 of file Teuchos_SimpleObjectDB.hpp.
RCP< T > Teuchos::SimpleObjectDB< T >::getNonconstObjRCP | ( | const int | index | ) |
Get an object (nonconst persisting association).
This will throw NonconstAccessError if a const object was added with storeConstObj()
.
Definition at line 277 of file Teuchos_SimpleObjectDB.hpp.
RCP< const T > Teuchos::SimpleObjectDB< T >::getConstObjRCP | ( | const int | index | ) | const |
Get an object (const persisting association).
Definition at line 285 of file Teuchos_SimpleObjectDB.hpp.
Ptr< T > Teuchos::SimpleObjectDB< T >::getNonconstObjPtr | ( | const int | index | ) |
Get an object (nonconst semi-persisting association).
This will throw NonconstAccessError if a const object was added with storeConstObj()
.
Definition at line 293 of file Teuchos_SimpleObjectDB.hpp.
Ptr< const T > Teuchos::SimpleObjectDB< T >::getConstObjPtr | ( | const int | index | ) | const |
Get an object (const semi-persisting association).
Definition at line 301 of file Teuchos_SimpleObjectDB.hpp.
void Teuchos::SimpleObjectDB< T >::purge | ( | ) |
Clear out all storage.
Clears out the table storage and all RCPs to stored objects. Any objects solely owned by this table will be freed.
Definition at line 309 of file Teuchos_SimpleObjectDB.hpp.