31#include <IceUtil/Handle.h>
33#include <ArmarXCore/interface/observers/VariantBase.h>
34#include <ArmarXCore/interface/observers/VariantContainers.h>
238 typename std::enable_if_t<!(std::is_base_of_v<VariantDataClass, T> ||
239 std::is_pointer_v<T>)>* t =
nullptr)
265 typename std::enable_if_t<std::is_base_of_v<VariantDataClass, T>>* t =
nullptr)
280 typename std::enable_if_t<std::is_base_of_v<VariantDataClass, T>>* t =
nullptr)
295 typename std::enable_if_t<std::is_base_of_v<VariantDataClass, T>>* t =
nullptr)
306 bool validate(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
332 void setInt(
int n,
const Ice::Current&
c = Ice::emptyCurrent)
override;
341 void setLong(
long n,
const Ice::Current&
c = Ice::emptyCurrent)
override;
350 void setFloat(
float f,
const Ice::Current&
c = Ice::emptyCurrent)
override;
359 void setDouble(
double d,
const Ice::Current&
c = Ice::emptyCurrent)
override;
368 void setString(
const std::string& s,
const Ice::Current&
c = Ice::emptyCurrent)
override;
377 void setBool(
bool b,
const Ice::Current&
c = Ice::emptyCurrent)
override;
386 void setClass(
const VariantDataClassPtr& variantDataClass);
395 void setClass(
const VariantDataClass& variantDataClass);
409 int getInt(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
419 long getLong(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
429 float getFloat(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
439 double getDouble(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
449 std::string
getString(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
459 bool getBool(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
468 template <
class TVariantDataClass>
482 throw InvalidTypeException(
483 "Variant::getClass failed: actual type of value: " +
data->ice_id() +
502 template <
typename T>
503 typename std::enable_if_t<std::is_base_of_v<VariantDataClass, T>>
504 set(
const VariantDataClassPtr& variantDataClass)
519 template <
typename T>
520 typename std::enable_if_t<!std::is_base_of_v<VariantDataClass, T>>
523 static_assert(std::is_base_of_v<VariantData, typename T::element_type>,
524 "Only basic types or from VariantDataClass derived classes can be "
525 "template parameters");
526 static int invType =
hashTypeName(InvalidVariantData::ice_staticId());
534 throw InvalidTypeException();
537 data = T::dynamicCast(value->ice_clone());
551 template <
typename T>
558 template <
typename T>
559 typename std::enable_if_t<std::is_base_of_v<VariantDataClass, typename T::element_type>,
T>
574 template <
typename T>
575 typename std::enable_if_t<(std::is_standard_layout_v<T> && std::is_trivial_v<T>) ||
576 std::is_same_v<std::string, T>,
581 "This function must not be called directly, it is only for primitive "
582 "types which have specializations");
599 std::string
getTypeName(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
604 bool getInitialized(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
672 stream <<
"Null VariantPtr";
690 static const std::map<VariantTypeId, std::string>&
getTypes();
702 template <
typename Type>
708 if (typeName.size() > 1)
710 typeName = typeName.substr(0, typeName.size() - 1);
725 void output(std::ostream& stream)
const;
745 static std::map<VariantTypeId, std::string>& types();
906 std::ostream&
operator<<(std::ostream& stream,
const VariantDataClass& variant);
The Variant class is described here: Variants.
bool getInitialized(const Ice::Current &c=Ice::emptyCurrent) const override
Tells if the Variant is properly initialized.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T > > set(const VariantDataClassPtr &variantDataClass)
Template-based setter for the Variant's value for VariantDataClass-instances.
VariantTypeId getType(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's internal type.
static std::string GetType()
Template-based getter for a type name.
Variant & operator=(float f)
static const std::map< VariantTypeId, std::string > & getTypes()
Returns the mapping of currently registered types.
void setClass(const VariantDataClassPtr &variantDataClass)
Sets the Variant's value to variantDataClass.
Variant & operator=(int n)
IceInternal::Handle< TVariantDataClass > getClass() const
Return the Variant's value as TVariantDataClass.
Variant & operator=(const std::string &s)
virtual std::string getOutputValueOnly() const
Returns the formatted content of the Variant as a string.
void setLong(long n, const Ice::Current &c=Ice::emptyCurrent) override
Sets the Variant's value to n.
void setFloat(float f, const Ice::Current &c=Ice::emptyCurrent) override
Sets the Variant's value to f.
std::string getString(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's value as string.
friend std::ostream & operator<<(std::ostream &stream, const Variant &rhs)
void setInt(int n, const Ice::Current &c=Ice::emptyCurrent) override
Sets the Variant's value to n.
virtual VariantPtr clone() const
Returns a copy of the Variant.
Variant(char const var[])
Construct a Variant from a string.
Variant & operator=(long n)
std::enable_if_t<(std::is_standard_layout_v< T > &&std::is_trivial_v< T >)||std::is_same_v< std::string, T >, T > get() const
This getter is only called if a wrong template parameter is given (i.e: the type does not inherit fro...
std::enable_if_t< std::is_base_of_v< VariantDataClass, typename T::element_type >, T > get() const
int getInt(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's value as int.
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
bool getBool(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's value as bool.
void setString(const std::string &s, const Ice::Current &c=Ice::emptyCurrent) override
Sets the Variant's value to s.
Variant(const T *var, typename std::enable_if_t< std::is_base_of_v< VariantDataClass, T > > *t=nullptr)
Construct a Variant from a pointer to a VariantDataClass instance.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > get() const
Template-based getter for the Variant's value.
void setBool(bool b, const Ice::Current &c=Ice::emptyCurrent) override
Sets the Variant's value to b.
std::string getTypeName(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's internal type.
Variant(const T &var, typename std::enable_if_t< std::is_base_of_v< VariantDataClass, T > > *t=nullptr)
Construct a Variant from a reference to a VariantDataClass instance.
static int hashTypeName(const std::string &typeName)
Compute and return a hash value for a given type name.
Variant & operator=(bool b)
Variant(const IceInternal::Handle< T > &var, typename std::enable_if_t< std::is_base_of_v< VariantDataClass, T > > *t=nullptr)
Construct a Variant from an IceHandle to a VariantDataClass instance.
long getLong(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's value as long.
Variant & operator=(double d)
double getDouble(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's value as double.
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
void output(std::ostream &stream) const
Outputs a formatted representation of the Variant to stream.
void setType(VariantTypeId typeId, const Ice::Current &c=Ice::emptyCurrent) override
Sets the Variant's type to typeId.
float getFloat(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's value as float.
bool validate(const Ice::Current &c=Ice::emptyCurrent) const override
Checks if the Variant is initialized and the stored value is valid with respect to the Variant's type...
Variant(const T &var, typename std::enable_if_t<!(std::is_base_of_v< VariantDataClass, T >||std::is_pointer_v< T >)> *t=nullptr)
Construct a Variant from a non-VariantDataClass instance, e.g.
std::enable_if_t<!std::is_base_of_v< VariantDataClass, T > > set(const T &value)
Template-based setter for the Variant's value for non-VariantDataClass-instances.
void setDouble(double d, const Ice::Current &c=Ice::emptyCurrent) override
Sets the Variant's value to d.
const VariantTypeId String
const VariantTypeId Invalid
bool IsBasicType(VariantTypeId id)
const VariantTypeId Double
const VariantTypeId Float
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::ostream & operator<<(std::ostream &os, const PythonApplicationManager::Paths &paths)
std::string GetTypeString(const std::type_info &tinf, bool withoutNamespaceSpecifier=false)
IceInternal::Handle< Variant > VariantPtr
constexpr bool always_false
std::map< std::string, Variant > StringVariantMap