1 #ifndef CORE_WeakPointersArray_H 2 #define CORE_WeakPointersArray_H 4 #include "boost/shared_ptr.hpp" 5 #include "boost/weak_ptr.hpp" 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;
141 void set(
const tUIndex& i,boost::shared_ptr<T> obj);
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;
230 boost::shared_ptr<T> obj=mValues[i].lock();
231 if (obj)
return obj.get();
242 boost::shared_ptr<T> obj=mValues[i].lock();
243 if (obj)
return obj.get();
260 if (obj.get()==
null)
return false;
261 return exist(obj.get());
boost::shared_ptr< T > operator[](const tUIndex &i)
get the i-th element weak pointer ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size())); ...
Definition: CORE_WeakPointersArray.h:64
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
boost::shared_ptr< const T > operator[](const tUIndex &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 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
class CORE_WeakPointersArray is an array of weak pointers
Definition: CORE_WeakPointersArray.h:12
void setCapacityFactor(const unsigned int &cap)
set the capcity factor
Definition: CORE_WeakPointersArray.h:135
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
#define tUIndex
Definition: types.h:126
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
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
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
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
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
const T & operator()(const tUIndex &i) const
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_WeakPointersArray.h:79
#define ASSERT_IN(a)
Definition: types.h:196
tUIndex mSize
Definition: CORE_WeakPointersArray.h:16
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74