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)
239 std::list<I*>& Items = mp_Descriptor->items();
241 unsigned int Last = Items.size() - 1;
243 if (indexFrom > Last || indexTo > Last)
245 "Index out of bounds");
247 typename std::list<I*>::const_iterator itFrom = Items.begin();
248 std::advance(itFrom, indexFrom);
252 removeItem(indexFrom);
257 insertItem(Item, indexTo);
272 std::list<I*>& Items = mp_Descriptor->items();
274 for (
typename std::list<I*>::iterator it = Items.begin(); it != Items.end(); ++it)
276 if (getID(*it) == ID)
277 return std::distance(Items.begin(), it);
294 std::list<I*>& Items = mp_Descriptor->items();
296 typename std::list<I*>::iterator it = std::find(Items.begin(), Items.end(), Item);
298 if (it != Items.end())
299 return std::distance(Items.begin(), it);
315 std::vector<std::string> IDs;
317 std::list<I*>& Items = mp_Descriptor->items();
319 for (
typename std::list<I*>::const_iterator it = Items.begin(); it != Items.end(); ++it)
320 IDs.push_back(getID(*it));
335 return mp_Descriptor->items().size();
346 mp_Descriptor->setGlobalParameter(Key, Value);
356 mp_Descriptor->setGlobalParameters(Params);
366 return mp_Descriptor->getGlobalParameters();
376 mp_Descriptor->eraseGlobalParameter(Key);
std::map< WareParamKey_t, WareParamValue_t > WareParams_t
Definition: TypeDefs.hpp:130
int findFirstItem(const openfluid::ware::WareID_t &ID) const
Definition: AdvancedWareSetDescriptor.hpp:270
openfluid::ware::WareParams_t getGlobalParameters() const
Definition: AdvancedWareSetDescriptor.hpp:364
std::vector< openfluid::ware::WareID_t > getOrderedIDs() const
Definition: AdvancedWareSetDescriptor.hpp:313
void eraseGlobalParameter(const openfluid::ware::WareParamKey_t &Key)
Definition: AdvancedWareSetDescriptor.hpp:374
virtual ~AdvancedWareSetDescriptor()
Definition: AdvancedWareSetDescriptor.hpp:75
Definition: FrameworkException.hpp:50
M * mp_Descriptor
Definition: AdvancedWareSetDescriptor.hpp:58
std::string WareID_t
Definition: TypeDefs.hpp:50
#define OPENFLUID_API
Definition: dllexport.hpp:87
Definition: AdvancedWareSetDescriptor.hpp:54
int findFirstItem(const I *Item) const
Definition: AdvancedWareSetDescriptor.hpp:292
I & itemAt(unsigned int Index) const
Definition: AdvancedWareSetDescriptor.hpp:138
void setGlobalParameters(const openfluid::ware::WareParams_t &Params)
Definition: AdvancedWareSetDescriptor.hpp:354
std::string WareParamKey_t
Definition: TypeDefs.hpp:126
int getItemsCount()
Definition: AdvancedWareSetDescriptor.hpp:333
void setGlobalParameter(const openfluid::ware::WareParamKey_t &Key, const openfluid::ware::WareParamValue_t &Value)
Definition: AdvancedWareSetDescriptor.hpp:343
Definition: StringValue.hpp:91
void insertItem(I *Item, unsigned int Index)
Definition: AdvancedWareSetDescriptor.hpp:179
void appendItem(I *Item)
Definition: AdvancedWareSetDescriptor.hpp:163
AdvancedWareSetDescriptor(M &Desc)
Definition: AdvancedWareSetDescriptor.hpp:64
void moveItem(unsigned int indexFrom, unsigned int indexTo)
Definition: AdvancedWareSetDescriptor.hpp:234
const std::list< I * > & items() const
Definition: AdvancedWareSetDescriptor.hpp:108
Definition: ApplicationException.hpp:47
void setItems(const std::list< I *> &Items)
Definition: AdvancedWareSetDescriptor.hpp:122
void removeItem(unsigned int Index)
Definition: AdvancedWareSetDescriptor.hpp:207