1 #ifndef CORE_WeakPointersList_H 2 #define CORE_WeakPointersList_H 4 #include "boost/shared_ptr.hpp" 5 #include "boost/weak_ptr.hpp" 47 boost::shared_ptr<const T> v=mVector[(int)i].lock();
50 boost::shared_ptr<const T> temp;
58 boost::shared_ptr<T> v=mVector[(int)i].lock();
61 boost::shared_ptr<T> temp;
68 static inline boost::shared_ptr<CORE_WeakPointersList<T> >
New() {
104 void add(
const boost::shared_ptr<T>& obj) {
105 boost::weak_ptr<T> wobj=obj;
106 mVector.push_back(wobj);
111 boost::shared_ptr<T> p;
112 obj.getSharedPointer(p);
119 virtual void addInList(
const boost::shared_ptr<T>& obj) {
135 return remove(obj.get());
150 if (obj!=
null)
return remove(*obj);
162 if (
size()==0)
return false;
163 return remove(
size()-1);
178 boost::shared_ptr<T> obj=mVector[mVector.size()-1].lock();
181 boost::shared_ptr<T> p;
192 boost::shared_ptr<T> obj=mVector[i].lock();
193 if (obj)
return obj.get();
205 boost::shared_ptr<T> obj=mVector[i].lock();
206 if (obj)
return obj.get();
231 if (obj==
null)
return false;
260 inline typename vector<boost::weak_ptr<T> >::const_iterator
begin()
const {
261 return mVector.begin();
265 inline typename vector<boost::weak_ptr<T> >::iterator
begin() {
266 return mVector.begin();
271 inline typename vector<boost::weak_ptr<T> >::const_iterator
end()
const {
272 return mVector.end();
276 inline typename vector<boost::weak_ptr<T> >::iterator
end() {
277 return mVector.end();
boost::shared_ptr< T > getLastElement()
get last element pointer
Definition: CORE_WeakPointersList.h:176
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
void permute(const tUIndex &i, const tUIndex &j)
permute
Definition: CORE_WeakPointersList.hpp:88
CORE_SharedPointersList< T > toSharedVector()
to shared vector
Definition: CORE_WeakPointersList.h:238
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersList.h:134
tBoolean removeAtIndex(const tUIndex &i)
remove the pointer at index i
Definition: CORE_WeakPointersList.hpp:80
vector< boost::weak_ptr< T > >::const_iterator end() const
get iterator
Definition: CORE_WeakPointersList.h:271
#define tBoolean
Definition: types.h:139
vector< boost::weak_ptr< T > > mVector
Definition: CORE_WeakPointersList.h:16
CORE_WeakPointersList()
internal constructor
Definition: CORE_WeakPointersList.hpp:7
boost::shared_ptr< const T > operator[](const tUIndex &i) const
get the i-th element ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_WeakPointersList.h:45
tUIndex size() const
return the size of the array
Definition: CORE_WeakPointersList.h:213
#define null
Definition: types.h:144
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:104
void setSize(const int &n)
set the size of the weak pointer list
Definition: CORE_WeakPointersList.h:88
tUIndex getSize() const
return the size of the array
Definition: CORE_WeakPointersList.h:216
void reverse()
reverse the vector
Definition: CORE_WeakPointersList.hpp:123
tBoolean insert(const tUIndex &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:97
virtual void addInList(const boost::shared_ptr< T > &obj)
add a core object
Definition: CORE_WeakPointersList.h:119
void add(T &obj)
add an element at the end
Definition: CORE_WeakPointersList.h:110
boost::shared_ptr< T > operator[](const tUIndex &i)
return the shared pointer at index i
Definition: CORE_WeakPointersList.h:56
static boost::shared_ptr< CORE_WeakPointersList< T > > New()
New constructor of a shared pointers list.
Definition: CORE_WeakPointersList.h:68
vector< boost::weak_ptr< T > >::iterator end()
get iterator
Definition: CORE_WeakPointersList.h:276
#define tUIndex
Definition: types.h:126
class CORE_WeakPointersList is a list of weak shared pointers
Definition: CORE_WeakPointersList.h:11
vector< boost::weak_ptr< T > >::iterator begin()
get iterator
Definition: CORE_WeakPointersList.h:265
abstract base class for most classes.
Definition: CORE_Object.h:53
void clear()
clear the array
Definition: CORE_WeakPointersList.h:167
void copy(const CORE_WeakPointersList< Q > &cpy)
copy the weak pointers list cpy
Definition: CORE_WeakPointersList.hpp:26
tBoolean exists(const boost::shared_ptr< T > &obj) const
exists
Definition: CORE_WeakPointersList.h:221
vector< boost::weak_ptr< T > >::const_iterator begin() const
get iterator
Definition: CORE_WeakPointersList.h:260
void merge(const CORE_WeakPointersList< Q > &array)
merge the array in this
Definition: CORE_WeakPointersList.hpp:135
#define ASSERT_IN(a)
Definition: types.h:196
tBoolean exists(const T *obj) const
exists
Definition: CORE_WeakPointersList.h:230
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141