Teuchos Package Browser (Single Doxygen Collection)
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... | |
Private Types | |
typedef Array < ConstNonconstObjectContainer < T > > | tableOfObjects_t |
typedef Array< int > | freedIndices_t |
Private Member Functions | |
void | validateIndex (const int index) const |
template<class T2 > | |
int | storeObjectImpl (const RCP< T2 > &robj) |
void | removeObjImpl (const int index) |
Private Attributes | |
tableOfObjects_t | tableOfObjects_ |
freedIndices_t | freedIndices_ |
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 86 of file Teuchos_SimpleObjectDB.hpp.
|
private |
Definition at line 191 of file Teuchos_SimpleObjectDB.hpp.
|
private |
Definition at line 192 of file Teuchos_SimpleObjectDB.hpp.
Teuchos::SimpleObjectDB< T >::SimpleObjectDB | ( | ) |
Construct an empty DB.
Definition at line 221 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 226 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 233 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::numObjects | ( | ) | const |
Return number of non-null stored objects.
Definition at line 240 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::storeNonconstObj | ( | const RCP< T > & | obj | ) |
Store a non-const object.
Definition at line 247 of file Teuchos_SimpleObjectDB.hpp.
int Teuchos::SimpleObjectDB< T >::storeConstObj | ( | const RCP< const T > & | obj | ) |
Store a const object.
Definition at line 254 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 262 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 269 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 277 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 287 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 297 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 309 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 317 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 325 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 333 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 341 of file Teuchos_SimpleObjectDB.hpp.
|
private |
Definition at line 353 of file Teuchos_SimpleObjectDB.hpp.
|
private |
Definition at line 370 of file Teuchos_SimpleObjectDB.hpp.
|
private |
Definition at line 390 of file Teuchos_SimpleObjectDB.hpp.
|
private |
Definition at line 194 of file Teuchos_SimpleObjectDB.hpp.
|
private |
Definition at line 195 of file Teuchos_SimpleObjectDB.hpp.