SBCMetaValue Class Reference

This class represents values. More...

Classes

class  ValueFactory< true, U >
 Partial specialization for values with proxies. More...
 

Constructors and destructors

template<typename U >
 SBCMetaValue (U u)
 Constructs a value.
 
 SBCMetaValue (const SBCMetaValue &u)
 Constructs a value.
 
 SBCMetaValue ()
 Constructs a value.
 
 ~SBCMetaValue ()
 Destructs the value.
 

Operators

SBCMetaValueoperator= (const SBCMetaValue &value)
 Assignment operator.
 

Type attributes

bool isEnumType () const
 Returns true if the value is of an enum type.
 
bool isClassType () const
 Returns true if the value is of a class type.
 
bool isFundamentalType () const
 Returns true if the value is of a fundamental type. More...
 
bool isRegisteredType () const
 Returns true if the value is of a registered type.
 
bool isConstType () const
 Returns true if the value is of a const type.
 
bool isVolatileType () const
 Returns true if the value is of a volatile type.
 
bool isReferenceType () const
 Returns true if the value is of a reference type.
 
bool isArrayType () const
 Returns true if the value is of an array type.
 
bool isPointerType () const
 Returns true if the value is of a pointer type.
 
bool isPointerToMemberType () const
 Returns true if the value is of a pointer to member type.
 
bool isFunctionType () const
 Returns true if the value is of a function type.
 
bool isPointerToFunctionType () const
 Returns true if the value is of a pointer to function type.
 
bool isPointerToMemberFunctionType () const
 Returns true if the value is of a pointer to member function type.
 
bool hasBaseType () const
 Returns true if the value is of a type that has a base type.
 
unsigned int getNumberOfParameters () const
 Returns the number of parameters of a function type.
 

Type names

std::string getTypeName () const
 Returns the type name. More...
 
std::string getParentTypeName () const
 Returns the parent type name. More...
 
std::string getRootTypeName () const
 Returns the root type name. More...
 
std::string getBaseTypeName () const
 Returns the base type name. More...
 
std::string getOutputTypeName () const
 Returns the output type name. More...
 
std::string getClassTypeName () const
 Returns the class type name. More...
 
std::string getParameterTypeName (unsigned int i) const
 Returns the type name of parameter i. More...
 

Short type names

std::string getShortTypeName () const
 Returns the short type name. More...
 
std::string getShortParentTypeName () const
 Returns the short parent type name. More...
 
std::string getShortRootTypeName () const
 Returns the short root type name. More...
 
std::string getShortBaseTypeName () const
 Returns the short base type name. More...
 
std::string getShortOutputTypeName () const
 Returns the short output type name. More...
 
std::string getShortClassTypeName () const
 Returns the short class type name. More...
 
std::string getShortParameterTypeName (unsigned int i) const
 Returns the short type name of parameter i. More...
 

Dependent types

SBCMetaValue getParentType () const
 Returns the parent type. More...
 
SBCMetaValue getRootType () const
 Returns the root type. More...
 
SBCMetaValue getBaseType () const
 Returns the base type. More...
 
SBCMetaValue getOutputType () const
 Returns the output type. More...
 
SBCMetaValue getClassType () const
 Returns the class type. More...
 
SBCMetaValue getParameterType (unsigned int i) const
 Returns the type of parameter i. More...
 

Identity

bool isValid () const
 Returns whether the value is valid and can be dereferenced with getValue. More...
 
SBCMetaValueBasegetValue () const
 Returns the value. More...
 
SBCContainerUUID getTypeUUID () const
 Returns the type UUID
More...
 

Interface

virtual SBCClassProxygetProxy () const
 Returns the proxy of the value.
 
virtual SBCMetaValue call (const std::string &functionName, const SBCMetaValue &t0=SBCMetaValue(), const SBCMetaValue &t1=SBCMetaValue(), const SBCMetaValue &t2=SBCMetaValue(), const SBCMetaValue &t3=SBCMetaValue(), const SBCMetaValue &t4=SBCMetaValue(), const SBCMetaValue &t5=SBCMetaValue(), const SBCMetaValue &t6=SBCMetaValue(), const SBCMetaValue &t7=SBCMetaValue(), const SBCMetaValue &t8=SBCMetaValue(), const SBCMetaValue &t9=SBCMetaValue(), const SBCMetaValue &t10=SBCMetaValue(), const SBCMetaValue &t11=SBCMetaValue(), const SBCMetaValue &t12=SBCMetaValue(), const SBCMetaValue &t13=SBCMetaValue(), const SBCMetaValue &t14=SBCMetaValue(), const SBCMetaValue &t15=SBCMetaValue()) const
 Calls the function functionName of the value with arguments t0, t1, ..., t15.
 
virtual SBCMetaValue constCall (const std::string &functionName, const SBCMetaValue &t0=SBCMetaValue(), const SBCMetaValue &t1=SBCMetaValue(), const SBCMetaValue &t2=SBCMetaValue(), const SBCMetaValue &t3=SBCMetaValue(), const SBCMetaValue &t4=SBCMetaValue(), const SBCMetaValue &t5=SBCMetaValue(), const SBCMetaValue &t6=SBCMetaValue(), const SBCMetaValue &t7=SBCMetaValue(), const SBCMetaValue &t8=SBCMetaValue(), const SBCMetaValue &t9=SBCMetaValue(), const SBCMetaValue &t10=SBCMetaValue(), const SBCMetaValue &t11=SBCMetaValue(), const SBCMetaValue &t12=SBCMetaValue(), const SBCMetaValue &t13=SBCMetaValue(), const SBCMetaValue &t14=SBCMetaValue(), const SBCMetaValue &t15=SBCMetaValue()) const
 Calls the const function functionName of the value with arguments t0, t1, ..., t15.
 
virtual SBCMetaValue get (const std::string &attributeName) const
 Returns the value of attribute attributeName for this value.
 
virtual void set (const std::string &attributeName, const SBCMetaValue &value, const SBCMetaValue &size=0) const
 Sets the value of attribute attributeName for this value to value.
 
virtual bool has (const std::string &attributeName) const
 Returns whether attribute attributeName exists in the value and has a value.
 
virtual void clear (const std::string &attributeName) const
 Clears attribute attributeName from the value when possible.
 
virtual unsigned int getSize (const std::string &attributeName) const
 Returns the size of attribute attributeName in the value when relevant.
 

Wrapping

template<typename U >
static SBCMetaValue buildType ()
 
static SBCMetaValue buildValue ()
 
template<typename U >
static SBCMetaValue buildValue (U u)
 

Casting

template<typename U >
 operator U ()
 
template<typename U >
static bool canCastFrom (const SBCMetaValue &fromValue)
 
template<typename U >
static U castFrom (const SBCMetaValue &fromValue)
 

Detailed Description

This class is the base class of value holders, and a key component of the introspection mechanism. In particular, it is the direct base class of the template class SBCMetaValueType, used to contain type information, which is itself the direct base class of the template class SBCMetaValueHolder, used to hold values.

Assume a SAMSON Extension called SEElement defines a class A, and another SAMSON Extension called SEOtherElement wants to use it. If the SAMSON Extension called SEOtherElement does not have access to the declaration of class A (typically provided in a header file included in SEElement), it cannot use the symbol A in its source code. For example, if the source code of SEOtherElement contained the line:

A* a = new A();

the compiler would complain that the symbol A is not defined.

In order to provide access to exposed classes, SAMSON uses a mechanism to hold values (for example, pointers to objects) in a uniform way. In the example above, the constructor exposed in the SAMSON Extension SEElement returns a value holder that stores a pointer to the new instance of class A:

return new SBValueHolder<A*>(new A());

and the SAMSON Extension SEOtherElement sees this value holder as a pointer to a SBValue (the base class of SBValueHolder<A*>):

SBValue* objectHolder = classProxy->createInstance();

This class is able to provide information about a hold type or a hold value.

Short name: SBValue

See also
SBCMetaType
SBCMetaValueType
SBCMetaValueHolder
Introspection

Member Function Documentation

◆ getBaseType()

SBCMetaValue SBCMetaValue::getBaseType ( ) const

This function returns the base type, i.e. an instance of the template class SBCMetaValueType which contains type information about the base type of this type. For example, the base type of SBMStructuralModelNodeAtom is SBMStructuralModelNodeParticle.

Note that this function returns a type. If a string is needed, use SBCMetaValue::getBaseTypeName().

See also
SBCMetaValue::getBaseTypeName()

◆ getBaseTypeName()

std::string SBCMetaValue::getBaseTypeName ( ) const

This function returns the type name of the base type of T. For example, the base type name of SBMStructuralModelNodeAtom is "SBMStructuralModelNodeParticle".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getBaseType().

See also
SBCMetaValue::getBaseType()

◆ getClassType()

SBCMetaValue SBCMetaValue::getClassType ( ) const

This function returns the class type, i.e. an instance of the template class SBCMetaValueType which contains type information about the class type of this type, when the type is a pointer to a member or a pointer to a member function. For example, the class type name of &SBMStructuralModelNodeAtom::clearName is SBMStructuralModelNodeAtom.

Note that this function returns a type. If a string is needed, use SBCMetaValue::getClassTypeName().

See also
SBCMetaValue::getClassTypeName()

◆ getClassTypeName()

std::string SBCMetaValue::getClassTypeName ( ) const

This function returns the type name of the class associated to T, when T is a pointer to a member or a pointer to a member function ("void" otherwise). For example, the class type name of &SBMStructuralModelNodeAtom::clearName is "SBMStructuralModelNodeAtom".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getClassType().

See also
SBCMetaValue::getClassType()

◆ getOutputType()

SBCMetaValue SBCMetaValue::getOutputType ( ) const

This function returns the output type, i.e. an instance of the template class SBCMetaValueType which contains type information about the output type of this type, when the type is a function. For example, the output type name of SBMStructuralModelNodeAtom* getFirstAtom() is SBMStructuralModelNodeAtom.

Note that this function returns a type. If a string is needed, use SBCMetaValue::getOutputTypeName().

See also
SBCMetaValue::getOutputTypeName()

◆ getOutputTypeName()

std::string SBCMetaValue::getOutputTypeName ( ) const

This function returns the type name of the output type of T, when T is a function. For example, the output type name of SBMStructuralModelNodeAtom* getFirstAtom() is "SBMStructuralModelNodeAtom*".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getOutputType().

See also
SBCMetaValue::getOutputType()

◆ getParameterType()

SBCMetaValue SBCMetaValue::getParameterType ( unsigned int  i) const

This function returns the type of parameter i, , i.e. an instance of the template class SBCMetaValueType which contains type information about the type of parameter i, when the type is a function. For example, the type name of parameter 2 of myFunction(int, double, const SBMStructuralModelNodeAtom*) is const SBMStructuralModelNodeAtom*.

Note that this function returns a type. If a string is needed, use SBCMetaValue::getParameterTypeName().

See also
SBCMetaValue::getParameterTypeName()

◆ getParameterTypeName()

std::string SBCMetaValue::getParameterTypeName ( unsigned int  i) const

This function returns the type name of parameter i of type T, when T is a function ("void" otherwise). For example, the type name of parameter 2 of myFunction(int, double, const SBMStructuralModelNodeAtom*) is "const SBMStructuralModelNodeAtom*".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getParameterType().

See also
SBCMetaValue::getParameterType()

◆ getParentType()

SBCMetaValue SBCMetaValue::getParentType ( ) const

This function returns the parent type, i.e. an instance of the template class SBCMetaValueType which contains type information about the parent type of this type. For example, the parent type of int* is int.

Note that this function returns a type. If a string is needed, use SBCMetaValue::getParentTypeName().

See also
SBCMetaValue::getParentTypeName()

◆ getParentTypeName()

std::string SBCMetaValue::getParentTypeName ( ) const

This function returns the type name of the parent type of T. For example, the parent type name of int* is "int".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getParentType().

See also
SBCMetaValue::getParentType()
SBCMetaValue::getRootTypeName()

◆ getRootType()

SBCMetaValue SBCMetaValue::getRootType ( ) const

This function returns the root type, i.e. an instance of the template class SBCMetaValueType which contains type information about the root type of this type. For example, the root type of const std::string& is std::string.

Note that this function returns a type. If a string is needed, use SBCMetaValue::getRootTypeName().

See also
SBCMetaValue::getRootTypeName()

◆ getRootTypeName()

std::string SBCMetaValue::getRootTypeName ( ) const

This function returns the type name of the root type of T. For example, the root type name of const std::string& is "std::string".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getRootType().

See also
SBCMetaValue::getRootType()
SBCMetaValue::getParentTypeName()

◆ getShortBaseTypeName()

std::string SBCMetaValue::getShortBaseTypeName ( ) const

This function returns the short type name of the base type of T. For example, the short base type name of SBMStructuralModelNodeAtom is "SBStructuralParticle".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getBaseType().

See also
SBCMetaValue::getBaseType()

◆ getShortClassTypeName()

std::string SBCMetaValue::getShortClassTypeName ( ) const

This function returns the short type name of the class associated to T, when T is a pointer to a member or a pointer to a member function ("void" otherwise). For example, the short class type name of &SBMStructuralModelNodeAtom::clearName is "SBAtom*".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getClassType().

See also
SBCMetaValue::getClassType()

◆ getShortOutputTypeName()

std::string SBCMetaValue::getShortOutputTypeName ( ) const

This function returns the short type name of the output type of T, when T is a function. For example, the short output type name of SBMStructuralModelNodeAtom* getFirstAtom() is "SBAtom".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getOutputType().

See also
SBCMetaValue::getOutputType()

◆ getShortParameterTypeName()

std::string SBCMetaValue::getShortParameterTypeName ( unsigned int  i) const

This function returns the short type name of parameter i of type T, when T is a function ("void" otherwise). For example, the short type name of parameter 2 of myFunction(int, double, const SBMStructuralModelNodeAtom*) is "const SBAtom*".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getParameterType().

See also
SBCMetaValue::getParameterType()

◆ getShortParentTypeName()

std::string SBCMetaValue::getShortParentTypeName ( ) const

This function returns the short type name of the parent type of T. For example, the short parent type name of SBMStructuralModelNodeAtom* is "SBAtom".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getParentType().

See also
SBCMetaValue::getParentType()
SBCMetaValue::getShortRootTypeName()

◆ getShortRootTypeName()

std::string SBCMetaValue::getShortRootTypeName ( ) const

This function returns the type name of the root type of T. For example, the short root type name of const SBMStructuralModelNodeAtom& is "SBAtom".

Note that this function returns a string. If a type is needed, use SBCMetaValue::getRootType().

See also
SBCMetaValue::getRootType()
SBCMetaValue::getShortParentTypeName()

◆ getShortTypeName()

std::string SBCMetaValue::getShortTypeName ( ) const

When the type T is fundamental, this function returns a string containing the fundamental type (e.g. "unsigned int"). When T is registered, this function returns its short type name. Else, this function recursively decomposes the type in order to provide a string describing it, but using short names (e.g. "const SBAtom*").

◆ getTypeName()

std::string SBCMetaValue::getTypeName ( ) const

When the type T is fundamental, this function returns a string containing the fundamental type (e.g. "unsigned int"). When T is registered, this function returns its type name. Else, this function recursively decomposes the type in order to provide a string describing it (e.g. "const SBMStructuralModelNodeAtom*").

◆ getTypeUUID()

SBCContainerUUID SBCMetaValue::getTypeUUID ( ) const

If the type is registered, this function returns the associated UUID. Else, the function returns an invalid UUID.

◆ getValue()

SBCMetaValueBase * SBCMetaValue::getValue ( ) const

This function returns the pointer to the held value base.

◆ isFundamentalType()

bool SBCMetaValue::isFundamentalType ( ) const

Returns true if the value is of a fundamental type (void, bool, char, signed char, unsigned char, wchar_t, short, unsigned short, int, unsigned int, long, unsigned long, float, double or long double).

◆ isValid()

bool SBCMetaValue::isValid ( ) const

This function returns whether the value is valid and can be dereferenced with getValue.

virtual SBValue createInstance(const SBValue &t0=SBValue(), const SBValue &t1=SBValue(), const SBValue &t2=SBValue(), const SBValue &t3=SBValue(), const SBValue &t4=SBValue(), const SBValue &t5=SBValue(), const SBValue &t6=SBValue(), const SBValue &t7=SBValue(), const SBValue &t8=SBValue(), const SBValue &t9=SBValue(), const SBValue &t10=SBValue(), const SBValue &t11=SBValue(), const SBValue &t12=SBValue(), const SBValue &t13=SBValue(), const SBValue &t14=SBValue(), const SBValue &t15=SBValue()) const
Creates an instance of the class with arguments t0, t1, ..., t15.
Definition: SBCClassProxy.cpp:97
This class represents values.
Definition: SBCMetaValue.hpp:23