1 #ifndef CORE_SharedPointersArray_H 2 #define CORE_SharedPointersArray_H 4 #include "boost/shared_ptr.hpp" 5 #include "boost/weak_ptr.hpp" 68 return *(mValues[i].get());
76 return *(mValues[i].get());
82 static inline boost::shared_ptr<CORE_SharedPointersArray<T> >
New() {
112 if (mCapacity>=n) mSize=n;
126 void set(
const tUIndex& i,boost::shared_ptr<T> obj);
130 boost::shared_ptr<T> p;
131 obj.getSharedPointer(p);
137 boost::shared_ptr<T> p;
138 if (obj!=
null) obj->getSharedPointer(p);
151 boost::shared_ptr<T> p;
152 if (obj!=
null) obj->getSharedPointer(p);
159 boost::shared_ptr<T> p;
160 obj.getSharedPointer(p);
167 void add(boost::shared_ptr<T> obj) {
169 mValues[mSize-1]=obj;
174 boost::shared_ptr<T> p;
175 obj.getSharedPointer(p);
181 boost::shared_ptr<T> p;
182 if (obj!=
null) obj->getSharedPointer(p);
193 if (obj.get()==
null)
return false;
194 return remove(obj.get());
218 if (mSize==0)
return false;
219 return remove(mSize-1);
228 return (mSize==0)?
null:mValues[mSize-1].get();
233 return (mSize==0)?
null:mValues[mSize-1].get();
241 return (i>=mSize) ?
null:mValues[i].get();
248 return (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:82
const boost::shared_ptr< T > & operator[](const tUIndex &i) const
get the i-th element shared pointer ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersArray.h:51
void copy(const CORE_SharedPointersArray< Q > &cpy)
New copy constructor of a shared pointers list.
Definition: CORE_SharedPointersArray.hpp:33
void add(T &obj)
add an element at the end
Definition: CORE_SharedPointersArray.h:173
tBoolean removeAtIndex(const tUIndex &i)
remove the pointer at index i
Definition: CORE_SharedPointersArray.hpp:166
const T * getLastElement() const
get last element pointer
Definition: CORE_SharedPointersArray.h:232
tUIndex mSize
Definition: CORE_SharedPointersArray.h:16
void resize(const tUIndex &cap)
resize the array
Definition: CORE_SharedPointersArray.hpp:47
void add(T *obj)
add an element at the end
Definition: CORE_SharedPointersArray.h:180
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_SharedPointersArray.hpp:122
T * getLastElement()
get last element pointer
Definition: CORE_SharedPointersArray.h:227
void insert(const tUIndex &i, T *obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersArray.h:150
#define tBoolean
Definition: types.h:139
boost::shared_ptr< T > * mValues
Definition: CORE_SharedPointersArray.h:25
tFlag mCapacityFactor
Definition: CORE_SharedPointersArray.h:22
const tUIndex & getSize() const
return the size of the array
Definition: CORE_SharedPointersArray.h:254
#define null
Definition: types.h:144
virtual ~CORE_SharedPointersArray()
destroy an array of T*
Definition: CORE_SharedPointersArray.hpp:23
boost::shared_ptr< T > & operator[](const tUIndex &i)
get the i-th element shared pointer ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersArray.h:58
void insert(const tUIndex &i, T &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersArray.h:158
T & operator()(const tUIndex &i)
get the i-th element ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersArray.h:73
void clear()
clear the array
Definition: CORE_SharedPointersArray.h:106
CORE_SharedPointersArray()
internal constructor of a shared pointers list
Definition: CORE_SharedPointersArray.hpp:8
tUIndex mCapacity
Definition: CORE_SharedPointersArray.h:19
void fit()
fit the capacity to size
Definition: CORE_SharedPointersArray.hpp:81
const T & operator()(const tUIndex &i) const
get the i-th element ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersArray.h:65
#define tUIndex
Definition: types.h:126
abstract base class for most classes.
Definition: CORE_Object.h:53
void setSize(const tUIndex &n)
set the size of the shared pointers list
Definition: CORE_SharedPointersArray.h:111
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersArray.h:167
void setCapacityFactor(const tFlag &cap)
set the capcity factor
Definition: CORE_SharedPointersArray.h:120
tBoolean exists(const T &obj) const
exists
Definition: CORE_SharedPointersArray.hpp:192
class CORE_SharedPointersArray is a list of shared pointers
Definition: CORE_SharedPointersArray.h:12
#define ASSERT_IN(a)
Definition: types.h:196
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74