Go to the documentation of this file.
32 #include <IceUtil/UUID.h>
33 #include <Ice/LocalException.h>
34 #include <Ice/ValueFactory.h>
72 variantNode->setInt(
"type", type);
75 if (val->ice_id() == TimedVariantBase::ice_staticId())
78 variantNode->setDouble(
"timestamp", tvar->getTimestamp());
81 if (!val->getInitialized())
83 variantNode->setString(
"value",
"(not initialized)");
87 variantNode->setString(
"value",
"(invalid type)");
91 variantNode->setInt(
"value", val->getInt());
95 variantNode->setInt(
"value",
static_cast<int>(val->getLong()));
99 variantNode->setFloat(
"value", val->getFloat());
103 variantNode->setDouble(
"value", val->getDouble());
107 variantNode->setString(
"value", val->getString());
111 variantNode->setBool(
"value", val->getBool());
115 VariantDataClassPtr ptr = val->getClass<VariantDataClass>();
120 ptr->serialize(valueNode);
122 variantNode->setElement(
"value", valueNode);
126 variantNode->setString(
"value",
"(NULLCAST for" + val->getTypeName() +
")");
140 std::string typeName =
getString(
"typeName");
170 var->setBool(
getBool(
"value"));
186 var->setInt(
getInt(
"value"));
190 var->setLong(
getInt(
"value"));
196 VariantDataClassPtr
data;
200 Ice::ValueFactoryPtr valFac =
ic->getValueFactoryManager()->find(typeStr);
204 throw Ice::NoValueFactoryException(__FILE__, __LINE__,
"Could not find ValueFactory for string '" + typeStr +
"'", typeStr);
207 data = VariantDataClassPtr::dynamicCast(valFac->create(typeStr));
211 ARMARX_WARNING_S <<
"Could not deserialize variant parameter, because IceCommunicator wasn't set in Serializer";
216 static Ice::Current
c;
220 c.adapter =
ic->createObjectAdapterWithEndpoints(
"Dummy" + IceUtil::generateUUID(),
"tcp");
250 return variantNode->deserializeVariant();
259 return variantNode->deserializeVariant();
265 return iceObjectNode ? iceObjectNode->deserializeIceObject() : SerializablePtr();
271 return iceObjectNode ? iceObjectNode->deserializeIceObject() : SerializablePtr();
277 iceObjectNode->serializeIceObject(obj);
285 iceObjectNode->serializeIceObject(obj);
294 obj->serialize(
this);
299 const std::string typeStr =
getString(
"type");
303 Ice::ValueFactoryPtr valFac =
ic->getValueFactoryManager()->find(typeStr);
310 SerializablePtr obj = SerializablePtr::dynamicCast(valFac->create(typeStr));
311 static Ice::Current
c;
315 c.adapter =
ic->createObjectAdapterWithEndpoints(
"Dummy" + IceUtil::generateUUID(),
"tcp");
318 obj->deserialize(
this,
c);
324 return SerializablePtr();
virtual AbstractObjectSerializerPtr createElement() const =0
The Variant class is described here: Variants.
virtual SerializablePtr getIceObject(const ::std::string &key) const
const VariantTypeId Float
void setIceCommunicator(Ice::CommunicatorPtr ic)
virtual void setVariant(const ::std::string &key, const VariantPtr &val)
static const std::map< VariantTypeId, std::string > & getTypes()
Returns the mapping of currently registered types.
virtual VariantPtr getVariant(const ::std::string &key) const
AbstractObjectSerializerPtr serializeVariant(const VariantPtr &val) const
const VariantTypeId Double
IceInternal::Handle< Variant > VariantPtr
virtual AbstractObjectSerializerPtr getElement(unsigned int index) const =0
const VariantTypeId Invalid
VariantPtr deserializeVariant()
SerializablePtr deserializeIceObject()
~AbstractObjectSerializer() override
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
virtual float getFloat(const ::std::string &key) const =0
void serializeIceObject(const SerializablePtr &obj)
AbstractObjectSerializer()
virtual void setIceObject(const ::std::string &key, const SerializablePtr &val)
virtual bool getBool(const ::std::string &key) const =0
virtual int getInt(const ::std::string &key) const =0
virtual bool hasElement(const ::std::string &key) const =0
virtual std::string getString(const ::std::string &key) const =0
virtual void setElement(const ::std::string &key, const AbstractObjectSerializerPtr &val)=0
static int hashTypeName(const std::string &typeName)
Compute and return a hash value for a given type name.
const VariantTypeId String
virtual double getDouble(const ::std::string &key) const =0
This file offers overloads of toIce() and fromIce() functions for STL container types.
virtual void setString(const ::std::string &key, const std::string &val)=0
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.