1 #ifndef CORE_SharedPointersList_H
2 #define CORE_SharedPointersList_H
4 #include "boost/shared_ptr.hpp"
5 #include "boost/weak_ptr.hpp"
13 vector<boost::shared_ptr<T> > mVector;
59 return *mVector[i].get();
66 return *mVector[i].get();
72 static inline boost::shared_ptr<CORE_SharedPointersList<T> >
New() {
97 boost::shared_ptr<T> p;
98 obj.getSharedPointer(p);
104 boost::shared_ptr<T> p;
105 if (obj!=
null) obj->getSharedPointer(p);
118 boost::shared_ptr<T> p;
119 if (obj!=
null) obj->getSharedPointer(p);
126 boost::shared_ptr<T> p;
127 obj.getSharedPointer(p);
134 void add(boost::shared_ptr<T> obj) {
135 mVector.push_back(obj);
140 boost::shared_ptr<T> p;
141 obj.getSharedPointer(p);
142 mVector.push_back(p);
147 boost::shared_ptr<T> p;
148 if (obj!=
null) obj->getSharedPointer(p);
149 mVector.push_back(p);
157 virtual void addInList(
const boost::shared_ptr<T>& obj) {
173 return remove(obj.get());
188 if (obj==
null)
return false;
201 if (n==0)
return false;
215 if (mVector.size()==0)
return null;
216 return mVector[mVector.size()-1].get();
221 if (mVector.size()==0)
return null;
222 return mVector[mVector.size()-1].get();
228 if (i<0)
return null;
229 if (i>=mVector.size())
return null;
230 return mVector[i].get();
236 if (i<0)
return null;
237 if (i>=mVector.size())
return null;
238 return mVector[i].get();
260 if (obj==
null)
return false;
271 void getValues(vector<const T*>& vs)
const;
287 typename vector<boost::shared_ptr<T> >::const_iterator
getIterator()
const {
288 return mVector.begin();
293 return mVector.begin();
298 return mVector.end();
303 return mVector.end();
void copy(const CORE_SharedPointersList< Q > &cpy)
New copy constructor of a shared pointers list.
Definition: CORE_SharedPointersList.hpp:26
tBoolean insert(const tVectorIndex &i, T &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersList.h:125
tBoolean exists(const T *obj) const
exists
Definition: CORE_SharedPointersList.h:259
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
tBoolean set(const tVectorIndex &i, boost::shared_ptr< T > obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.hpp:97
tBoolean insert(const tVectorIndex &i, T *obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersList.h:117
void clear()
clear the array
Definition: CORE_SharedPointersList.h:206
static boost::shared_ptr< CORE_SharedPointersList< T > > New()
New constructor of a shared pointers list.
Definition: CORE_SharedPointersList.h:72
void add(T &obj)
add an element at the end
Definition: CORE_SharedPointersList.h:139
#define tVectorIndex
Definition: types.h:42
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersList.h:134
vector< boost::shared_ptr< T > >::iterator getIterator()
get iterator
Definition: CORE_SharedPointersList.h:292
T & operator()(const tVectorIndex &i)
get the i-th element
Definition: CORE_SharedPointersList.h:63
#define tBoolean
Definition: types.h:48
void add(T *obj)
add an element at the end
Definition: CORE_SharedPointersList.h:146
void merge(const CORE_SharedPointersList< Q > &array)
merge the array in this
Definition: CORE_SharedPointersList.hpp:122
virtual ~CORE_SharedPointersList()
destroy an array of T*
Definition: CORE_SharedPointersList.hpp:19
void reverse()
reverse the vector
Definition: CORE_SharedPointersList.hpp:107
#define null
Definition: types.h:13
tBoolean set(const tVectorIndex &i, T *obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.h:103
tBoolean removeAtIndex(const tVectorIndex &i)
remove the pointer at index i
Definition: CORE_SharedPointersList.hpp:66
tBoolean set(const tVectorIndex &i, T &obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.h:96
void getValues(vector< T * > &vs)
get values
Definition: CORE_SharedPointersList.hpp:137
const boost::shared_ptr< T > & operator[](const tVectorIndex &i) const
get the i-th element shared pointer ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersList.h:39
CORE_SharedPointersList()
internal constructor of a shared pointers list
Definition: CORE_SharedPointersList.hpp:7
vector< boost::shared_ptr< T > >::const_iterator getIterator() const
get iterator
Definition: CORE_SharedPointersList.h:287
virtual void addInList(const boost::shared_ptr< T > &obj)
add a core object
Definition: CORE_SharedPointersList.h:157
tBoolean insert(const tVectorIndex &i, boost::shared_ptr< T > obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersList.hpp:86
vector< boost::shared_ptr< T > >::iterator getEndIterator()
get iterator
Definition: CORE_SharedPointersList.h:302
const T * getLastElement() const
get last element pointer
Definition: CORE_SharedPointersList.h:220
abstract base class for most classes.
Definition: CORE_Object.h:30
boost::shared_ptr< T > & operator[](const tVectorIndex &i)
get the i-th element shared pointer ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersList.h:47
T * getLastElement()
get last element pointer
Definition: CORE_SharedPointersList.h:214
const T & operator()(const tVectorIndex &i) const
get the i-th element ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersList.h:55
void permute(const tVectorIndex &i, const tVectorIndex &j)
permute
Definition: CORE_SharedPointersList.hpp:75
vector< boost::shared_ptr< T > >::const_iterator getEndIterator() const
get iterator
Definition: CORE_SharedPointersList.h:297
void setSize(const tVectorIndex &n)
set the size of the shared pointers list
Definition: CORE_SharedPointersList.h:87
tBoolean exists(boost::shared_ptr< T > obj) const
exists
Definition: CORE_SharedPointersList.h:250
tVectorIndex size() const
return the size of the array
Definition: CORE_SharedPointersList.h:242
#define ASSERT_IN(a)
Definition: types.h:96
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
tVectorIndex getSize() const
return the size of the array
Definition: CORE_SharedPointersList.h:245