![]() |
Gorgon Game Engine
|
This is basic folder resource, it contains other resources. More...
Public Member Functions | |
Folder () | |
Default constructor. More... | |
Folder (File &file) | |
Constructs a folder over a specific file, it does not add the folder to the tree of the file though. More... | |
Folder (std::weak_ptr< File > file) | |
virtual | ~Folder () |
Destructor. More... | |
virtual GID::Type | GetGID () const override |
01010000h, (System, Folder) More... | |
bool | IsLoaded () const |
Returns whether this resource is loaded. More... | |
bool | Load (bool shallow=false) |
Loads this resource if it is not loaded yet. More... | |
virtual void | Prepare () override |
Prepares children to be used. 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 | 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 Folder * | LoadResource (std::weak_ptr< File > file, std::shared_ptr< Reader > data, unsigned long size) |
Protected Member Functions | |
bool | load (std::shared_ptr< Reader > data, unsigned long size, bool first, bool shallow, bool load) |
This is the actual load function. More... | |
void | save (Writer &writer) const override |
![]() | |
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... | |
Protected Attributes | |
unsigned long | entrypoint |
Entry point of this resource within the physical file. More... | |
std::weak_ptr< File > | file |
The file object that is used to load this folder. More... | |
bool | fullyloaded |
Whether the contents of this folder is fully loaded. More... | |
std::map< std::string, Base * > | namedlist |
A map to bind items to their names. More... | |
std::shared_ptr< Reader > | reader |
This is the reader used to read this folder. Might be empty if the folder is loaded completely. More... | |
bool | reallyloadnames |
Names will only be loaded if the variable is set. 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... | |
Collection related | |
void | Add (Base &resource) |
Adds a the given resource to this folder. More... | |
void | Add (Base *resource) |
Adds a the given resource to this folder. More... | |
void | Insert (Base &resource, long before) |
Inserts a the given resource to this folder before the given index. More... | |
void | Insert (Base *resource, long before) |
Inserts a the given resource to this folder before the given index. More... | |
void | MoveBefore (long index, long before) |
Moves the given item to the given position. More... | |
void | MoveBefore (Base &item, long before) |
Moves the given item to the given position. More... | |
void | Remove (Base &resource) |
Removes the given item. More... | |
void | Delete (Base &resource) |
Deletes the given item properly, minding any links. More... | |
int | GetCount () const |
Returns the number of items contained. More... | |
Base & | GetItem (int Index) const |
Returns an item with the given index. More... | |
Base & | GetItemPtr (int Index) const |
Returns an item with the given index. More... | |
Base & | operator[] (int Index) const |
Returns an item with the given index. More... | |
bool | Exists (int index) const |
Checks whether an item in the given index is present. More... | |
bool | Exists (const std::string &name) const |
Checks whether an item with the given name is present. More... | |
Typecasting access | |
These functions allow access to children by casting them to the requested type | |
template<typename T_ > | |
T_ & | Get (int index) const |
Returns the item at the given index performing dynamic_cast to the given type. More... | |
template<typename T_ > | |
T_ & | Get (const std::string &name) const |
Returns the item at the given index performing dynamic_cast to the given type. More... | |
template<typename T_ > | |
T_ * | GetPtr (int index) |
Returns the item at the given index performing dynamic_cast to the given type. More... | |
template<typename T_ > | |
T_ * | GetPtr (const std::string &name) const |
Returns the item at the given index performing dynamic_cast to the given type. 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... | |
This is basic folder resource, it contains other resources.
Folder | ( | ) |
Default constructor.
Constructs a folder over a specific file, it does not add the folder to the tree of the file though.
References Folder::file.
|
virtual |
Destructor.
void Add | ( | Base & | resource | ) |
Adds a the given resource to this folder.
References Base::children.
void Add | ( | Base * | resource | ) |
Adds a the given resource to this folder.
References Base::children.
void Delete | ( | Base & | resource | ) |
Deletes the given item properly, minding any links.
References Base::children, Base::DeleteResource(), Base::GetParentPtr(), and Base::setparenttonullptr().
bool Exists | ( | const std::string & | name | ) | const |
Checks whether an item with the given name is present.
References Base::name, and Folder::namedlist.
bool Exists | ( | int | index | ) | const |
Checks whether an item in the given index is present.
References Base::children.
T_& Get | ( | const std::string & | name | ) | const |
Returns the item at the given index performing dynamic_cast to the given type.
This function propagates bad_cast exception from dynamic_cast, does not perform range check
std::runtime_error | if the given name is not found |
References Base::name, and Folder::namedlist.
T_& Get | ( | int | index | ) | const |
Returns the item at the given index performing dynamic_cast to the given type.
This function propagates bad_cast exception from dynamic_cast, does not perform range check
References Base::children.
int GetCount | ( | ) | const |
Returns the number of items contained.
References Base::children.
|
overridevirtual |
Base& GetItem | ( | int | Index | ) | const |
Returns an item with the given index.
References Base::children.
Base& GetItemPtr | ( | int | Index | ) | const |
Returns an item with the given index.
References Base::children.
T_* GetPtr | ( | const std::string & | name | ) | const |
Returns the item at the given index performing dynamic_cast to the given type.
This function returns nullptr if object cannot be casted to the given type.
std::runtime_error | if the given name is not found |
References Base::name, and Folder::namedlist.
T_* GetPtr | ( | int | index | ) |
Returns the item at the given index performing dynamic_cast to the given type.
This function returns nullptr if object cannot be casted to the given type.
References Base::children.
void Insert | ( | Base & | resource, |
long | before | ||
) |
Inserts a the given resource to this folder before the given index.
References Base::children.
void Insert | ( | Base * | resource, |
long | before | ||
) |
Inserts a the given resource to this folder before the given index.
References Base::children.
bool IsLoaded | ( | ) | const |
Returns whether this resource is loaded.
References Folder::fullyloaded.
bool Load | ( | bool | shallow = false | ) |
Loads this resource if it is not loaded yet.
shallow | only loads immediate children of this resource |
References Base::begin(), Folder::entrypoint, Folder::file, Folder::fullyloaded, Folder::load(), Folder::reader, and Base::Resolve().
|
protected |
This is the actual load function.
This function requires already opened and precisely positioned input stream
References Folder::Folder(), Base::children, Folder::entrypoint, Folder::file, Gorgon::Resource::GID::Folder, Gorgon::Resource::GID::Folder_Names, Gorgon::Resource::GID::Folder_Props, Folder::fullyloaded, LoadError::NoFileObject, Folder::reader, and Folder::reallyloadnames.
|
static |
References Folder::Folder(), and Folder::file.
void MoveBefore | ( | Base & | item, |
long | before | ||
) |
Moves the given item to the given position.
It is possible to specify GetCount() as before to move the item to the end.
References Base::children.
void MoveBefore | ( | long | index, |
long | before | ||
) |
Moves the given item to the given position.
It is possible to specify GetCount() as before to move the item to the end.
References Base::children.
Base& operator[] | ( | int | Index | ) | const |
Returns an item with the given index.
References Base::children.
|
overridevirtual |
Prepares children to be used.
Reimplemented from Base.
References Base::children, Folder::namedlist, Base::Prepare(), and Folder::reallyloadnames.
void Remove | ( | Base & | resource | ) |
Removes the given item.
References Base::children.
|
overrideprotectedvirtual |
|
protected |
Entry point of this resource within the physical file.
This value is stored for late loading purposes
|
protected |
The file object that is used to load this folder.
If this folder is partially loaded this file would be used to load its contents
|
protected |
Whether the contents of this folder is fully loaded.
|
protected |
A map to bind items to their names.
|
protected |
This is the reader used to read this folder. Might be empty if the folder is loaded completely.
|
protected |
Names will only be loaded if the variable is set.