1 #ifndef CORE_SharedPointersVMap_H 2 #define CORE_SharedPointersVMap_H 4 #include "boost/shared_ptr.hpp" 5 #include "boost/weak_ptr.hpp" 14 template <
class Key,
class Value>
17 map<Key,boost::shared_ptr<Value> >
mMap;
18 typename map<Key,boost::shared_ptr<Value> >::iterator
mIterator;
32 template <
class K,
class Q>
43 inline const boost::shared_ptr<Value>
operator[](
const Key& k)
const {
44 const boost::shared_ptr<Value> ret;
45 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.find(k);
46 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
47 if (iter!=end)
return iter->second;
52 inline boost::shared_ptr<Value>
operator[](
const Key& k) {
53 boost::shared_ptr<Value> ret;
54 typename map<Key,boost::shared_ptr<Value> >::iterator iter=mMap.find(k);
55 if (iter!=mMap.end())
return iter->second;
62 return *(*this)[k].get();
67 return *(*this)[k].get();
83 const Value*
get(
const Key& k)
const;
88 Value*
get(
const Key& k);
103 void getValues(vector<Value*>& vals)
const;
115 void getKeys(vector<Key>& ks)
const;
129 mIterator=mMap.begin();
134 return (mIterator!=mMap.end());
139 return (mIterator!=mMap.end());
144 inline void next(Key& k,Value*& v) {
145 v=mIterator->second.get();
151 inline void next(Key& k,boost::shared_ptr<Value>& v) {
166 return mIterator->first;
172 return mIterator->second;
177 return mIterator->second;
185 template<
class K,
class V>
192 inline tBoolean put(
const Key& k,
const boost::shared_ptr<Value>& v) {
200 boost::shared_ptr<Value> p_v;
201 v.getSharedPointer(p_v);
209 boost::shared_ptr<Value> p_v;
211 v->getSharedPointer(p_v);
269 template <
class K,
class V>
tBoolean exists(const Key &k) const
exists return true if the key exists in map
Definition: CORE_SharedPointersVMap.hpp:52
map< Key, boost::shared_ptr< Value > >::iterator mIterator
Definition: CORE_SharedPointersVMap.h:18
const boost::shared_ptr< Value > operator[](const Key &k) const
get object corresponding to key
Definition: CORE_SharedPointersVMap.h:43
void getValues(CORE_Vector< Value *> &vals) const
return an array of values
Definition: CORE_SharedPointersVMap.hpp:100
void next(Key &k, boost::shared_ptr< Value > &v)
has next
Definition: CORE_SharedPointersVMap.h:151
void copy(const CORE_SharedPointersVMap< K, V > &mapCpy)
copy a map
Definition: CORE_SharedPointersVMap.hpp:28
this class describes an array
Definition: CORE_Vector.h:19
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
tBoolean hasNextElement() const
had next element
Definition: CORE_SharedPointersVMap.h:138
void next(Key &k, Value *&v)
has next
Definition: CORE_SharedPointersVMap.h:144
const Value & operator()(const Key &k) const
get object corresponding to key
Definition: CORE_SharedPointersVMap.h:61
boost::shared_ptr< Value > currentValue()
current value
Definition: CORE_SharedPointersVMap.h:176
map< Key, boost::shared_ptr< Value > > mMap
Definition: CORE_SharedPointersVMap.h:17
#define tBoolean
Definition: types.h:139
#define null
Definition: types.h:144
void nextElement()
next element
Definition: CORE_SharedPointersVMap.h:158
This class describes a map: primitive type of Key -> shared pointer of Value.
Definition: CORE_SharedPointersVMap.h:15
virtual ~CORE_SharedPointersVMap()
destroy a map
Definition: CORE_SharedPointersVMap.hpp:22
const Key & currentKey() const
current key
Definition: CORE_SharedPointersVMap.h:165
this class describes an array
Definition: CORE_Array.h:19
virtual tString toString() const
return the string representation of the object node
Definition: CORE_SharedPointersVMap.hpp:39
tBoolean removeValue(boost::shared_ptr< Value > &k)
remove the value
Definition: CORE_SharedPointersVMap.h:251
tUIndex size() const
return the size of the array
Definition: CORE_SharedPointersVMap.h:91
boost::shared_ptr< Value > operator[](const Key &k)
get object corresponding to key
Definition: CORE_SharedPointersVMap.h:52
void merge(const CORE_SharedPointersVMap< K, V > &m)
merge the map
Definition: CORE_SharedPointersVMap.hpp:162
tBoolean put(const Key &k, Value &v)
set the value at the index k
Definition: CORE_SharedPointersVMap.h:199
#define tUIndex
Definition: types.h:126
void clear()
clear the map
Definition: CORE_SharedPointersVMap.h:258
abstract base class for most classes.
Definition: CORE_Object.h:53
tBoolean removeValue(const Value *k)
remove the value
Definition: CORE_SharedPointersVMap.h:234
Value & operator()(const Key &k)
get object corresponding to key
Definition: CORE_SharedPointersVMap.h:66
#define tString
Definition: types.h:135
tBoolean hasNext() const
had next
Definition: CORE_SharedPointersVMap.h:133
tBoolean put(const Key &k, Value *v)
set the value at the index k
Definition: CORE_SharedPointersVMap.h:208
void begin()
begin
Definition: CORE_SharedPointersVMap.h:128
void getKeys(vector< Key > &ks) const
return a vector of keys
Definition: CORE_SharedPointersVMap.hpp:131
CORE_SharedPointersVMap()
Definition: CORE_SharedPointersVMap.hpp:7
tBoolean put(const Key &k, const boost::shared_ptr< Value > &v)
set the value at the index k
Definition: CORE_SharedPointersVMap.h:192
tUIndex getSize() const
return the size of the array
Definition: CORE_SharedPointersVMap.h:94
const boost::shared_ptr< Value > currentValue() const
current value
Definition: CORE_SharedPointersVMap.h:171