Gorgon Game Engine
Variable Class Reference

This class represents a variable. It contains the data and the name of the variable. More...

Inheritance diagram for Variable:
[legend]

Public Member Functions

 Variable (const std::string &name, const Type &type)
 Constructor that sets the name, and type of the variable. More...
 
 Variable (const std::string &name, const Type &type, const Any &value)
 Constructor that sets the name, type and value of the variable. More...
 
 Variable (const std::string &name="", const Data &data=Data::Invalid())
 Creates an invalid variable. More...
 
std::string GetName () const
 Returns the name of the variable. More...
 
bool IsReferenceAssigned () const
 
void Set (Any value)
 Sets the data contained in this variable without changing its type. More...
 
void Set (const Data &value)
 Sets the data contained in this variable. More...
 
void Set (const Type &type, Any value)
 Sets the data contained in this variable by modifying its type. More...
 
void SetReferenceable (const Data &value)
 Sets the data contained in this variable. More...
 
- Public Member Functions inherited from Data
 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
 

Additional Inherited Members

- Static Public Member Functions inherited from Data
static Data Invalid ()
 Constructs an invalid data object. More...
 
- Protected Attributes inherited from Data
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

This class represents a variable. It contains the data and the name of the variable.

Constructor & Destructor Documentation

◆ Variable() [1/3]

Variable ( const std::string &  name = "",
const Data data = Data::Invalid() 
)

Creates an invalid variable.

◆ Variable() [2/3]

Variable ( const std::string &  name,
const Type type,
const Any value 
)

Constructor that sets the name, type and value of the variable.

Unless this variable is declared inside an executing code, definedin should be left nullptr.

◆ Variable() [3/3]

Variable ( const std::string &  name,
const Type type 
)

Constructor that sets the name, and type of the variable.

Default value of the specified type is used as value. Unless this variable is declared inside an executing code, definedin should be left nullptr.

Member Function Documentation

◆ GetName()

std::string GetName ( ) const

Returns the name of the variable.

◆ IsReferenceAssigned()

bool IsReferenceAssigned ( ) const

◆ Set() [1/3]

void Set ( Any  value)

Sets the data contained in this variable without changing its type.

References Data::data, Data::isconstant, Data::isreference, Data::parent, and Any::Swap().

◆ Set() [2/3]

void Set ( const Data value)

Sets the data contained in this variable.

References Data::operator=().

◆ Set() [3/3]

void Set ( const Type type,
Any  value 
)

Sets the data contained in this variable by modifying its type.

Also this function resets the tags unless they are re-specified

References Data::data, Data::isconstant, Data::isreference, Data::parent, Any::Swap(), and Data::type.

◆ SetReferenceable()

void SetReferenceable ( const Data value)

Sets the data contained in this variable.

If it is a reference, the value that is referenced is updated

References Type::Assign(), VirtualMachine::Get(), Data::GetType(), ReferenceCounter::Increase(), Data::isconstant, Data::IsReference(), and VirtualMachine::References.


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