 |
Gorgon Game Engine
|
Go to the documentation of this file.
8 namespace Gorgon {
namespace Resource {
74 if(
children.FindLocation(resource)==-1)
99 return index>=0 && index<
children.GetCount();
117 template <
typename T_>
118 T_ &
Get(
int index)
const {
119 return dynamic_cast<T_&
>(
children[index]);
126 template <
typename T_>
131 throw std::runtime_error(
"Requested item cannot be found");
136 template <
typename T_>
138 return dynamic_cast<T_*
>(&
children[index]);
144 template <
typename T_>
157 bool Load(
bool shallow=
false);
165 virtual void Prepare()
override;
174 bool load(std::shared_ptr<Reader> data,
unsigned long size,
bool first,
bool shallow,
bool load);
virtual void Resolve(File &file)
This function shall resolve links or similar constructs.
Definition: Base.cpp:6
bool DeleteResource()
Safely deletes the resource.
Definition: Base.cpp:34
void Add(Base &resource)
Adds a the given resource to this folder.
Definition: Folder.h:41
std::map< std::string, Base * > namedlist
A map to bind items to their names.
Definition: Folder.h:186
void setparenttonullptr(Base &base)
Sets the parent of an object to nullptr, provides access.
Definition: Base.h:149
constexpr Type File
File.
Definition: GID.h:84
std::string name
Name of this resource object, may not be loaded.
Definition: Base.h:155
Base & GetItem(int Index) const
Returns an item with the given index.
Definition: Folder.h:89
virtual ~Folder()
Destructor.
Definition: Folder.h:29
bool Exists(int index) const
Checks whether an item in the given index is present.
Definition: Folder.h:98
@ NoFileObject
There is no file object associated with the resource. Generally thrown during late loading.
Definition: Reader.h:43
bool load(std::shared_ptr< Reader > data, unsigned long size, bool first, bool shallow, bool load)
This is the actual load function.
Definition: Folder.cpp:72
void WriteChunkHeader(GID::Type type, unsigned long size)
Writes the header of a chunk.
Definition: Writer.h:364
bool Exists(const std::string &name) const
Checks whether an item with the given name is present.
Definition: Folder.h:103
bool fullyloaded
Whether the contents of this folder is fully loaded.
Definition: Folder.h:189
T_ * GetPtr(const std::string &name) const
Returns the item at the given index performing dynamic_cast to the given type.
Definition: Folder.h:145
virtual void Prepare()
This function shall prepare this resource to be used after resource is loaded.
Definition: Base.cpp:16
constexpr Type Folder_Props
Properties of a folder.
Definition: GID.h:97
Marker WriteObjectStart(const Base &base)
Writes the start of an object. Should have a matching WriteEnd with the returned marker.
Definition: File.cpp:211
constexpr Type Folder
Folder resource Gorgon::Resource::Folder.
Definition: GID.h:91
void save(Writer &writer) const override
Definition: Folder.cpp:137
const Containers::Collection< Base >::ConstIterator begin() const
Allows easy iteration through range based fors.
Definition: Base.h:100
std::shared_ptr< Reader > reader
This is the reader used to read this folder. Might be empty if the folder is loaded completely.
Definition: Folder.h:196
unsigned long entrypoint
Entry point of this resource within the physical file.
Definition: Folder.h:180
void Remove(Base &resource)
Removes the given item.
Definition: Folder.h:70
void Add(Base *resource)
Adds a the given resource to this folder.
Definition: Folder.h:44
T_ & Get(const std::string &name) const
Returns the item at the given index performing dynamic_cast to the given type.
Definition: Folder.h:127
Folder()
Default constructor.
Definition: Folder.h:19
void Delete(Base &resource)
Deletes the given item properly, minding any links.
Definition: Folder.h:73
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
void MoveBefore(Base &item, long before)
Moves the given item to the given position.
Definition: Folder.h:65
virtual GID::Type GetGID() const override
01010000h, (System, Folder)
Definition: Folder.h:33
T_ & Get(int index) const
Returns the item at the given index performing dynamic_cast to the given type.
Definition: Folder.h:118
int GetCount() const
Returns the number of items contained.
Definition: Folder.h:86
void Insert(Base &resource, long before)
Inserts a the given resource to this folder before the given index.
Definition: Folder.h:48
Base * GetParentPtr() const
Returns the pointer to the parent. This function may return nullptr.
Definition: Base.h:78
Base & operator[](int Index) const
Returns an item with the given index.
Definition: Folder.h:95
This class represents a logical resource file.
Definition: File.h:53
std::weak_ptr< File > file
The file object that is used to load this folder.
Definition: Folder.h:193
bool IsLoaded() const
Returns whether this resource is loaded.
Definition: Folder.h:160
This class is the base for all Gorgon Resources.
Definition: Base.h:20
void Insert(Base *resource, long before)
Inserts a the given resource to this folder before the given index.
Definition: Folder.h:53
This class allows resource objects to save their data to a stream.
Definition: Writer.h:59
bool Load(bool shallow=false)
Loads this resource if it is not loaded yet.
Definition: Folder.cpp:24
This class represents a loading error.
Definition: Reader.h:16
void WriteEnd(Marker &marker)
This function performs writes necessary to end a chunk that is represented by the marker.
Definition: Writer.h:373
void MoveBefore(long index, long before)
Moves the given item to the given position.
Definition: Folder.h:59
Base & GetItemPtr(int Index) const
Returns an item with the given index.
Definition: Folder.h:92
T_ * GetPtr(int index)
Returns the item at the given index performing dynamic_cast to the given type.
Definition: Folder.h:137
bool reallyloadnames
Names will only be loaded if the variable is set.
Definition: Folder.h:183
static Folder * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > data, unsigned long size)
Definition: Folder.cpp:150
void WriteBool(bool value)
Writes a boolean value. In resource 1.0, booleans are stored as 32bit integers.
Definition: Writer.h:220
Type to store GID information.
Definition: GID.h:23
Containers::Collection< Base > children
Child objects that this resource object have.
Definition: Base.h:162
virtual void Prepare() override
Prepares children to be used.
Definition: Folder.cpp:12
This is basic folder resource, it contains other resources.
Definition: Folder.h:14
constexpr Type Folder_Names
Definition: GID.h:93