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);
91 inline int size()
const{
return (
int) mMap.size();};
94 inline int getSize()
const{
return (
int) mMap.size();};
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);
264 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
const Key & currentKey() const
current key
Definition: CORE_SharedPointersVMap.h:165
void next(Key &k, boost::shared_ptr< Value > &v)
has next
Definition: CORE_SharedPointersVMap.h:151
int getSize() const
return the size of the array
Definition: CORE_SharedPointersVMap.h:94
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:18
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 boost::shared_ptr< Value > currentValue() const
current value
Definition: CORE_SharedPointersVMap.h:171
boost::shared_ptr< Value > currentValue()
current value
Definition: CORE_SharedPointersVMap.h:176
#define tBoolean
Definition: types.h:35
void getKeys(vector< Key > &ks) const
return a vector of keys
Definition: CORE_SharedPointersVMap.hpp:129
virtual tString toString() const
return the string representation of the object node
Definition: CORE_SharedPointersVMap.hpp:39
void getValues(CORE_Vector< Value * > &vals) const
return an array of values
Definition: CORE_SharedPointersVMap.hpp:100
#define null
Definition: types.h:13
void nextElement()
next element
Definition: CORE_SharedPointersVMap.h:158
const Value & operator()(const Key &k) const
get object corresponding to key
Definition: CORE_SharedPointersVMap.h:61
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
this class describes an array
Definition: CORE_Array.h:18
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:169
tBoolean put(const Key &k, Value &v)
set the value at the index k
Definition: CORE_SharedPointersVMap.h:199
int size() const
return the size of the array
Definition: CORE_SharedPointersVMap.h:91
const boost::shared_ptr< Value > operator[](const Key &k) const
get object corresponding to key
Definition: CORE_SharedPointersVMap.h:43
void clear()
clear the map
Definition: CORE_SharedPointersVMap.h:253
abstract base class for most classes.
Definition: CORE_Object.h:30
tBoolean removeValue(const Value *k)
remove the value
Definition: CORE_SharedPointersVMap.hpp:212
Value & operator()(const Key &k)
get object corresponding to key
Definition: CORE_SharedPointersVMap.h:66
#define tString
Definition: types.h:36
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
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
tBoolean hasNext() const
had next
Definition: CORE_SharedPointersVMap.h:133