1 #ifndef CORE_WeakPointersList_H
2 #define CORE_WeakPointersList_H
4 #include "boost/shared_ptr.hpp"
5 #include "boost/weak_ptr.hpp"
16 vector<boost::weak_ptr<T> > mVector;
46 inline boost::shared_ptr<const T>
operator[](
int i)
const {
49 boost::shared_ptr<const T> v=mVector[(int)i].lock();
52 boost::shared_ptr<const T> temp;
61 boost::shared_ptr<T> v=mVector[(int)i].lock();
64 boost::shared_ptr<T> temp;
71 static inline boost::shared_ptr<CORE_WeakPointersList<T> >
New() {
97 tBoolean set(
int i,
const boost::shared_ptr<T>& obj);
107 void add(
const boost::shared_ptr<T>& obj) {
108 boost::weak_ptr<T> wobj=obj;
109 mVector.push_back(wobj);
114 boost::shared_ptr<T> p;
115 obj.getSharedPointer(p);
122 virtual void addInList(
const boost::shared_ptr<T>& obj) {
137 tBoolean remove(
const boost::shared_ptr<T>& obj);
160 return remove(
size()-1);
175 boost::shared_ptr<T> obj=mVector[mVector.size()-1].lock();
178 boost::shared_ptr<T> p;
187 inline const T*
get(
int i)
const {
190 boost::shared_ptr<T> obj=mVector[i].lock();
191 if (obj)
return obj.get();
201 inline T*
get(
int i) {
204 boost::shared_ptr<T> obj=mVector[i].lock();
205 if (obj)
return obj.get();
212 inline int size()
const {
return mVector.size();};
215 inline int getSize()
const {
return mVector.size();};
235 for (
int i=0;i<n;i++) {
246 void permute(
const int& i,
const int&j);
262 return (mIterator<mVector.size());
266 inline boost::shared_ptr<T>
next() {
267 boost::shared_ptr<T> ret=mVector[mIterator].lock();
271 boost::shared_ptr<T> p;
int getSize() const
return the size of the array
Definition: CORE_WeakPointersList.h:215
boost::shared_ptr< const T > operator[](int i) const
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_WeakPointersList.h:46
boost::shared_ptr< T > getLastElement()
get last element pointer
Definition: CORE_WeakPointersList.h:173
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
void begin()
put the iterator on begin
Definition: CORE_WeakPointersList.h:255
tBoolean insert(int i, const boost::shared_ptr< T > &obj)
insert the pointer at index i the old element i become the element i+1
Definition: CORE_WeakPointersList.hpp:129
CORE_SharedPointersList< T > toSharedVector()
to shared vector
Definition: CORE_WeakPointersList.h:232
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersList.h:141
boost::shared_ptr< T > operator[](int i)
return the shared pointer at index i
Definition: CORE_WeakPointersList.h:58
#define tBoolean
Definition: types.h:35
boost::shared_ptr< T > next()
return the next element
Definition: CORE_WeakPointersList.h:266
CORE_WeakPointersList()
internal constructor
Definition: CORE_WeakPointersList.hpp:7
tBoolean exists(const boost::shared_ptr< T > &obj) const
exists
Definition: CORE_WeakPointersList.hpp:40
void permute(const int &i, const int &j)
permute
Definition: CORE_WeakPointersList.hpp:121
tBoolean hasNext() const
return true if the array has next element
Definition: CORE_WeakPointersList.h:261
tBoolean set(int i, const boost::shared_ptr< T > &obj)
set the pointer at the index i
Definition: CORE_WeakPointersList.hpp:143
#define null
Definition: types.h:13
virtual ~CORE_WeakPointersList()
destroy an array of T*
Definition: CORE_WeakPointersList.hpp:19
void add(const boost::shared_ptr< T > &obj)
add an element at the end
Definition: CORE_WeakPointersList.h:107
void setSize(const int &n)
set the size of the weak pointer list
Definition: CORE_WeakPointersList.h:91
void reverse()
reverse the vector
Definition: CORE_WeakPointersList.hpp:154
virtual void addInList(const boost::shared_ptr< T > &obj)
add a core object
Definition: CORE_WeakPointersList.h:122
void add(T &obj)
add an element at the end
Definition: CORE_WeakPointersList.h:113
static boost::shared_ptr< CORE_WeakPointersList< T > > New()
New constructor of a shared pointers list.
Definition: CORE_WeakPointersList.h:71
class CORE_WeakPointersList is a list of weak shared pointers
Definition: CORE_WeakPointersList.h:11
int size() const
return the size of the array
Definition: CORE_WeakPointersList.h:212
abstract base class for most classes.
Definition: CORE_Object.h:30
void clear()
clear the array
Definition: CORE_WeakPointersList.h:164
void copy(const CORE_WeakPointersList< Q > &cpy)
copy the weak pointers list cpy
Definition: CORE_WeakPointersList.hpp:26
tBoolean removeAtIndex(const int &i)
remove the pointer at index i
Definition: CORE_WeakPointersList.hpp:112
void merge(const CORE_WeakPointersList< Q > &array)
merge the array in this
Definition: CORE_WeakPointersList.hpp:167
#define ASSERT_IN(a)
Definition: types.h:82
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106