Gorgon Game Engine
Data Class Reference

Data describes a piece of data. More...

Inheritance diagram for Data:
[legend]

Public Member Functions

 Data ()
 Constructs an invalid data. More...
 
 Data (const Data &other)
 Copy constructor. More...
 
 Data (const Type &type)
 Default value constructor. Value of the data is determined from the type. More...
 
 Data (const Type &type, const Any &data, bool isreference=false, bool isconstant=false)
 Any constructor. Allows both data and type to be specified. More...
 
 Data (const Type *type, const Any &data, bool isreference=false, bool isconstant=false)
 Any constructor. Allows both data and type to be specified. More...
 
 Data (Data &&other)
 Move constructor. More...
 
virtual ~Data ()
 
void Delete () const
 Attempts to delete the data contained in this data. More...
 
Data DeReference ()
 
Any GetData () const
 Returns the data contained in this data element. More...
 
Data GetReference ()
 
const TypeGetType () const
 Returns the type of the data. More...
 
template<class T_ >
std::enable_if<!std::is_pointer< T_ >::value, const typename std::remove_reference< T_ >::type & >::type GetValue () const
 Returns the value of this data in the requested format. More...
 
template<class T_ >
std::enable_if< std::is_pointer< T_ >::value &&std::is_const< typename std::remove_pointer< T_ >::type >::value, T_ >::type GetValue () const
 Returns the value of this data in the requested format. More...
 
template<class T_ >
std::enable_if< std::is_pointer< T_ >::value &&!std::is_const< typename std::remove_pointer< T_ >::type >::value, T_ >::type GetValue () const
 Returns the value of this data in the requested format. More...
 
bool IsConstant () const
 Returns if this data is constant. More...
 
bool IsNull () const
 
bool IsReference () const
 Returns if this data contains a reference. More...
 
bool IsValid () const
 Returns if the data is in a valid state. More...
 
void MakeConstant ()
 Makes this data a constant. More...
 
Dataoperator= (Data)
 Assignment operator. More...
 
bool operator== (const Data &r) const
 
template<class T_ >
std::enable_if< std::is_pointer< T_ >::value, T_ >::type ReferenceValue () const
 Returns the value of this data in the requested format. More...
 
template<class T_ >
std::enable_if<!std::is_pointer< T_ >::value, T_ >::type ReferenceValue () const
 Returns the value of this data in the requested format. More...
 
void RemoveParent ()
 
void SetParent (const Data data)
 
std::string ToString () const
 

Static Public Member Functions

static Data Invalid ()
 Constructs an invalid data object. More...
 

Protected Attributes

Any data
 Stored data. More...
 
bool isconstant
 This data is a constant and should not be changed. More...
 
bool isreference
 Is a reference, data is a ptr to the original type. More...
 
Dataparent
 
const Typetype
 Type of the data. More...
 

Detailed Description

Data describes a piece of data.

It contains boxed data and the type. Additionally, a data can be an array, or reference to a variable. Data can have two tags: ArrayTag and ReferenceTag. It is possible to use both tags together to create an array of references. When a data is a reference, its type indicates which type it refers to. However, the type it refers to could also be an array. This allows two dimensional arrays to exist. However, reference to reference is not valid for now. Data is non-mutable after construction.

Constructor & Destructor Documentation

◆ Data() [1/6]

Data ( )

Constructs an invalid data.

Performing any operation on this data might cause crashes. Never use this constructor unless its absolutely necessary

◆ Data() [2/6]

◆ Data() [3/6]

Data ( Data &&  other)

Move constructor.

References Data::data, Data::isconstant, Data::isreference, Data::parent, and Data::type.

◆ Data() [4/6]

Data ( const Type type,
const Any data,
bool  isreference = false,
bool  isconstant = false 
)

◆ Data() [5/6]

Data ( const Type type,
const Any data,
bool  isreference = false,
bool  isconstant = false 
)

Any constructor. Allows both data and type to be specified.

◆ Data() [6/6]

◆ ~Data()

Member Function Documentation

◆ Delete()

void Delete ( ) const

Attempts to delete the data contained in this data.

References Data::data, Type::Delete(), Data::IsReference(), Type::IsReferenceType(), Any::IsSet(), Any::Pointer(), and Data::type.

◆ DeReference()

◆ GetData()

Any GetData ( ) const

Returns the data contained in this data element.

References Data::data.

◆ GetReference()

◆ GetType()

const Type& GetType ( ) const

Returns the type of the data.

References ASSERT, and Data::type.

◆ GetValue() [1/3]

std::enable_if<!std::is_pointer<T_>::value, const typename std::remove_reference<T_>::type &>::type GetValue ( ) const

Returns the value of this data in the requested format.

References Data::data, Any::Get(), Data::isconstant, and Data::IsReference().

◆ GetValue() [2/3]

std::enable_if<std::is_pointer<T_>::value && std::is_const<typename std::remove_pointer<T_>::type>::value, T_>::type GetValue ( ) const

Returns the value of this data in the requested format.

References Data::data, Any::Get(), Data::isconstant, and Data::IsReference().

◆ GetValue() [3/3]

std::enable_if<std::is_pointer<T_>::value && !std::is_const<typename std::remove_pointer<T_>::type>::value, T_>::type GetValue ( ) const

Returns the value of this data in the requested format.

References Data::data, Any::Get(), Data::isconstant, and Data::IsReference().

◆ Invalid()

static Data Invalid ( )
static

Constructs an invalid data object.

Data object does not perform validity check therefore, use of this function should be very limited.

◆ IsConstant()

bool IsConstant ( ) const

Returns if this data is constant.

References Data::isconstant.

◆ IsNull()

bool IsNull ( ) const

◆ IsReference()

bool IsReference ( ) const

Returns if this data contains a reference.

References ASSERT, Data::isreference, Type::IsReferenceType(), and Data::type.

◆ IsValid()

bool IsValid ( ) const

Returns if the data is in a valid state.

References Data::type.

◆ MakeConstant()

◆ operator=()

◆ operator==()

bool operator== ( const Data r) const

References Type::Compare(), and Data::type.

◆ ReferenceValue() [1/2]

std::enable_if<std::is_pointer<T_>::value, T_>::type ReferenceValue ( ) const

Returns the value of this data in the requested format.

Requested type should ideally be a reference. Though this is not a requirement.

References ASSERT, Data::data, Any::Get(), Data::IsReference(), and Data::type.

◆ ReferenceValue() [2/2]

std::enable_if<!std::is_pointer<T_>::value, T_>::type ReferenceValue ( ) const

Returns the value of this data in the requested format.

Requested type should ideally be a reference. Though this is not a requirement.

References ASSERT, Data::data, Any::Get(), Data::IsReference(), and Data::type.

◆ RemoveParent()

void RemoveParent ( )

References Data::parent.

◆ SetParent()

void SetParent ( const Data  data)

◆ ToString()

std::string ToString ( ) const

References ASSERT, Type::ToString(), and Data::type.

Member Data Documentation

◆ data

Any data
protected

Stored data.

◆ isconstant

bool isconstant
protected

This data is a constant and should not be changed.

◆ isreference

bool isreference
protected

Is a reference, data is a ptr to the original type.

◆ parent

Data* parent
protected

◆ type

const Type* type
protected

Type of the data.


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