1 #ifndef CORE_SharedPointersArray_H
2 #define CORE_SharedPointersArray_H
4 #include "boost/shared_ptr.hpp"
5 #include "boost/weak_ptr.hpp"
22 tFlag mCapacityFactor;
25 boost::shared_ptr<T> *mValues;
74 return *(mValues[i].get());
84 return *(mValues[i].get());
90 static inline boost::shared_ptr<CORE_SharedPointersArray<T> >
New() {
120 if (mCapacity>=n) mSize=n;
138 boost::shared_ptr<T> p;
139 obj.getSharedPointer(p);
145 boost::shared_ptr<T> p;
146 if (obj!=
null) obj->getSharedPointer(p);
159 boost::shared_ptr<T> p;
160 if (obj!=
null) obj->getSharedPointer(p);
167 boost::shared_ptr<T> p;
168 obj.getSharedPointer(p);
175 void add(boost::shared_ptr<T> obj) {
177 mValues[mSize-1]=obj;
182 boost::shared_ptr<T> p;
183 obj.getSharedPointer(p);
189 boost::shared_ptr<T> p;
190 if (obj!=
null) obj->getSharedPointer(p);
201 if (obj.get()==
null)
return false;
202 return remove(obj.get());
226 return remove(mSize-1);
235 return (mSize==0)?
null:mValues[mSize-1].get();
240 return (mSize==0)?
null:mValues[mSize-1].get();
248 return ( (i<0) || (i>=mSize) ) ?
null:mValues[i].get();
256 return ((i<0) || (i>=mSize)) ?
null:mValues[i].get();
static boost::shared_ptr< CORE_SharedPointersArray< T > > New()
New constructor of a shared pointers list.
Definition: CORE_SharedPointersArray.h:90
void resize(const tArrayIndex &cap)
resize the array
Definition: CORE_SharedPointersArray.hpp:47
void set(const tArrayIndex &i, T &obj)
set the pointer at the index i
Definition: CORE_SharedPointersArray.h:137
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
void add(T &obj)
add an element at the end
Definition: CORE_SharedPointersArray.h:181
#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
void add(T *obj)
add an element at the end
Definition: CORE_SharedPointersArray.h:188
T * getLastElement()
get last element pointer
Definition: CORE_SharedPointersArray.h:234
#define tBoolean
Definition: types.h:48
T & operator()(const int &i)
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersArray.h:80
const T & operator()(const tArrayIndex &i) const
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersArray.h:70
#define null
Definition: types.h:13
void insert(const tArrayIndex &i, T &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersArray.h:166
virtual ~CORE_SharedPointersArray()
destroy an array of T*
Definition: CORE_SharedPointersArray.hpp:23
void clear()
clear the array
Definition: CORE_SharedPointersArray.h:114
CORE_SharedPointersArray()
internal constructor of a shared pointers list
Definition: CORE_SharedPointersArray.hpp:8
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
const T * getLastElement() const
get last element pointer
Definition: CORE_SharedPointersArray.h:239
void setSize(const tArrayIndex &n)
set the size of the shared pointers list
Definition: CORE_SharedPointersArray.h:119
const boost::shared_ptr< T > & operator[](const tArrayIndex &i) const
get the i-th element shared pointer ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size())); ...
Definition: CORE_SharedPointersArray.h:52
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
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersArray.h:175
void insert(const tArrayIndex &i, T *obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersArray.h:158
void setCapacityFactor(const tFlag &cap)
set the capcity factor
Definition: CORE_SharedPointersArray.h:128
boost::shared_ptr< T > & operator[](const tArrayIndex &i)
get the i-th element shared pointer ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size())); ...
Definition: CORE_SharedPointersArray.h:61
void set(const tArrayIndex &i, T *obj)
set the pointer at the index i
Definition: CORE_SharedPointersArray.h:144
class CORE_SharedPointersArray is a list of shared pointers
Definition: CORE_SharedPointersArray.h:12
#define ASSERT_IN(a)
Definition: types.h:96
const tArrayIndex & getSize() const
return the size of the array
Definition: CORE_SharedPointersArray.h:262
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14