1 #ifndef CORE_SharedPointersArray_CPP
2 #define CORE_SharedPointersArray_CPP
12 mValues=
new boost::shared_ptr<T>[mCapacity];
27 if (mValues!=
null)
delete[] mValues;
37 boost::shared_ptr<T> *pValues=mValues;
38 const boost::shared_ptr<T> *cValues=&cpy[0];
40 *pValues=boost::dynamic_pointer_cast<T>(*cValues);
49 if (cap<mCapacity)
return;
51 if (mCapacityFactor<=1) mCapacity=cap+1;
52 else while (mCapacity<=cap) mCapacity*=mCapacityFactor;
54 boost::shared_ptr<T> *newValues=
null;
56 newValues=
new boost::shared_ptr<T>[mCapacity];
57 }
catch (std::exception e) {
58 cout << e.what()<<
"\n";
60 "CORE_SharedPointersArray<T>::resize(cap)",
61 "not enought memory to allocate new array");
66 const boost::shared_ptr<T> *cValues=&(*this)[0];
68 *newValues=boost::dynamic_pointer_cast<T>(*cValues);
74 if (mValues!=
null)
delete[] mValues;
83 if (mSize+1==mCapacity)
return;
87 boost::shared_ptr<T> *newValues=
null;
89 newValues =
new boost::shared_ptr<T>[mCapacity];
90 }
catch (std::exception e) {
91 cout << e.what()<<
"\n";
92 throw CORE_Exception(
"common/core",
"CORE_SharedPointersArray<T>::resize(cap)",
93 "not enought memory to allocate new array");
97 const boost::shared_ptr<T> *cValues=&(*this)[0];
99 *newValues=boost::dynamic_pointer_cast<T>(*cValues);
105 if (mValues!=
null)
delete[] mValues;
123 if (index>=mSize) add(obj);
126 boost::shared_ptr<T> *pValues=&(*this)[mSize];
127 const boost::shared_ptr<T> *cValues=
null;
129 cValues=&(*this)[mSize-1];
144 if (mSize==0)
return false;
146 boost::shared_ptr<T> *pValues=&(*this)[i];
147 if ((*pValues).get()==obj) removeAtIndex(i);
151 if ((*pValues).get()==obj) {
168 if ((i<0) || (i>=mSize))
return false;
171 boost::shared_ptr<T> *pValues=&(*this)[i];
173 const boost::shared_ptr<T> *cValues=
null;
197 if (mSize==0)
return false;
198 const boost::shared_ptr<T> *pValues=&(*this)[0];
200 if ((*pValues).get()==obj)
return true;
void resize(const tArrayIndex &cap)
resize the array
Definition: CORE_SharedPointersArray.hpp:47
void copy(const CORE_SharedPointersArray< Q > &cpy)
New copy constructor of a shared pointers list.
Definition: CORE_SharedPointersArray.hpp:33
tBoolean exists(const T &obj) const
exists
Definition: CORE_SharedPointersArray.hpp:192
#define tArrayIndex
Definition: types.h:39
void insert(const tArrayIndex &i, boost::shared_ptr< T > obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersArray.hpp:122
tBoolean remove()
remove the last pointer
Definition: CORE_SharedPointersArray.h:225
#define tBoolean
Definition: types.h:48
#define null
Definition: types.h:13
virtual ~CORE_SharedPointersArray()
destroy an array of T*
Definition: CORE_SharedPointersArray.hpp:23
CORE_SharedPointersArray()
internal constructor of a shared pointers list
Definition: CORE_SharedPointersArray.hpp:8
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
void fit()
fit the capacity to size
Definition: CORE_SharedPointersArray.hpp:81
void set(const tArrayIndex &i, boost::shared_ptr< T > obj)
set the pointer at the index i
Definition: CORE_SharedPointersArray.hpp:114
tBoolean removeAtIndex(const tArrayIndex &i)
remove the pointer at index i
Definition: CORE_SharedPointersArray.hpp:166
abstract base class for most classes.
Definition: CORE_Object.h:30
class CORE_SharedPointersArray is a list of shared pointers
Definition: CORE_SharedPointersArray.h:12
const tArrayIndex & getSize() const
return the size of the array
Definition: CORE_SharedPointersArray.h:262