![]() |
Gorgon Game Engine
|
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... | |
DataItem & | GetItem (const std::string &name) const |
Returns the data item with the given name. More... | |
DataItem & | GetItem (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... | |
DataItem & | Release (const std::string &name) |
Releases the data item with the given name. The data item will not be destroyed. More... | |
DataItem & | Release (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... | |
![]() | |
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... | |
Base & | GetParent () const |
Returns the parent. If no parent set, this function throws std::runtime_error. More... | |
Base * | GetParentPtr () const |
Returns the pointer to the parent. This function may return nullptr. More... | |
const Base & | GetRoot () 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 Data * | LoadResource (std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize) |
Loads a data resource. More... | |
Protected Member Functions | |
~Data () | |
Destructor. More... | |
![]() | |
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 | |
![]() | |
const Containers::Collection< Base > & | Children |
The children this object have. More... | |
unsigned long | refcount |
INTERNAL, Reference count, used in linking mechanism. More... | |
![]() | |
Containers::Collection< Base > | children |
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... | |
Base * | parent |
Immediate parent of this resource. More... | |
const Base * | root |
Root of this resource. More... | |
Constant iterator for the data resource.
using Iterator = Containers::Collection<DataItem>::Iterator |
Iterator for the data resource.
|
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 | ( | 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().
|
protected |
Destructor.
void Add | ( | DataItem & | item | ) |
Adds the given data item to this data resource. Ownership of the item is transferred to this Data.
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.
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.
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.
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.
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().
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().
Iterator begin | ( | ) |
Can be used to iterate over data objects.
ConstIterator begin | ( | ) | const |
Can be used to iterate over data objects.
Iterator end | ( | ) |
Can be used to iterate over data objects.
ConstIterator end | ( | ) | const |
Can be used to iterate over data objects.
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.
T_ Get | ( | const std::string & | name | ) | const |
Returns the data with the given name; use GetObject in order to get resource objects.
T_ Get | ( | int | index | ) | const |
Returns the data with the given index; use GetObject in order to get resource objects.
int Get | ( | int | index | ) | const |
References DataItem::Get().
float Get | ( | int | index | ) | const |
References DataItem::Get().
int GetCount | ( | ) | const |
Returns the number data items in this data resource.
|
overridevirtual |
This function shall return Gorgon ID of this resource.
Implements Base.
References Gorgon::Resource::GID::Data.
DataItem& GetItem | ( | const std::string & | name | ) | const |
Returns the data item with the given name.
References Base::name.
DataItem& GetItem | ( | int | index | ) | const |
Returns the data item with the given index.
T_& GetObject | ( | const std::string & | name | ) | const |
Returns the resource object with the given name.
References Gorgon::Utils::NotImplemented().
T_& GetObject | ( | int | index | ) | const |
Returns the resource object at the given index.
References ObjectData::Get().
void Insert | ( | Base & | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Data::Insert().
void Insert | ( | Base * | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | const char * | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
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.
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.
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.
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.
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.
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.
void Insert | ( | const std::string & | name, |
Geometry::Margin | value, | ||
int | before | ||
) |
References Base::name.
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.
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.
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.
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.
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.
void Insert | ( | const std::string & | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
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.
void Insert | ( | float | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | Geometry::Bounds | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | Geometry::Margin | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | Geometry::Point | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | Geometry::Pointf | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | Geometry::Rectangle | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | Geometry::Size | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From(), and Data::Insert().
void Insert | ( | int | value, |
int | before | ||
) |
Inserts a data item to the given position.
References Gorgon::String::From().
|
static |
Loads a data resource.
References Data::Data(), Gorgon::Utils::ASSERT_FALSE(), DataItem::DataLoaders, and Gorgon::String::From().
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.
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.
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.
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.
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().
DataItem& Release | ( | int | index | ) |
Releases the data item with the given index. The data item will not be destroyed.
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().
void Remove | ( | int | index | ) |
Removes the item at the given index. The data item will be destroyed.