30 #include <ArmarXCore/interface/observers/VariantContainers.h>
33 #include <IceUtil/Handle.h>
51 virtual public StringValueMapBase
59 VariantContainerBasePtr cloneContainer(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
64 void addElement(
const std::string& key,
const VariantContainerBasePtr& variantContainer,
const Ice::Current&
c = Ice::emptyCurrent)
override;
65 void addVariant(
const std::string& key,
const Variant& variant);
66 void setElement(
const std::string& key,
const VariantContainerBasePtr& variantContainer,
const Ice::Current&
c = Ice::emptyCurrent)
override;
78 template <
typename ValueType>
79 void setElements(
const std::map<std::string, ValueType>& map);
84 template <
typename ValueType>
85 void setElements(
const std::vector<std::string>& keyVec,
const std::vector<ValueType>&
values);
90 void clear(
const Ice::Current&
c = Ice::emptyCurrent)
override;
93 Ice::Int getType(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
95 static VariantTypeId getStaticType(
const Ice::Current&
c = Ice::emptyCurrent);
97 int getSize(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
98 bool validateElements(
const Ice::Current&
c = Ice::emptyCurrent)
override;
113 VariantContainerBasePtr getElementBase(
const std::string& key,
const Ice::Current&
c = Ice::emptyCurrent)
const override;
124 template <
typename ContainerType>
131 throw InvalidTypeException();
143 VariantPtr getVariant(
const std::string& key)
const;
152 template <
class ValueType>
155 std::map<std::string, ValueType> map;
156 StringVariantContainerBaseMap::const_iterator it = elements.begin();
158 for (; it != elements.end(); it++)
160 const std::string& key = it->first;
161 map[key] = getVariant(key)->get<ValueType>();
170 template <
typename Type>
173 std::map<std::string, Type> map;
174 StringVariantContainerBaseMap::const_iterator it = elements.begin();
176 for (; it != elements.end(); it++)
178 const std::string& key = it->first;
179 map[key] = getElement<typename Type::element_type>(key);
195 template <
typename Type>
200 for (
typename std::map<std::string, Type>::const_iterator it = map.begin(); it != map.end(); it++)
202 result->addVariant(it->first, it->second);
218 template <
typename Type>
223 for (
typename std::map<std::string, Type>::const_iterator it = map.begin(); it != map.end(); it++)
225 result->addElement(it->first, it->second);
232 static std::string getTypePrefix();
234 void serialize(
const ObjectSerializerBasePtr& serializer, const ::Ice::Current& = Ice::emptyCurrent)
const override;
235 void deserialize(
const ObjectSerializerBasePtr& serializer, const ::Ice::Current& = Ice::emptyCurrent)
override;
239 std::string
toString(
const Ice::Current& = Ice::emptyCurrent)
const override;
241 bool forceSingleTypeMap =
true;
261 template <
typename ValueType>
264 typename std::map<std::string, ValueType>::const_iterator it = map.begin();
266 for (; it != map.end(); it++)
271 template <
typename ValueType>
277 if (keyVec.size() !=
values.size())
279 ARMARX_WARNING_S <<
"Size of keys vector does not match values vector size:" << keyVec.size() <<
" vs. " <<
values.size();
282 for (
int i = 0; i < size; i++)