20 #ifndef HURRICANE_MAP_COLLECTION
21 #define HURRICANE_MAP_COLLECTION
23 #include "hurricane/Commons.h"
33 template<
class Key,
class Element,
class Compare = less<Key> >
42 public:
typedef map<Key, Element, Compare> ElementMap;
49 private:
const ElementMap* _elementMap;
50 private:
typename ElementMap::const_iterator _iterator;
52 public: Locator(
const ElementMap* elementMap)
55 _elementMap(elementMap),
58 if (_elementMap) _iterator = _elementMap->begin();
61 public:
virtual Element getElement()
const
64 return (isValid()) ? (*_iterator).second : Element();
70 return new Locator(_elementMap);
73 public:
virtual bool isValid()
const
76 return (_elementMap && (_iterator != _elementMap->end()));
79 public:
virtual void progress()
90 private:
const ElementMap* _elementMap;
98 _elementMap(elementMap)
105 _elementMap(&elementMap)
112 _elementMap(mapCollection._elementMap)
122 _elementMap = mapCollection._elementMap;
129 public:
virtual Collection<Element>* getClone() const
140 return (_elementMap) ?
new Locator(_elementMap) : NULL;
143 public:
virtual unsigned getSize() const
146 return (_elementMap) ? _elementMap->size() : 0;
152 public:
virtual string _getTypeName() const
155 return _TName(
"MapCollection");
158 public:
virtual string _getString() const
162 return "<" + _getTypeName() +
" unbound>";
164 if (_elementMap->empty())
165 return "<" + _getTypeName() +
" empty>";
167 return "<" + _getTypeName() +
" " + getString(_elementMap->size()) +
">";
171 Record* _getRecord() const
174 Record* record = NULL;
175 if (!_elementMap->empty()) {
176 record =
new Record(_getString());
177 typename map<Key, Element, Compare>::const_iterator iterator = _elementMap->begin();
178 while (iterator != _elementMap->end()) {
179 record->add(getSlot<Element>(getString((*iterator).first), (*iterator).second));
194 template<
class Key,
class Element,
class Compare>
195 inline GenericCollection<Element> getCollection(
const map<Key, Element, Compare>& elementMap)
198 return MapCollection<Key, Element, Compare>(elementMap);
201 template<
class Key,
class Element,
class Compare>
202 inline GenericCollection<Element> getCollection(
const map<Key, Element, Compare>* elementMap)
205 return MapCollection<Key, Element, Compare>(elementMap);
Collection description (API)
Definition: Collection.h:39
Locator description (API)
Definition: Locator.h:33
Hurricane Collection wrapper around a std::map.
Definition: MapCollection.h:34
MapCollection(const ElementMap *elementMap=NULL)
Definition: MapCollection.h:95
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5