1 #ifndef CORE_WeakPointersArray_H
2 #define CORE_WeakPointersArray_H
4 #include "boost/shared_ptr.hpp"
5 #include "boost/weak_ptr.hpp"
20 tFlag mCapacityFactor;
23 boost::weak_ptr<T> *mValues;
53 boost::shared_ptr<const T> v=mValues[i].lock();
56 boost::shared_ptr<const T> temp;
67 boost::shared_ptr<T> v=mValues[i].lock();
70 boost::shared_ptr<T> temp;
80 boost::shared_ptr<T> p=(*this)[i];
89 boost::shared_ptr<T> p=(*this)[i];
97 static inline boost::shared_ptr<CORE_WeakPointersArray<T> >
New() {
127 if (mCapacity>=n) mSize=n;
154 void add(boost::shared_ptr<T> obj) {
156 boost::weak_ptr<T> wobj=obj;
157 mValues[mSize-1]=wobj;
162 boost::shared_ptr<T> p;
163 obj.getSharedPointer(p);
175 if (obj.get()==
null)
return false;
176 return remove(obj.get());
200 return remove(mSize-1);
210 boost::shared_ptr<T> p;
213 boost::shared_ptr<T> obj=mValues[mSize-1].lock();
216 boost::shared_ptr<T> p;
231 boost::shared_ptr<T> obj=mValues[i].lock();
232 if (obj)
return obj.get();
244 boost::shared_ptr<T> obj=mValues[i].lock();
245 if (obj)
return obj.get();
262 if (obj.get()==
null)
return false;
263 return exist(obj.get());
const T & operator()(const tArrayIndex &i) const
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_WeakPointersArray.h:79
boost::shared_ptr< const T > operator[](const tArrayIndex &i) const
get the i-th element weak pointer ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size())); ...
Definition: CORE_WeakPointersArray.h:50
#define tArrayIndex
Definition: types.h:39
tBoolean removeAtIndex(const tArrayIndex &i)
remove the pointer at index i
Definition: CORE_WeakPointersArray.hpp:163
void resize(const tArrayIndex &cap)
resize the array
Definition: CORE_WeakPointersArray.hpp:44
void copy(const CORE_WeakPointersArray< Q > &cpy)
New copy constructor of a weak pointers list.
Definition: CORE_WeakPointersArray.hpp:33
CORE_WeakPointersArray()
internal constructor of a weak pointers array
Definition: CORE_WeakPointersArray.hpp:8
const tArrayIndex & getSize() const
return the size of the array
Definition: CORE_WeakPointersArray.h:254
void set(const tArrayIndex &i, boost::shared_ptr< T > obj)
set the pointer at the index i
Definition: CORE_WeakPointersArray.hpp:111
#define tBoolean
Definition: types.h:48
#define null
Definition: types.h:13
virtual ~CORE_WeakPointersArray()
destroy an array of T*
Definition: CORE_WeakPointersArray.hpp:23
class CORE_WeakPointersArray is an array of weak pointers
Definition: CORE_WeakPointersArray.h:12
tBoolean exists(boost::shared_ptr< T > obj) const
exists
Definition: CORE_WeakPointersArray.h:261
void setCapacityFactor(const unsigned int &cap)
set the capcity factor
Definition: CORE_WeakPointersArray.h:135
boost::shared_ptr< T > operator[](const tArrayIndex &i)
get the i-th element weak pointer ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size())); ...
Definition: CORE_WeakPointersArray.h:64
void add(T &obj)
add an element at the end
Definition: CORE_WeakPointersArray.h:161
void clear()
clear the array
Definition: CORE_WeakPointersArray.h:121
T & operator()(const int &i)
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_WeakPointersArray.h:88
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_WeakPointersArray.hpp:119
abstract base class for most classes.
Definition: CORE_Object.h:30
boost::shared_ptr< T > getLastElement()
get last element pointer
Definition: CORE_WeakPointersArray.h:208
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
static boost::shared_ptr< CORE_WeakPointersArray< T > > New()
New constructor of a weak pointers list.
Definition: CORE_WeakPointersArray.h:97
void setSize(const tArrayIndex &n)
set the size of the weak pointers list
Definition: CORE_WeakPointersArray.h:126
#define ASSERT_IN(a)
Definition: types.h:96
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14