13 #ifndef TEUCHOS_SIMPLEOBJECTTABLE_HPP
14 #define TEUCHOS_SIMPLEOBJECTTABLE_HPP
38 int storeNew(T* obj,
bool owned =
true);
76 if (freedIndices.size() != 0) {
77 index = freedIndices.back();
78 freedIndices.pop_back();
79 tableOfObjects[index] = robj;
81 tableOfObjects.push_back(robj);
82 index = tableOfObjects.size() - 1;
91 return storeRCP(
rcp(obj, owned));
98 return storeRCP(rcp_dynamic_cast<T>(robj_old,
true));
105 throw RangeError(
"Item has already been deleted from SimpleObjectTable.");
108 int cnt = tableOfObjects[index].strong_count();
111 freedIndices.push_back(index);
121 throw RangeError(
"Item has already been deleted from SimpleObjectTable.");
124 return tableOfObjects[index];
130 int ocnt = tableOfObjects.size();
131 for (
int i=0; i<ocnt; i++) {
135 if (tableOfObjects.size() > 0)
136 tableOfObjects.erase(tableOfObjects.begin(), tableOfObjects.end());
137 if (freedIndices.size() > 0)
138 freedIndices.erase(freedIndices.begin(), freedIndices.end());
Array< int > freedIndices
This class provides a central place to store objects.
const RCP< T > getRCP(int index)
int storeNew(T *obj, bool owned=true)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
int storeCastedRCP(const RCP< TOld > &robj_old)
int storeRCP(const RCP< T > &robj)
const RCP< T > & assert_not_null() const
Throws NullReferenceError if this->get()==NULL, otherwise returns reference to *this.
Templated array class derived from the STL std::vector.
int removeRCP(int &index)
Smart reference counting pointer class for automatic garbage collection.
Array< RCP< T > > tableOfObjects
Range error exception class.
Reference-counted pointer class and non-member templated function implementations.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...