1 #ifndef CORE_SharedPointersList_H 2 #define CORE_SharedPointersList_H 4 #include "boost/shared_ptr.hpp" 5 #include "boost/weak_ptr.hpp" 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;
207 if (mVector.size()==0)
return false;
208 mVector.erase(mVector.begin());
214 if (mVector.size()==0)
return false;
215 mVector.erase(mVector.begin()+
size()-1);
230 if (mVector.size()==0)
return null;
231 return mVector[mVector.size()-1].get();
236 if (mVector.size()==0)
return null;
237 return mVector[mVector.size()-1].get();
243 if (i>=mVector.size())
return null;
244 return mVector[i].get();
250 if (i>=mVector.size())
return null;
251 return mVector[i].get();
273 if (obj==
null)
return false;
284 void getValues(vector<const T*>& vs)
const;
300 inline typename vector<boost::shared_ptr<T> >::const_iterator
begin()
const {
301 return mVector.begin();
305 inline typename vector<boost::shared_ptr<T> >::iterator
begin() {
306 return mVector.begin();
311 inline typename vector<boost::shared_ptr<T> >::const_iterator
end()
const {
312 return mVector.end();
316 inline typename vector<boost::shared_ptr<T> >::iterator
end() {
317 return mVector.end();
void copy(const CORE_SharedPointersList< Q > &cpy)
New copy constructor of a shared pointers list.
Definition: CORE_SharedPointersList.hpp:26
tUIndex getSize() const
return the size of the array
Definition: CORE_SharedPointersList.h:258
vector< boost::shared_ptr< T > > mVector
Definition: CORE_SharedPointersList.h:13
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
tBoolean insert(const tUIndex &i, T &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersList.h:125
void clear()
clear the array
Definition: CORE_SharedPointersList.h:221
const T * getLastElement() const
get last element pointer
Definition: CORE_SharedPointersList.h:235
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
tBoolean removeAtIndex(const tUIndex &i)
remove the pointer at index i
Definition: CORE_SharedPointersList.hpp:66
vector< boost::shared_ptr< T > >::const_iterator end() const
get iterator
Definition: CORE_SharedPointersList.h:311
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersList.h:134
tBoolean 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_SharedPointersList.hpp:84
vector< boost::shared_ptr< T > >::iterator end()
get iterator
Definition: CORE_SharedPointersList.h:316
tBoolean exists(const T *obj) const
exists
Definition: CORE_SharedPointersList.h:272
#define tBoolean
Definition: types.h:139
void add(T *obj)
add an element at the end
Definition: CORE_SharedPointersList.h:146
tBoolean removeLast()
remove the first pointer
Definition: CORE_SharedPointersList.h:213
void merge(const CORE_SharedPointersList< Q > &array)
merge the array in this
Definition: CORE_SharedPointersList.hpp:118
virtual ~CORE_SharedPointersList()
destroy an array of T*
Definition: CORE_SharedPointersList.hpp:19
vector< boost::shared_ptr< T > >::const_iterator begin() const
get iterator
Definition: CORE_SharedPointersList.h:300
void reverse()
reverse the vector
Definition: CORE_SharedPointersList.hpp:105
#define null
Definition: types.h:144
void permute(const tUIndex &i, const tUIndex &j)
permute
Definition: CORE_SharedPointersList.hpp:76
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_SharedPointersList.h:39
T & operator()(const tUIndex &i)
get the i-th element
Definition: CORE_SharedPointersList.h:63
CORE_SharedPointersList()
internal constructor of a shared pointers list
Definition: CORE_SharedPointersList.hpp:7
virtual void addInList(const boost::shared_ptr< T > &obj)
add a core object
Definition: CORE_SharedPointersList.h:157
void getValues(vector< T *> &vs)
get values
Definition: CORE_SharedPointersList.hpp:133
tBoolean insert(const tUIndex &i, T *obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_SharedPointersList.h:117
#define tUIndex
Definition: types.h:126
tBoolean exists(boost::shared_ptr< T > obj) const
exists
Definition: CORE_SharedPointersList.h:263
boost::shared_ptr< T > & operator[](const tUIndex &i)
get the i-th element shared pointer ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersList.h:47
abstract base class for most classes.
Definition: CORE_Object.h:53
T * getLastElement()
get last element pointer
Definition: CORE_SharedPointersList.h:229
tUIndex size() const
return the size of the array
Definition: CORE_SharedPointersList.h:255
const T & operator()(const tUIndex &i) const
get the i-th element ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_SharedPointersList.h:55
void setSize(const tUIndex &n)
set the size of the shared pointers list
Definition: CORE_SharedPointersList.h:87
#define ASSERT_IN(a)
Definition: types.h:196
vector< boost::shared_ptr< T > >::iterator begin()
get iterator
Definition: CORE_SharedPointersList.h:305
tBoolean removeFirst()
remove the first pointer
Definition: CORE_SharedPointersList.h:206
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141