1 #ifndef CORE_WeakPointersArray_CPP 2 #define CORE_WeakPointersArray_CPP 39 mValues[i]=boost::dynamic_pointer_cast<T>(cpy[i]);
51 boost::weak_ptr<T> *newValues=
null;
53 newValues=
new boost::weak_ptr<T>[
mCapacity];
54 }
catch (std::exception e) {
55 cout << e.what()<<
"\n";
57 "CORE_WeakPointersArray<T>::resize(cap)",
58 "not enought memory to allocate new array");
63 const boost::weak_ptr<T> *cValues=&(*this)[0];
65 *newValues=boost::dynamic_pointer_cast<T>(*cValues);
84 boost::shared_ptr<T> *newValues=
null;
86 newValues =
new boost::weak_ptr<T>[
mCapacity];
87 }
catch (std::exception e) {
88 cout << e.what()<<
"\n";
89 throw CORE_Exception(
"common/core",
"CORE_WeakPointersArray<T>::resize(cap)",
90 "not enought memory to allocate new array");
94 const boost::weak_ptr<T> *cValues=&(*this)[0];
96 *newValues=boost::dynamic_pointer_cast<T>(*cValues);
123 boost::weak_ptr<T> *pValues=&(*this)[
mSize];
124 const boost::weak_ptr<T> *cValues=
null;
126 cValues=&(*this)[
mSize-1];
141 if (
mSize==0)
return false;
143 boost::weak_ptr<T> *pValues=&(*this)[i];
148 if ((*pValues).lock().get()==obj) {
165 if ((i<0) || (i>=
mSize))
return false;
168 boost::weak_ptr<T> *pValues=&(*this)[i];
170 const boost::weak_ptr<T> *cValues=
null;
193 if (
mSize==0)
return false;
194 const boost::weak_ptr<T> *pValues=&(*this)[0];
196 if ((*pValues).lock().get()==obj)
return true;
tBoolean remove()
remove the last pointer
Definition: CORE_WeakPointersArray.h:199
void copy(const CORE_WeakPointersArray< Q > &cpy)
New copy constructor of a weak pointers list.
Definition: CORE_WeakPointersArray.hpp:33
void insert(const tUIndex &i, boost::shared_ptr< T > obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_WeakPointersArray.hpp:119
CORE_WeakPointersArray()
internal constructor of a weak pointers array
Definition: CORE_WeakPointersArray.hpp:8
#define tBoolean
Definition: types.h:139
#define null
Definition: types.h:144
void setSize(const tUIndex &n)
set the size of the weak pointers list
Definition: CORE_WeakPointersArray.h:126
tFlag mCapacityFactor
Definition: CORE_WeakPointersArray.h:20
virtual ~CORE_WeakPointersArray()
destroy an array of T*
Definition: CORE_WeakPointersArray.hpp:23
tUIndex mCapacity
Definition: CORE_WeakPointersArray.h:18
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
class CORE_WeakPointersArray is an array of weak pointers
Definition: CORE_WeakPointersArray.h:12
#define tUIndex
Definition: types.h:126
const tUIndex & getSize() const
return the size of the array
Definition: CORE_WeakPointersArray.h:252
abstract base class for most classes.
Definition: CORE_Object.h:53
void set(const tUIndex &i, boost::shared_ptr< T > obj)
set the pointer at the index i
Definition: CORE_WeakPointersArray.hpp:111
boost::weak_ptr< T > * mValues
Definition: CORE_WeakPointersArray.h:23
tBoolean removeAtIndex(const tUIndex &i)
remove the pointer at index i
Definition: CORE_WeakPointersArray.hpp:163
void fit()
fit the capacity to size
Definition: CORE_WeakPointersArray.hpp:78
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_WeakPointersArray.h:154
tBoolean exists(boost::shared_ptr< T > obj) const
exists
Definition: CORE_WeakPointersArray.h:259
void resize(const tUIndex &cap)
resize the array
Definition: CORE_WeakPointersArray.hpp:44
tUIndex mSize
Definition: CORE_WeakPointersArray.h:16