Variant Class Referenceabstract

The Variant class. More...

#include <RobotAPI/libraries/aron/core/data/variant/Variant.h>

+ Inheritance diagram for Variant:

Public Types

using PointerType = VariantPtr
 

Public Member Functions

virtual size_t childrenSize () const =0
 get the children size of a data variant More...
 
virtual VariantPtr cloneAsVariant () const =0
 get a pointer to a copy of this variant More...
 
virtual VariantPtr cloneAsVariant (const Path &newPath) const =0
 
virtual bool fullfillsType (const type::VariantPtr &) const =0
 checks, if the current data variant fullfills the given type More...
 
virtual std::vector< VariantPtrgetChildren () const =0
 get the children of a data variant More...
 
data::Descriptor getDescriptor () const
 getter for the descriptor enum More...
 
virtual std::string getFullName () const =0
 get the full str representation of this variant More...
 
Path getPath () const
 get the path More...
 
virtual std::string getShortName () const =0
 get a short str representation of this variant More...
 
virtual VariantPtr navigateAbsolute (const Path &path) const =0
 naviate absolute More...
 
virtual VariantPtr navigateRelative (const Path &path) const =0
 navigate relative More...
 
virtual bool operator== (const Variant &other) const =0
 
bool operator== (const VariantPtr &other) const
 
std::string pathToString () const
 get the path as string More...
 
virtual type::VariantPtr recalculateType () const =0
 recalculate the type of a data variant. Please not tha the mapping ist NOT bijective, so the calculated type may be wrong More...
 
virtual data::dto::GenericDataPtr toAronDTO () const =0
 convert the variant to the ice representation More...
 
 Variant ()=delete
 
 Variant (const data::Descriptor &descriptor, const Path &path)
 
virtual ~Variant ()=default
 

Static Public Member Functions

static VariantPtr FromAronDTO (const data::dto::GenericDataPtr &, const Path &=Path())
 create a variant from a dto object More...
 
static std::vector< VariantPtrFromAronDTO (const std::vector< data::dto::GenericDataPtr > &, const Path &=Path())
 create a list of variants from a list of dto objects More...
 
static std::vector< data::dto::GenericDataPtr > ToAronDTO (const std::vector< VariantPtr > &)
 return a list of dto objects from a list of variant objects More...
 

Protected Attributes

const data::Descriptor descriptor
 
const Path path
 

Detailed Description

The Variant class.

It represents a data object (a variant containing data). Every data variant inherits from this class. It provdes basic methods for cast/conversion and holds a descriptor, specifying the data type.

If you have a unknown variant and you want to run a specific method based on the type, we suggest to use the visitor pattern (

See also
data/visitor/Visitor.h)

Note that a data variant differs from a type variant. A data variant contains data (e.g. if you have a list the data object contains the list elements) while a type object holds the static type information (e.g. the accepted type of the list). The elements of a list variant without type information may have different types (e.g. element [0] is an int variant whil element [1] is a string variant)

Also note, that while a type variant should always be defined (will not be NULL!), a data object can be NULL. This happens, if a maybe type (e.g. optional) is not set. The underlying ice representation will have a nullptr instead.

Definition at line 60 of file Variant.h.

Member Typedef Documentation

◆ PointerType

Definition at line 63 of file Variant.h.

Constructor & Destructor Documentation

◆ Variant() [1/2]

Variant ( )
delete

◆ Variant() [2/2]

Variant ( const data::Descriptor descriptor,
const Path path 
)
inline

Definition at line 69 of file Variant.h.

◆ ~Variant()

virtual ~Variant ( )
virtualdefault

Member Function Documentation

◆ childrenSize()

virtual size_t childrenSize ( ) const
pure virtual

get the children size of a data variant

Implemented in PrimitiveVariant< AronDataT, ValueT, DerivedT >, Dict, List, and ComplexVariant< AronDataT, DerivedT >.

◆ cloneAsVariant() [1/2]

virtual VariantPtr cloneAsVariant ( ) const
pure virtual

get a pointer to a copy of this variant

Implemented in SpecializedVariantBase< AronDataT, DerivedT >.

◆ cloneAsVariant() [2/2]

◆ FromAronDTO() [1/2]

VariantPtr FromAronDTO ( const data::dto::GenericDataPtr &  a,
const Path path = Path() 
)
static

create a variant from a dto object

Definition at line 39 of file Variant.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromAronDTO() [2/2]

std::vector< VariantPtr > FromAronDTO ( const std::vector< data::dto::GenericDataPtr > &  a,
const Path path = Path() 
)
static

create a list of variants from a list of dto objects

Definition at line 44 of file Variant.cpp.

+ Here is the call graph for this function:

◆ fullfillsType()

virtual bool fullfillsType ( const type::VariantPtr ) const
pure virtual

checks, if the current data variant fullfills the given type

Implemented in NDArray, Dict, List, Int, Bool, Double, Float, Long, and String.

◆ getChildren()

virtual std::vector<VariantPtr> getChildren ( ) const
pure virtual

get the children of a data variant

Implemented in PrimitiveVariant< AronDataT, ValueT, DerivedT >, Dict, List, and ComplexVariant< AronDataT, DerivedT >.

◆ getDescriptor()

data::Descriptor getDescriptor ( ) const
inline

getter for the descriptor enum

Definition at line 103 of file Variant.h.

◆ getFullName()

virtual std::string getFullName ( ) const
pure virtual

get the full str representation of this variant

Implemented in NDArray, Dict, List, Int, Bool, Double, Float, Long, and String.

◆ getPath()

Path getPath ( ) const
inline

get the path

Definition at line 110 of file Variant.h.

+ Here is the caller graph for this function:

◆ getShortName()

virtual std::string getShortName ( ) const
pure virtual

get a short str representation of this variant

Implemented in NDArray, Dict, List, Int, Bool, Double, Float, Long, and String.

◆ navigateAbsolute()

◆ navigateRelative()

◆ operator==() [1/2]

◆ operator==() [2/2]

bool operator== ( const VariantPtr other) const
inline

Definition at line 80 of file Variant.h.

◆ pathToString()

std::string pathToString ( ) const
inline

get the path as string

Definition at line 117 of file Variant.h.

+ Here is the call graph for this function:

◆ recalculateType()

virtual type::VariantPtr recalculateType ( ) const
pure virtual

recalculate the type of a data variant. Please not tha the mapping ist NOT bijective, so the calculated type may be wrong

Implemented in NDArray, Dict, List, Int, Bool, Double, Float, Long, and String.

◆ toAronDTO()

virtual data::dto::GenericDataPtr toAronDTO ( ) const
pure virtual

convert the variant to the ice representation

Implemented in SpecializedVariantBase< AronDataT, DerivedT >.

◆ ToAronDTO()

std::vector< data::dto::GenericDataPtr > ToAronDTO ( const std::vector< VariantPtr > &  a)
static

return a list of dto objects from a list of variant objects

Definition at line 54 of file Variant.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ descriptor

const data::Descriptor descriptor
protected

Definition at line 155 of file Variant.h.

◆ path

const Path path
protected

Definition at line 156 of file Variant.h.


The documentation for this class was generated from the following files: