40 #ifndef __OPENFLUID_FLUIDX_ADVANCEDWARESETDESCRIPTOR_HPP__ 41 #define __OPENFLUID_FLUIDX_ADVANCEDWARESETDESCRIPTOR_HPP__ 53 template<
class M,
class I>
85 virtual void check() = 0;
110 return mp_Descriptor->items();
124 mp_Descriptor->items() = Items;
140 std::list<I*>& Items = mp_Descriptor->items();
142 if (Index < Items.size())
144 typename std::list<I*>::iterator it = Items.begin();
145 std::advance(it, Index);
151 "Index out of bounds");
166 mp_Descriptor->appendItem(Item);
181 std::list<I*>& Items = mp_Descriptor->items();
184 Items.insert(Items.begin(), Item);
185 else if (Index < Items.size())
187 typename std::list<I*>::iterator it = Items.begin();
188 std::advance(it, Index);
190 Items.insert(it, Item);
194 "Index out of bounds");
209 std::list<I*>& Items = mp_Descriptor->items();
211 if (Index < Items.size())
213 typename std::list<I*>::iterator it = Items.begin();
214 std::advance(it, Index);
220 "Index out of bounds");
234 void moveItem(
unsigned int indexFrom,
unsigned int indexTo)
236 if (indexFrom == indexTo)
return;
238 std::list<I*>& Items = mp_Descriptor->items();
240 unsigned int Last = Items.size() - 1;
242 if (indexFrom > Last || indexTo > Last)
244 "Index out of bounds");
246 typename std::list<I*>::const_iterator itFrom = Items.begin();
247 std::advance(itFrom, indexFrom);
251 removeItem(indexFrom);
256 insertItem(Item, indexTo);
271 std::list<I*>& Items = mp_Descriptor->items();
273 for (
typename std::list<I*>::iterator it = Items.begin(); it != Items.end(); ++it)
275 if (getID(*it) == ID)
276 return std::distance(Items.begin(), it);
293 std::list<I*>& Items = mp_Descriptor->items();
295 typename std::list<I*>::iterator it = std::find(Items.begin(), Items.end(), Item);
297 if (it != Items.end())
298 return std::distance(Items.begin(), it);
314 std::vector<std::string> IDs;
316 std::list<I*>& Items = mp_Descriptor->items();
318 for (
typename std::list<I*>::const_iterator it = Items.begin(); it != Items.end(); ++it)
319 IDs.push_back(getID(*it));
334 return mp_Descriptor->items().size();
345 mp_Descriptor->setGlobalParameter(Key, Value);
355 mp_Descriptor->setGlobalParameters(Params);
365 return mp_Descriptor->getGlobalParameters();
375 mp_Descriptor->eraseGlobalParameter(Key);
int findFirstItem(const openfluid::ware::WareID_t &ID) const
Definition: AdvancedWareSetDescriptor.hpp:269
Definition: AdvancedWareSetDescriptor.hpp:54
openfluid::ware::WareParams_t getGlobalParameters() const
Definition: AdvancedWareSetDescriptor.hpp:363
std::string WareID_t
Definition: TypeDefs.hpp:50
void moveItem(unsigned int indexFrom, unsigned int indexTo)
Definition: AdvancedWareSetDescriptor.hpp:234
void removeItem(unsigned int Index)
Definition: AdvancedWareSetDescriptor.hpp:207
const std::list< I * > & items() const
Definition: AdvancedWareSetDescriptor.hpp:108
void setGlobalParameter(const openfluid::ware::WareParamKey_t &Key, const openfluid::ware::WareParamValue_t &Value)
Definition: AdvancedWareSetDescriptor.hpp:342
void insertItem(I *Item, unsigned int Index)
Definition: AdvancedWareSetDescriptor.hpp:179
AdvancedWareSetDescriptor(M &Desc)
Definition: AdvancedWareSetDescriptor.hpp:64
void eraseGlobalParameter(const openfluid::ware::WareParamKey_t &Key)
Definition: AdvancedWareSetDescriptor.hpp:373
std::string WareParamKey_t
Definition: TypeDefs.hpp:126
void setItems(const std::list< I * > &Items)
Definition: AdvancedWareSetDescriptor.hpp:122
std::vector< openfluid::ware::WareID_t > getOrderedIDs() const
Definition: AdvancedWareSetDescriptor.hpp:312
void setGlobalParameters(const openfluid::ware::WareParams_t &Params)
Definition: AdvancedWareSetDescriptor.hpp:353
Definition: FrameworkException.hpp:50
Definition: ApplicationException.hpp:47
M * mp_Descriptor
Definition: AdvancedWareSetDescriptor.hpp:58
virtual ~AdvancedWareSetDescriptor()
Definition: AdvancedWareSetDescriptor.hpp:75
int getItemsCount()
Definition: AdvancedWareSetDescriptor.hpp:332
int findFirstItem(const I *Item) const
Definition: AdvancedWareSetDescriptor.hpp:291
#define OPENFLUID_API
Definition: dllexport.hpp:87
void appendItem(I *Item)
Definition: AdvancedWareSetDescriptor.hpp:163
Definition: StringValue.hpp:91
I & itemAt(unsigned int Index) const
Definition: AdvancedWareSetDescriptor.hpp:138
std::map< WareParamKey_t, WareParamValue_t > WareParams_t
Definition: TypeDefs.hpp:130