Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Teuchos::SimpleObjectDB< T > Class Template Reference

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_
 

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.

Member Typedef Documentation

template<class T >
typedef Array<ConstNonconstObjectContainer<T> > Teuchos::SimpleObjectDB< T >::tableOfObjects_t
private

Definition at line 191 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
typedef Array<int> Teuchos::SimpleObjectDB< T >::freedIndices_t
private

Definition at line 192 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.

template<class T >
void Teuchos::SimpleObjectDB< T >::validateIndex ( const int  index) const
private

Definition at line 353 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
template<class T2 >
int Teuchos::SimpleObjectDB< T >::storeObjectImpl ( const RCP< T2 > &  robj)
private

Definition at line 370 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
void Teuchos::SimpleObjectDB< T >::removeObjImpl ( const int  index)
private

Definition at line 390 of file Teuchos_SimpleObjectDB.hpp.

Member Data Documentation

template<class T >
tableOfObjects_t Teuchos::SimpleObjectDB< T >::tableOfObjects_
private

Definition at line 194 of file Teuchos_SimpleObjectDB.hpp.

template<class T >
freedIndices_t Teuchos::SimpleObjectDB< T >::freedIndices_
private

Definition at line 195 of file Teuchos_SimpleObjectDB.hpp.


The documentation for this class was generated from the following file: