45#ifndef TEUCHOS_SIMPLEOBJECTTABLE_HPP
46#define TEUCHOS_SIMPLEOBJECTTABLE_HPP
70 int storeNew(
T* obj,
bool owned =
true);
75 int removeRCP(
int &index);
77 const RCP<T> getRCP(
int index);
96SimpleObjectTable<T>::~SimpleObjectTable()
102int SimpleObjectTable<T>::storeRCP(
const RCP<T> & robj)
104 robj.assert_not_null();
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;
121int SimpleObjectTable<T>::storeNew(T* obj,
bool owned)
128int SimpleObjectTable<T>::storeCastedRCP(
const RCP<TOld> & robj_old)
134int SimpleObjectTable<T>::removeRCP(
int &index)
136 if (tableOfObjects[index] == Teuchos::null) {
137 throw RangeError(
"Item has already been deleted from SimpleObjectTable.");
140 int cnt = tableOfObjects[index].strong_count();
142 tableOfObjects[index] = Teuchos::null;
143 freedIndices.push_back(index);
150const RCP<T> SimpleObjectTable<T>::getRCP(
int index)
152 if (tableOfObjects[index] == Teuchos::null) {
153 throw RangeError(
"Item has already been deleted from SimpleObjectTable.");
156 return tableOfObjects[index];
160void SimpleObjectTable<T>::purge()
162 int ocnt = tableOfObjects.size();
164 tableOfObjects[
i] = Teuchos::null;
167 if (tableOfObjects.size() > 0)
168 tableOfObjects.erase(tableOfObjects.begin(), tableOfObjects.end());
169 if (freedIndices.size() > 0)
170 freedIndices.erase(freedIndices.begin(), freedIndices.end());
Templated array class derived from the STL std::vector.
Reference-counted pointer class and non-member templated function implementations.
Smart reference counting pointer class for automatic garbage collection.
RCP(ENull null_arg=null)
Initialize RCP<T> to NULL.
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object.
This class provides a central place to store objects.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...