Gorgon Game Engine
Data Class Reference
Inheritance diagram for Data:
[legend]

Public Types

using ConstIterator = Containers::Collection< DataItem >::ConstIterator
 Constant iterator for the data resource. More...
 
using Iterator = Containers::Collection< DataItem >::Iterator
 Iterator for the data resource. More...
 

Public Member Functions

 Data ()
 Creates an empty Data. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
 Data (const T_ &values, const R_ &reflectionobj=T_::Reflection())
 This constructor accepts a reflected struct and turns it into a resource data. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
 Data (const T_ &values, const std::string &prefix, const R_ &reflectionobj=T_::Reflection())
 This constructor accepts a reflected struct and turns it into a resource data. More...
 
void Add (DataItem &item)
 Adds the given data item to this data resource. Ownership of the item is transferred to this Data. More...
 
template<class T_ >
std::enable_if< std::is_base_of< Base, T_ >::value, void >::type Append (const std::string &name, T_ &value)
 Appends the given resource object to the end of this data resource with the specified name. More...
 
template<class T_ >
std::enable_if<!std::is_base_of< Base, T_ >::value, void >::type Append (const std::string &name, T_ value)
 Appends the given data to the end of this data resource with the specified name. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
std::enable_if< R_::IsGorgonReflection, void >::type Append (const T_ &values, const R_ &reflectionobj=T_::Reflection())
 This function accepts a reflected struct and appends it to the resource data. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
std::enable_if< R_::IsGorgonReflection, void >::type Append (const T_ &values, const std::string &prefix, const R_ &reflectionobj=T_::Reflection())
 This function accepts a reflected struct and appends it to the resource data. More...
 
template<class T_ >
std::enable_if< std::is_base_of< Base, T_ >::value, void >::type Append (T_ &value)
 Appends the given resource object to the end of this data resource. More...
 
template<class T_ >
std::enable_if<!std::is_base_of< Base, T_ >::value &&!T_::ReflectionType::IsGorgonReflection, void >::type Append (T_ value)
 Appends the given data to the end of this data resource. More...
 
Iterator begin ()
 Can be used to iterate over data objects. More...
 
ConstIterator begin () const
 Can be used to iterate over data objects. More...
 
Iterator end ()
 Can be used to iterate over data objects. More...
 
ConstIterator end () const
 Can be used to iterate over data objects. More...
 
int FindIndex (const std::string &name) const
 Returns the index of the data item with the given name. More...
 
template<class T_ >
T_ Get (const std::string &name) const
 Returns the data with the given name; use GetObject in order to get resource objects. More...
 
template<class T_ >
T_ Get (int index) const
 Returns the data with the given index; use GetObject in order to get resource objects. More...
 
template<>
int Get (int index) const
 
template<>
float Get (int index) const
 
int GetCount () const
 Returns the number data items in this data resource. More...
 
virtual GID::Type GetGID () const override
 This function shall return Gorgon ID of this resource. More...
 
DataItemGetItem (const std::string &name) const
 Returns the data item with the given name. More...
 
DataItemGetItem (int index) const
 Returns the data item with the given index. More...
 
template<class T_ >
T_ & GetObject (const std::string &name) const
 Returns the resource object with the given name. More...
 
template<class T_ >
T_ & GetObject (int index) const
 Returns the resource object at the given index. More...
 
void Insert (Base &value, int before)
 Inserts a data item to the given position. More...
 
void Insert (Base *value, int before)
 Inserts a data item to the given position. More...
 
void Insert (const char *value, int before)
 Inserts a data item to the given position. More...
 
void Insert (const std::string &name, Base &value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, Base *value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, const char *value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, const std::string &value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, float value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, Geometry::Bounds value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, Geometry::Margin value, int before)
 
void Insert (const std::string &name, Geometry::Point value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, Geometry::Pointf value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, Geometry::Rectangle value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, Geometry::Size value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &name, int value, int before)
 Inserts a data item to the given position with the specified name. More...
 
void Insert (const std::string &value, int before)
 Inserts a data item to the given position. More...
 
void Insert (DataItem &item, int before)
 Inserts the given data item to this data resource before the specified index. Ownership of the item is transferred to this Data. More...
 
void Insert (float value, int before)
 Inserts a data item to the given position. More...
 
void Insert (Geometry::Bounds value, int before)
 Inserts a data item to the given position. More...
 
void Insert (Geometry::Margin value, int before)
 Inserts a data item to the given position. More...
 
void Insert (Geometry::Point value, int before)
 Inserts a data item to the given position. More...
 
void Insert (Geometry::Pointf value, int before)
 Inserts a data item to the given position. More...
 
void Insert (Geometry::Rectangle value, int before)
 Inserts a data item to the given position. More...
 
void Insert (Geometry::Size value, int before)
 Inserts a data item to the given position. More...
 
void Insert (int value, int before)
 Inserts a data item to the given position. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
T_ NamedTransform (const R_ &reflectionobj=T_::Reflection())
 Transforms the members of this resource data to the given struct. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
T_ NamedTransform (const std::string &prefix, const R_ &reflectionobj=T_::Reflection())
 Transforms the members of this resource data to the given struct. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
T_ NamedTransform_KeepObjects (const R_ &reflectionobj=T_::Reflection()) const
 Transforms the members of this resource data to the given struct. More...
 
template<class T_ , class R_ = typename T_::ReflectionType>
T_ NamedTransform_KeepObjects (const std::string &prefix, const R_ &reflectionobj=T_::Reflection()) const
 Transforms the members of this resource data to the given struct. More...
 
DataItemRelease (const std::string &name)
 Releases the data item with the given name. The data item will not be destroyed. More...
 
DataItemRelease (int index)
 Releases the data item with the given index. The data item will not be destroyed. More...
 
void Remove (const std::string &name)
 Removes the item with the given name. The data item will be destroyed. More...
 
void Remove (int index)
 Removes the item at the given index. The data item will be destroyed. More...
 
- Public Member Functions inherited from Base
 Base ()
 Default constructor. More...
 
const Containers::Collection< Base >::ConstIterator begin () const
 Allows easy iteration through range based fors. More...
 
const Containers::Collection< Base >::ConstIterator cbegin () const
 Beginning of children. More...
 
const Containers::Collection< Base >::ConstIterator cend () const
 End of children. More...
 
bool DeleteResource ()
 Safely deletes the resource. More...
 
virtual void Discard ()
 This function shall discard any transitional data which is not vital after Prepare function is issued. More...
 
const Containers::Collection< Base >::ConstIterator end () const
 Allows easy iteration through range based fors. More...
 
virtual SGuid GetGuid () const
 Returns the guid of the object. More...
 
const std::string & GetName () const
 Returns the name of this object. More...
 
BaseGetParent () const
 Returns the parent. If no parent set, this function throws std::runtime_error. More...
 
BaseGetParentPtr () const
 Returns the pointer to the parent. This function may return nullptr. More...
 
const BaseGetRoot () const
 Returns the root of this resource. More...
 
bool HasParent () const
 Returns whether this object has a parent. More...
 
virtual bool IsEqual (const SGuid &guid) const
 This function tests whether this object has the given SGuid. More...
 
virtual void Prepare ()
 This function shall prepare this resource to be used after resource is loaded. More...
 
virtual void Resolve (File &file)
 This function shall resolve links or similar constructs. More...
 
void Save (Writer &writer)
 Saves this object into the given writer. The writer should be open prior to this call. More...
 
virtual void SetGuid (SGuid guid)
 Changes the guid of the object. More...
 
virtual void SetName (const std::string &name)
 Sets the name of the object. More...
 

Static Public Member Functions

static DataLoadResource (std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
 Loads a data resource. More...
 

Protected Member Functions

 ~Data ()
 Destructor. More...
 
- Protected Member Functions inherited from Base
virtual ~Base ()
 Destructor, Always children gets destroyed first. More...
 
void destroychildren ()
 Destroys the children of this resource. More...
 
void setparenttonullptr (Base &base)
 Sets the parent of an object to nullptr, provides access. More...
 

Additional Inherited Members

- Public Attributes inherited from Base
const Containers::Collection< Base > & Children
 The children this object have. More...
 
unsigned long refcount
 INTERNAL, Reference count, used in linking mechanism. More...
 
- Protected Attributes inherited from Base
Containers::Collection< Basechildren
 Child objects that this resource object have. More...
 
SGuid guid
 SGuid to identify this resource object. More...
 
std::string name
 Name of this resource object, may not be loaded. More...
 
Baseparent
 Immediate parent of this resource. More...
 
const Baseroot
 Root of this resource. More...
 

Member Typedef Documentation

◆ ConstIterator

Constant iterator for the data resource.

◆ Iterator

Iterator for the data resource.

Constructor & Destructor Documentation

◆ Data() [1/3]

Data ( )

Creates an empty Data.

◆ Data() [2/3]

Data ( const T_ &  values,
const R_ &  reflectionobj = T_::Reflection() 
)
explicit

This constructor accepts a reflected struct and turns it into a resource data.

The types are tried to be matched with the built-in data resources. Second parameter allows named reflection.

References Data::Append().

◆ Data() [3/3]

Data ( const T_ &  values,
const std::string &  prefix,
const R_ &  reflectionobj = T_::Reflection() 
)

This constructor accepts a reflected struct and turns it into a resource data.

The types are tried to be matched with the built-in data resources. Multiple objects having same member names can be saved to a single data using second parameter, which appends a prefix to object members. Third parameter allows named reflection.

References Data::Append().

◆ ~Data()

~Data ( )
protected

Destructor.

Member Function Documentation

◆ Add()

void Add ( DataItem item)

Adds the given data item to this data resource. Ownership of the item is transferred to this Data.

◆ Append() [1/6]

std::enable_if<std::is_base_of<Base, T_>::value, void>::type Append ( const std::string &  name,
T_ &  value 
)

Appends the given resource object to the end of this data resource with the specified name.

References Data::Insert(), and Base::name.

◆ Append() [2/6]

std::enable_if<!std::is_base_of<Base, T_>::value, void>::type Append ( const std::string &  name,
T_  value 
)

Appends the given data to the end of this data resource with the specified name.

References Data::Insert(), and Base::name.

◆ Append() [3/6]

std::enable_if<R_::IsGorgonReflection, void>::type Append ( const T_ &  values,
const R_ &  reflectionobj = T_::Reflection() 
)

This function accepts a reflected struct and appends it to the resource data.

The types are tried to be matched with the built-in data resources. Multiple objects having same member names can be saved to a single data using second parameter, which appends a prefix to object members. Third parameter allows named reflection.

◆ Append() [4/6]

std::enable_if<R_::IsGorgonReflection, void>::type Append ( const T_ &  values,
const std::string &  prefix,
const R_ &  reflectionobj = T_::Reflection() 
)

This function accepts a reflected struct and appends it to the resource data.

The types are tried to be matched with the built-in data resources. Multiple objects having same member names can be saved to a single data using second parameter, which appends a prefix to object members. Third parameter allows named reflection.

◆ Append() [5/6]

std::enable_if<std::is_base_of<Base, T_>::value, void>::type Append ( T_ &  value)

Appends the given resource object to the end of this data resource.

References Data::Insert().

◆ Append() [6/6]

std::enable_if<!std::is_base_of<Base, T_>::value && !T_::ReflectionType::IsGorgonReflection, void>::type Append ( T_  value)

Appends the given data to the end of this data resource.

References Data::Insert().

◆ begin() [1/2]

Iterator begin ( )

Can be used to iterate over data objects.

◆ begin() [2/2]

ConstIterator begin ( ) const

Can be used to iterate over data objects.

◆ end() [1/2]

Iterator end ( )

Can be used to iterate over data objects.

◆ end() [2/2]

ConstIterator end ( ) const

Can be used to iterate over data objects.

◆ FindIndex()

int FindIndex ( const std::string &  name) const

Returns the index of the data item with the given name.

This function will return -1 if there is no such data item with the specified name exists

References Base::name.

◆ Get() [1/4]

T_ Get ( const std::string &  name) const

Returns the data with the given name; use GetObject in order to get resource objects.

◆ Get() [2/4]

T_ Get ( int  index) const

Returns the data with the given index; use GetObject in order to get resource objects.

◆ Get() [3/4]

int Get ( int  index) const

References DataItem::Get().

◆ Get() [4/4]

float Get ( int  index) const

References DataItem::Get().

◆ GetCount()

int GetCount ( ) const

Returns the number data items in this data resource.

◆ GetGID()

virtual GID::Type GetGID ( ) const
overridevirtual

This function shall return Gorgon ID of this resource.

Implements Base.

References Gorgon::Resource::GID::Data.

◆ GetItem() [1/2]

DataItem& GetItem ( const std::string &  name) const

Returns the data item with the given name.

References Base::name.

◆ GetItem() [2/2]

DataItem& GetItem ( int  index) const

Returns the data item with the given index.

◆ GetObject() [1/2]

T_& GetObject ( const std::string &  name) const

Returns the resource object with the given name.

References Gorgon::Utils::NotImplemented().

◆ GetObject() [2/2]

T_& GetObject ( int  index) const

Returns the resource object at the given index.

References ObjectData::Get().

◆ Insert() [1/25]

void Insert ( Base value,
int  before 
)

Inserts a data item to the given position.

References Data::Insert().

◆ Insert() [2/25]

void Insert ( Base value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [3/25]

void Insert ( const char *  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [4/25]

void Insert ( const std::string &  name,
Base value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Data::Insert(), and Base::name.

◆ Insert() [5/25]

void Insert ( const std::string &  name,
Base value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [6/25]

void Insert ( const std::string &  name,
const char *  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [7/25]

void Insert ( const std::string &  name,
const std::string &  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [8/25]

void Insert ( const std::string &  name,
float  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [9/25]

void Insert ( const std::string &  name,
Geometry::Bounds  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [10/25]

void Insert ( const std::string &  name,
Geometry::Margin  value,
int  before 
)

References Base::name.

◆ Insert() [11/25]

void Insert ( const std::string &  name,
Geometry::Point  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [12/25]

void Insert ( const std::string &  name,
Geometry::Pointf  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [13/25]

void Insert ( const std::string &  name,
Geometry::Rectangle  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [14/25]

void Insert ( const std::string &  name,
Geometry::Size  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [15/25]

void Insert ( const std::string &  name,
int  value,
int  before 
)

Inserts a data item to the given position with the specified name.

References Base::name.

◆ Insert() [16/25]

void Insert ( const std::string &  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [17/25]

void Insert ( DataItem item,
int  before 
)

Inserts the given data item to this data resource before the specified index. Ownership of the item is transferred to this Data.

◆ Insert() [18/25]

void Insert ( float  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [19/25]

void Insert ( Geometry::Bounds  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [20/25]

void Insert ( Geometry::Margin  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [21/25]

void Insert ( Geometry::Point  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [22/25]

void Insert ( Geometry::Pointf  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [23/25]

void Insert ( Geometry::Rectangle  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [24/25]

void Insert ( Geometry::Size  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From(), and Data::Insert().

◆ Insert() [25/25]

void Insert ( int  value,
int  before 
)

Inserts a data item to the given position.

References Gorgon::String::From().

◆ LoadResource()

Data * LoadResource ( std::weak_ptr< File file,
std::shared_ptr< Reader reader,
unsigned long  totalsize 
)
static

◆ NamedTransform() [1/2]

T_ NamedTransform ( const R_ &  reflectionobj = T_::Reflection())

Transforms the members of this resource data to the given struct.

Members are matched by name. Any resource objects that are transformed into the structure are released.

◆ NamedTransform() [2/2]

T_ NamedTransform ( const std::string &  prefix,
const R_ &  reflectionobj = T_::Reflection() 
)

Transforms the members of this resource data to the given struct.

Members are matched by name starting with prefix. Any resource objects that are transformed into the structure are released.

◆ NamedTransform_KeepObjects() [1/2]

T_ NamedTransform_KeepObjects ( const R_ &  reflectionobj = T_::Reflection()) const

Transforms the members of this resource data to the given struct.

Members are matched by name. This version does not transfer the ownership of the object data.

◆ NamedTransform_KeepObjects() [2/2]

T_ NamedTransform_KeepObjects ( const std::string &  prefix,
const R_ &  reflectionobj = T_::Reflection() 
) const

Transforms the members of this resource data to the given struct.

Members are matched by name starting with prefix. This version does not transfer the ownership of the object data.

◆ Release() [1/2]

DataItem& Release ( const std::string &  name)

Releases the data item with the given name. The data item will not be destroyed.

References Data::FindIndex(), Base::name, and Data::Release().

◆ Release() [2/2]

DataItem& Release ( int  index)

Releases the data item with the given index. The data item will not be destroyed.

◆ Remove() [1/2]

void Remove ( const std::string &  name)

Removes the item with the given name. The data item will be destroyed.

References Data::FindIndex(), Base::name, and Data::Remove().

◆ Remove() [2/2]

void Remove ( int  index)

Removes the item at the given index. The data item will be destroyed.


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