Go to the documentation of this file.
32 #include <IceUtil/UUID.h>
33 #include <Ice/ObjectAdapter.h>
34 #include <Ice/ValueFactory.h>
39 forceSingleTypeMap(forceSingleTypeMap)
57 VariantContainerBase(
source),
68 this->typeContainer = ContainerTypePtr::dynamicCast(
source.typeContainer->clone());
70 auto it =
source.elements.begin();
72 for (; it !=
source.elements.end(); it++)
74 elements[it->first] = it->second->cloneContainer();
94 if (elements.find(key) != elements.end())
96 throw KeyAlreadyExistsException();
99 setElement(key, variantContainer->cloneContainer());
117 getContainerType()->subType = variantContainer->getContainerType()->clone();
120 elements[key] = (variantContainer->cloneContainer());
139 return int(elements.size());
144 auto it = elements.begin();
147 for (; it != elements.end(); it++)
149 result = result && it->second->validateElements();
157 auto it = elements.find(key);
159 if (it == elements.end())
161 throw IndexOutOfBoundsException();
169 VariantPtr ptr = getElement<SingleVariant>(key)->get();
173 throw InvalidTypeException();
181 return "::armarx::StringValueMapBase";
187 std::stringstream ss;
189 for (
const auto& element : elements)
191 ss << element.first <<
": " << element.second->toString() <<
"\n";
204 StringVariantContainerBaseMap::const_iterator it = elements.begin();
206 for (; it != elements.end(); it++)
208 newObj->setIceObject(it->first, it->second);
212 obj->setElement(
"map", newObj);
219 Ice::StringSeq keys = map->getElementNames();
221 for (Ice::StringSeq::iterator it = keys.begin(); it != keys.end(); it++)
223 VariantContainerBasePtr
c = VariantContainerBasePtr::dynamicCast(map->getIceObject(*it));
231 throw LocalException(
"Could not cast to VariantContainerBasePtr");
The Variant class is described here: Variants.
void setElement(const std::string &key, const VariantContainerBasePtr &variantContainer, const Ice::Current &c=Ice::emptyCurrent) override
VariantPtr getVariant(const std::string &key) const
getVariant returns a pointer to a Variant object associated with key
const VariantContainerType Map
static VariantTypeId getStaticType(const Ice::Current &c=Ice::emptyCurrent)
VariantContainerBasePtr cloneContainer(const Ice::Current &c=Ice::emptyCurrent) const override
int getSize(const Ice::Current &c=Ice::emptyCurrent) const override
StringValueMap & operator=(const StringValueMap &source)
Ice::Int getType(const Ice::Current &c=Ice::emptyCurrent) const override
The SingleVariant class is required to store single Variant instances in VariantContainer subclasses.
static bool compare(const ContainerTypePtr &type1, const ContainerTypePtr &secondType)
const VariantTypeId Invalid
std::string toString(const Ice::Current &=Ice::emptyCurrent) const override
void addElement(const std::string &key, const VariantContainerBasePtr &variantContainer, const Ice::Current &c=Ice::emptyCurrent) override
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
void addVariant(const std::string &key, const Variant &variant)
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
StringValueMap(bool forceSingleTypeMap=true)
bool validateElements(const Ice::Current &c=Ice::emptyCurrent) override
void deserialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
std::shared_ptr< Object > ObjectPtr
void clear(const Ice::Current &c=Ice::emptyCurrent) override
clear calls ::clear() on the internal StringValueMap::elements container
VariantContainerBasePtr getElementBase(const std::string &key, const Ice::Current &c=Ice::emptyCurrent) const override
getElementBase is the slice-interface implementation for getting an Element and only returns a basepo...
The StringValueMap class is a subclass of VariantContainer and is comparable to a std::map<std::strin...
This file offers overloads of toIce() and fromIce() functions for STL container types.
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
ContainerTypePtr getContainerType(const Ice::Current &c=Ice::emptyCurrent) const override
void serialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
static std::string getTypePrefix()
Ice::ObjectPtr ice_clone() const override