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