SCENE C++ API  2.0.22
Public Member Functions | List of all members
LSAttribute Class Reference

Storage class which may contain different common data types. More...

#include <lsattribute.h>

+ Inheritance diagram for LSAttribute:

Public Member Functions

 LSAttribute ()
 Constructs an invalid attribute. More...
 
virtual ~LSAttribute ()
 Destroys the attribute. More...
 
 LSAttribute (const LSAttribute &attribute)
 Constructs a attribute containing a copy of the attribute attribute. More...
 
template<class T >
 LSAttribute (const T &value)
 Constructs an LSAttribute of the type defined by the constructor parameter. More...
 
bool isValid () const
 Checks whether the attribute is valid. More...
 
template<class T >
getValue () const
 Gets the attribute value. More...
 
template<class T >
void setValue (const T &value)
 Sets the attribute value. More...
 
LSString toString () const
 Gets the attribute value as a string representation. More...
 
bool fromString (LSString value)
 Sets the attribute value based on the string value. More...
 
LSString getType () const
 Gets the type of the attribute value. More...
 
bool hasType (LSString type) const
 Checks whether the attribute value is of a given type. More...
 
template<class T >
bool hasType () const
 Checks whether the attribute value is of a given type. More...
 
LSAttributeoperator= (const LSAttribute &from)
 Assignment Operator. More...
 
void * operator new (size_t tSize)
 Default allocation function. More...
 
void operator delete (void *p)
 Default deallocation function. More...
 

Detailed Description

Storage class which may contain different common data types.

The LSAttribute class is a storage class which is able to store a single value of type getType(). All types can also be serialized to strings and read from strings using the toString() and fromString() methods.

Possible value types are:

Version
SCENE API Version 2.0.0.

Constructor & Destructor Documentation

◆ LSAttribute() [1/3]

Constructs an invalid attribute.

Version
SCENE API Version 2.0.0.

◆ ~LSAttribute()

virtual ~LSAttribute ( )
virtual

Destroys the attribute.

Version
SCENE API Version 2.0.0.

◆ LSAttribute() [2/3]

LSAttribute ( const LSAttribute attribute)

Constructs a attribute containing a copy of the attribute attribute.

Version
SCENE API Version 2.0.0.

◆ LSAttribute() [3/3]

LSAttribute ( const T &  value)

Constructs an LSAttribute of the type defined by the constructor parameter.

For a list of possible value types see value types.

Version
SCENE API Version 2.0.0.

Member Function Documentation

◆ isValid()

bool isValid ( ) const

Checks whether the attribute is valid.

Returns
true if the attribute is valid, false otherwise.
Version
SCENE API Version 2.0.0.

◆ getValue()

T getValue ( ) const

Gets the attribute value.

If the attribute value isn't of the type T a default instance of the type T will be returned. You can test whether the attribute value is of a certain type using the hasType() function. For a list of possible value types see value types.

Returns
The attribute value if it could be converted, otherwise a default constructed instance of the template type.
Version
SCENE API Version 2.0.0.

◆ setValue()

void setValue ( const T &  value)

Sets the attribute value.

If a value of a different type than the current attribute type is assigned the attribute type will change. For a list of possible value types see value types.

Version
SCENE API Version 2.0.0.

◆ toString()

LSString toString ( ) const

Gets the attribute value as a string representation.

Returns
The string representation of the attribute value.
Version
SCENE API Version 2.0.0.

◆ fromString()

bool fromString ( LSString  value)

Sets the attribute value based on the string value.

Returns
true if the value could be set based on the given string representation, false otherwise.
Version
SCENE API Version 2.0.0.

◆ getType()

LSString getType ( ) const

Gets the type of the attribute value.

Returns
The type of the attribute value.
Version
SCENE API Version 2.0.0.

◆ hasType() [1/2]

bool hasType ( LSString  type) const

Checks whether the attribute value is of a given type.

Returns
true if the attribute value has the given type, false otherwise.
Version
SCENE API Version 2.0.0.

◆ hasType() [2/2]

bool hasType ( ) const

Checks whether the attribute value is of a given type.

The template type T is used for the check. For a list of possible value types see value types.

Version
SCENE API Version 2.0.0.

◆ operator=()

LSAttribute& operator= ( const LSAttribute from)

Assignment Operator.

Assigns the value of the given attribute to this attribute. This also sets the attribute type of this attribute to the type of the attribute from which the values is assigned.

Version
SCENE API Version 2.0.0.

◆ operator new()

void* operator new ( size_t  tSize)

Default allocation function.

Overloaded in order to always allocate LSString objects in the context of this module.

Version
SCENE API Version 2.0.0.

◆ operator delete()

void operator delete ( void *  p)

Default deallocation function.

Overloaded in order to always deallocate LSString objects in the context of this module.

Version
SCENE API Version 2.0.0.