Teuchos - Trilinos Tools Package Version of the Day
Public Member Functions
Teuchos::SimpleObjectDB< T > Class Template Reference

Simple object object database. More...

#include <Teuchos_SimpleObjectDB.hpp>

List of all members.

Public Member Functions

 SimpleObjectDB ()
 Construct an empty DB.
int tableSize () const
 Return the current size of the table.
int numFreeIndexes () const
 Return number of free indexes.
int numObjects () const
 Return number of non-null stored objects.
int storeNonconstObj (const RCP< T > &obj)
 Store a non-const object.
int storeConstObj (const RCP< const T > &obj)
 Store a const object.
template<class TOld >
int storeCastedNonconstObj (const RCP< TOld > &robj_old)
 Performs an rcp_dynamic_cast<>() to store the obejct.
void removeObj (const int index)
 Remove a stored object without returning it.
RCP< T > removeNonconstObj (const int index)
RCP< const T > removeConstObj (const int index)
int removeRCP (int &index)
 Remove an indexed object from the table.
RCP< T > getNonconstObjRCP (const int index)
 Get an object (nonconst persisting association).
RCP< const T > getConstObjRCP (const int index) const
 Get an object (const persisting association).
Ptr< T > getNonconstObjPtr (const int index)
 Get an object (nonconst semi-persisting association).
Ptr< const T > getConstObjPtr (const int index) const
 Get an object (const semi-persisting association).
void purge ()
 Clear out all storage.

Detailed Description

template<class T>
class Teuchos::SimpleObjectDB< T >

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:

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.


Constructor & Destructor Documentation

template<class T >
Teuchos::SimpleObjectDB< T >::SimpleObjectDB ( )

Construct an empty DB.

Definition at line 221 of file Teuchos_SimpleObjectDB.hpp.


Member Function Documentation

template<class T >
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.

template<class T >
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.

template<class T >
int Teuchos::SimpleObjectDB< T >::numObjects ( ) const

Return number of non-null stored objects.

Definition at line 240 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
int Teuchos::SimpleObjectDB< T >::storeNonconstObj ( const RCP< T > &  obj)

Store a non-const object.

Returns:
Index to the object.

Definition at line 247 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
int Teuchos::SimpleObjectDB< T >::storeConstObj ( const RCP< const T > &  obj)

Store a const object.

Returns:
Index to the object.

Definition at line 254 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
template<class TOld >
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.

Returns:
Index to the object.

Definition at line 262 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
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.

template<class T >
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.

template<class T >
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.

template<class T >
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.

Returns:
The reference count of the object after it removed from the table. If this count is 0, then the object was freed as a side-effect.

Definition at line 297 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
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.

template<class T >
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.

template<class T >
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.

template<class T >
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.

template<class T >
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.


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