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;
41 inline const boost::shared_ptr<T>&
operator[](
const int & i)
const {
44 return mVector[(int)i];
53 return mVector[(int)i];
63 return *mVector[(int)i].
get();
73 return *mVector[(int)i].
get();
79 static inline boost::shared_ptr<CORE_SharedPointersList<T> >
New() {
100 tBoolean set(
const int& i,
const boost::shared_ptr<T>& obj);
104 boost::shared_ptr<T> p;
105 obj.getSharedPointer(p);
111 boost::shared_ptr<T> p;
112 if (obj!=
null) obj->getSharedPointer(p);
125 boost::shared_ptr<T> p;
126 if (obj!=
null) obj->getSharedPointer(p);
133 boost::shared_ptr<T> p;
134 obj.getSharedPointer(p);
141 void add(boost::shared_ptr<T> obj) {
142 mVector.push_back(obj);
147 boost::shared_ptr<T> p;
148 obj.getSharedPointer(p);
149 mVector.push_back(p);
154 boost::shared_ptr<T> p;
155 if (obj!=
null) obj->getSharedPointer(p);
156 mVector.push_back(p);
164 virtual void addInList(
const boost::shared_ptr<T>& obj) {
179 tBoolean remove(
const boost::shared_ptr<T>& obj);
202 return remove(
size()-1);
216 if (mVector.size()==0)
return null;
217 return mVector[mVector.size()-1].get();
222 if (mVector.size()==0)
return null;
223 return mVector[mVector.size()-1].get();
230 inline const T*
get(
const int& i)
const {
231 if (i<0)
return null;
232 if (i>=((
int)mVector.size()))
return null;
233 return mVector[i].get();
240 inline T*
get(
const int& i) {
241 if (i<0)
return null;
242 if (i>=((
int)mVector.size()))
return null;
243 return mVector[i].get();
247 inline int size()
const {
return mVector.size();};
250 inline int getSize()
const {
return mVector.size();};
271 void getValues(vector<const T*>& vs)
const;
279 void permute(
const int& i,
const int&j);
295 return ((
int)mIterator<(
int)mVector.size());
299 inline boost::shared_ptr<T>
next() {
300 boost::shared_ptr<T> ret=mVector[mIterator];
void copy(const CORE_SharedPointersList< Q > &cpy)
New copy constructor of a shared pointers list.
Definition: CORE_SharedPointersList.hpp:26
boost::shared_ptr< T > & operator[](const int &i)
get the i-th element shared pointer ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size())); ...
Definition: CORE_SharedPointersList.h:50
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
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:79
void add(T &obj)
add an element at the end
Definition: CORE_SharedPointersList.h:146
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersList.h:141
tBoolean insert(const int &i, T *obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersList.h:124
tBoolean hasNext() const
return true if the array has next element
Definition: CORE_SharedPointersList.h:294
#define tBoolean
Definition: types.h:35
tBoolean insert(const int &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:114
void add(T *obj)
add an element at the end
Definition: CORE_SharedPointersList.h:153
void merge(const CORE_SharedPointersList< Q > &array)
merge the array in this
Definition: CORE_SharedPointersList.hpp:150
virtual ~CORE_SharedPointersList()
destroy an array of T*
Definition: CORE_SharedPointersList.hpp:19
void setSize(const int &n)
set the size of the shared pointers list
Definition: CORE_SharedPointersList.h:94
void reverse()
reverse the vector
Definition: CORE_SharedPointersList.hpp:137
#define null
Definition: types.h:13
void begin()
put the iterator on begin
Definition: CORE_SharedPointersList.h:288
void getValues(vector< T * > &vs)
get values
Definition: CORE_SharedPointersList.hpp:160
void permute(const int &i, const int &j)
permute
Definition: CORE_SharedPointersList.hpp:106
tBoolean set(const int &i, T *obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.h:110
CORE_SharedPointersList()
internal constructor of a shared pointers list
Definition: CORE_SharedPointersList.hpp:7
tBoolean removeAtIndex(const int &i)
remove the pointer at index i
Definition: CORE_SharedPointersList.hpp:97
virtual void addInList(const boost::shared_ptr< T > &obj)
add a core object
Definition: CORE_SharedPointersList.h:164
const T & operator()(const int &i) const
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersList.h:59
int getSize() const
return the size of the array
Definition: CORE_SharedPointersList.h:250
const T * getLastElement() const
get last element pointer
Definition: CORE_SharedPointersList.h:221
T & operator()(const int &i)
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersList.h:69
int size() const
return the size of the array
Definition: CORE_SharedPointersList.h:247
abstract base class for most classes.
Definition: CORE_Object.h:30
T * getLastElement()
get last element pointer
Definition: CORE_SharedPointersList.h:215
tBoolean insert(const int &i, T &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersList.h:132
tBoolean set(const int &i, T &obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.h:103
boost::shared_ptr< T > next()
return the next element
Definition: CORE_SharedPointersList.h:299
const boost::shared_ptr< T > & operator[](const int &i) const
get the i-th element shared pointer ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size())); ...
Definition: CORE_SharedPointersList.h:41
tBoolean set(const int &i, const boost::shared_ptr< T > &obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.hpp:127
#define ASSERT_IN(a)
Definition: types.h:82
tBoolean exists(const boost::shared_ptr< T > &obj) const
exists
Definition: CORE_SharedPointersList.hpp:33
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106