45 #ifndef TEUCHOS_SIMPLEOBJECTTABLE_HPP
46 #define TEUCHOS_SIMPLEOBJECTTABLE_HPP
70 int storeNew(T* obj,
bool owned =
true);
108 if (freedIndices.size() != 0) {
109 index = freedIndices.back();
110 freedIndices.pop_back();
111 tableOfObjects[index] = robj;
113 tableOfObjects.push_back(robj);
114 index = tableOfObjects.size() - 1;
123 return storeRCP(
rcp(obj, owned));
127 template <
class TOld>
130 return storeRCP(rcp_dynamic_cast<T>(robj_old,
true));
137 throw RangeError(
"Item has already been deleted from SimpleObjectTable.");
140 int cnt = tableOfObjects[index].strong_count();
143 freedIndices.push_back(index);
153 throw RangeError(
"Item has already been deleted from SimpleObjectTable.");
156 return tableOfObjects[index];
162 int ocnt = tableOfObjects.size();
163 for (
int i=0; i<ocnt; i++) {
167 if (tableOfObjects.size() > 0)
168 tableOfObjects.erase(tableOfObjects.begin(), tableOfObjects.end());
169 if (freedIndices.size() > 0)
170 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...