Go to the documentation of this file.
32 #include <boost/regex.hpp>
34 #include <IceUtil/UUID.h>
35 #include <Ice/ObjectAdapter.h>
36 #include <Ice/ValueFactory.h>
38 template class ::IceInternal::Handle<::armarx::SingleVariant>;
39 template class ::IceInternal::Handle<::armarx::ContainerTypeI>;
44 SingleVariant::SingleVariant()
52 SingleVariant::SingleVariant(
const Variant& variant)
57 typeContainer->typeId = Variant::typeToString(variant.
getType());
62 VariantContainerBase(
source),
73 element = VariantPtr::dynamicCast(
source.element)->
clone();
75 typeContainer =
source.typeContainer->clone();
101 element = variant->clone();
114 return typeContainer;
119 this->typeContainer = containerType->clone();
129 return element->validate();
135 obj->setVariant(
"variant",
get());
146 return "::armarx::SingleVariantBase";
151 VariantPtr variant = VariantPtr::dynamicCast(element);
152 std::string variantString = variant->getOutputValueOnly();
153 return variantString;
167 newType->typeId = this->typeId;
171 newType->subType = subType->clone();
181 this->containerType = containerType;
183 thisType->typeId = containerType;
189 ContainerTypeI result = *(ContainerTypeIPtr::dynamicCast(thisType->clone()));
198 ContainerTypeI result = *(ContainerTypeIPtr::dynamicCast(thisType->clone()));
199 result.subType = subType.
clone();
205 ContainerTypePtr type1 = firstType;
206 ContainerTypePtr type2 = secondType;
208 if (!type1 && !type2)
213 while (type1 || type2)
215 if ((type1 && !type2) || (!type1 && type2))
220 if (type1->typeId != type2->typeId)
225 type1 = type1->subType;
226 type2 = type2->subType;
235 ContainerTypePtr curType = type;
236 std::vector<std::string> typeStrings;
241 typeStrings.push_back(curType->typeId);
242 curType = curType->subType;
245 std::vector<std::string>::reverse_iterator rit = typeStrings.rbegin();
247 for (; rit != typeStrings.rend(); rit++)
255 result = *rit +
"(" + result +
")";
264 boost::regex exp(
"([a-zA-Z:0-9_\\-]+?)\\(([a-zA-Z:0-9_\\-()]+)\\)");
265 boost::match_results<std::string::const_iterator>
matches;
268 if (boost::regex_search(typeStr,
matches, exp))
275 result->typeId = typeStr;
288 while (type->subType)
290 type = type->subType;
307 VariantContainerBase(
source)
309 typeContainer =
source.typeContainer->clone();
319 return this->
clone();
324 return typeContainer;
329 typeContainer = containerType;
350 return typeContainer;
355 typeContainer = containerType;
360 return cloneContainer(
c);
375 return validateElements(
c);
The Variant class is described here: Variants.
std::string toString(const Ice::Current &c) const override
void serialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
SingleVariant & operator=(const SingleVariant &source)
static std::string GetInnerType(const std::string &typeStr)
std::string toString(const Ice::Current &c) const override
VariantTypeId getType(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's internal type.
static std::string getTypePrefix()
const VariantTypeId VariantContainer
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &c=Ice::emptyCurrent) override
bool validateElements(const ::Ice::Current &=Ice::emptyCurrent) override
ContainerTypePtr getContainerType(const Ice::Current &=Ice::emptyCurrent) const override
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
int getSize(const Ice::Current &=Ice::emptyCurrent) const override
VariantContainerBasePtr cloneContainer(const ::Ice::Current &=Ice::emptyCurrent) const override
Ice::ObjectPtr ice_clone() const override
static VariantTypeId getStaticType(const Ice::Current &c=Ice::emptyCurrent)
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &=Ice::emptyCurrent) override
VariantContainerType(std::string containerType)
VariantBasePtr getElementBase(const Ice::Current &=Ice::emptyCurrent) const override
ContainerTypePtr clone(const Ice::Current &=Ice::emptyCurrent) const override
The SingleVariant class is required to store single Variant instances in VariantContainer subclasses.
void deserialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
static bool compare(const ContainerTypePtr &type1, const ContainerTypePtr &secondType)
const ContainerTypeI operator()(VariantTypeId typeId) const
const VariantTypeId Invalid
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
int getSize(const ::Ice::Current &=Ice::emptyCurrent) const override
VariantContainer is the base class of all other Variant container classes.
bool validate(const Ice::Current &c=Ice::emptyCurrent) override
Ice::ObjectPtr ice_clone() const override
Ice::Int getType(const Ice::Current &c=Ice::emptyCurrent) const override
bool matches(std::string skillName, std::vector< std::string > &searches)
const char * toString(InteractionFeedbackType type)
VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
VariantContainerBasePtr cloneContainer(const Ice::Current &=Ice::emptyCurrent) const override
std::shared_ptr< Object > ObjectPtr
void setVariant(const VariantPtr &variant)
ContainerTypePtr getContainerType(const Ice::Current &c=Ice::emptyCurrent) const override
static ContainerTypePtr FromString(const std::string &typeStr)
bool validateElements(const Ice::Current &=Ice::emptyCurrent) override
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &c=Ice::emptyCurrent) override
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
static std::string allTypesToString(const ContainerTypePtr &type)