20 #ifndef HURRICANE_VECTOR_COLLECTION
21 #define HURRICANE_VECTOR_COLLECTION
23 #include "hurricane/Commons.h"
41 public:
typedef vector<Element> ElementVector;
48 private:
const ElementVector* _elementVector;
49 private:
typename ElementVector::const_iterator _iterator;
51 public: Locator(
const ElementVector* elementVector)
54 _elementVector(elementVector),
57 if (_elementVector) _iterator = _elementVector->begin();
60 public:
virtual Element getElement()
const
63 return (isValid()) ? *_iterator : Element();
69 return new Locator(_elementVector);
72 public:
virtual bool isValid()
const
75 return (_elementVector && (_iterator != _elementVector->end()));
78 public:
virtual void progress()
89 private:
const ElementVector* _elementVector;
97 _elementVector(elementVector)
104 _elementVector(&elementVector)
111 _elementVector(vectorCollection._elementVector)
121 _elementVector = vectorCollection._elementVector;
128 public:
virtual Collection<Element>* getClone() const
139 return (_elementVector) ?
new Locator(_elementVector) : NULL;
142 public:
virtual unsigned getSize() const
145 return (_elementVector) ? _elementVector->size() : 0;
151 public:
virtual string _getTypeName() const
154 return _TName(
"VectorCollection");
157 public:
virtual string _getString() const
161 return "<" + _getTypeName() +
" unbound>";
163 if (_elementVector->empty())
164 return "<" + _getTypeName() +
" empty>";
166 return "<" + _getTypeName() +
" " + getString(_elementVector->size()) +
">";
170 public: Record* _getRecord() const
173 Hurricane::Record* record = NULL;
174 if (!_elementVector->empty()) {
175 record =
new Record(_getString());
177 typename vector<Element>::const_iterator iterator = _elementVector->begin();
178 while (iterator != _elementVector->end()) {
179 record->add(getSlot(getString(n++), *iterator));
194 template<
class Element>
195 inline GenericCollection<Element> getCollection(
const vector<Element>& elementVector)
198 return VectorCollection<Element>(elementVector);
201 template<
class Element>
202 inline GenericCollection<Element> getCollection(
const vector<Element>* elementVector)
205 return VectorCollection<Element>(elementVector);
Collection description (API)
Definition: Collection.h:39
Locator description (API)
Definition: Locator.h:33
Hurricane Collection wrapper around a std::vector.
Definition: VectorCollection.h:33
VectorCollection(const ElementVector *elementVector=NULL)
Definition: VectorCollection.h:94
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5