![]() |
Gorgon Game Engine
|
Data describes a piece of data. More...
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 Type & | GetType () 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... | |
Data & | operator= (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... | |
Data * | parent |
const Type * | type |
Type of the data. More... | |
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.
Data | ( | ) |
Constructs an invalid data.
Performing any operation on this data might cause crashes. Never use this constructor unless its absolutely necessary
Copy constructor.
References Data::Data(), Data::data, VirtualMachine::Exists(), VirtualMachine::Get(), ReferenceCounter::Increase(), Data::isconstant, Data::IsReference(), Data::isreference, Type::IsReferenceType(), Data::parent, Any::Pointer(), VirtualMachine::References, and Data::type.
Move constructor.
References Data::data, Data::isconstant, Data::isreference, Data::parent, and Data::type.
Any constructor. Allows both data and type to be specified.
References ASSERT, Data::data, VirtualMachine::Exists(), VirtualMachine::Get(), ReferenceCounter::Increase(), Data::IsReference(), Any::Pointer(), VirtualMachine::References, and Data::type.
Any constructor. Allows both data and type to be specified.
Default value constructor. Value of the data is determined from the type.
References Data::data, VirtualMachine::Exists(), VirtualMachine::Get(), Type::GetDefaultValue(), ReferenceCounter::Increase(), Type::IsReferenceType(), Any::Pointer(), VirtualMachine::References, and Data::type.
|
virtual |
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.
Data DeReference | ( | ) |
Any GetData | ( | ) | const |
Returns the data contained in this data element.
References Data::data.
Data GetReference | ( | ) |
const Type& GetType | ( | ) | const |
Returns the type of the data.
References ASSERT, and Data::type.
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().
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().
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().
|
static |
Constructs an invalid data object.
Data object does not perform validity check therefore, use of this function should be very limited.
bool IsConstant | ( | ) | const |
Returns if this data is constant.
References Data::isconstant.
bool IsNull | ( | ) | const |
References ASSERT, Data::data, Type::IsReferenceType(), Any::Pointer(), and Data::type.
bool IsReference | ( | ) | const |
Returns if this data contains a reference.
References ASSERT, Data::isreference, Type::IsReferenceType(), and Data::type.
bool IsValid | ( | ) | const |
Returns if the data is in a valid state.
References Data::type.
void MakeConstant | ( | ) |
Makes this data a constant.
References ASSERT, RTTH::ConstPtrType, RTTH::ConstType, Data::data, Data::isconstant, Data::IsReference(), Any::SetType(), Data::type, and Type::TypeInterface.
Assignment operator.
References Data::data, ReferenceCounter::Decrease(), VirtualMachine::Exists(), VirtualMachine::Get(), Data::isconstant, Data::IsReference(), Data::isreference, Type::IsReferenceType(), Any::IsSet(), Data::parent, Any::Pointer(), VirtualMachine::References, and Data::type.
bool operator== | ( | const Data & | r | ) | const |
References Type::Compare(), and Data::type.
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.
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.
void RemoveParent | ( | ) |
References Data::parent.
void SetParent | ( | const Data | data | ) |
References Data::Data(), Data::data, and Data::parent.
std::string ToString | ( | ) | const |
References ASSERT, Type::ToString(), and Data::type.
|
protected |
Stored data.
|
protected |
This data is a constant and should not be changed.
|
protected |
Is a reference, data is a ptr to the original type.
|
protected |