|
CeresEngine 0.2.0
A game development framework
|
A package is a collection of resources that are stored in a single data blob. More...
#include <CeresEngine/Resource/Package.hpp>
Classes | |
| struct | Entry |
| A structure that describes a single entry in the package. More... | |
| struct | PackageIndex |
| A structure that wraps the index of a package. More... | |
Public Member Functions | |
| Package (PackageManager &manager, const PackageURL &packageURL) | |
| Creates a new package. | |
| ~Package () noexcept | |
| const PackageID & | getPackageID () const noexcept |
| A UUID that uniquely identifies the package. | |
| const SPtr< PackageMetadata > & | getMetadata () const noexcept |
| Generates a hash for the provided type. | |
| void | setMetadata (const SPtr< PackageMetadata > &metadata) noexcept |
| Generates a hash for the provided type. | |
| bool | isEmpty () const noexcept |
| Checks if the package is currently empty and contains no resources. | |
| Async | addResource (const FilePath &path, const HResource &resource, bool allowReplacing=false) |
| Adds a new resource to the package. | |
| Async | removeResource (const FilePath &path) |
| Removes the resource at the given path from the package. | |
| Async | removeResource (const ResourceID &resourceID) |
| Removes the resource with the given ID from the package. | |
| Async< HResource > | loadResource (const FilePath &path) |
| Loads a resource from the package. | |
| Async< HResource > | loadResource (const ResourceID &resourceID) |
| Loads a resource from the package. | |
| Async | save () |
| Async | save (const PackageURL &url) |
Public Member Functions inherited from CeresEngine::RefCounted< Package > | |
| RefCounted (Args &&... args) | |
Creates a new RefCounted object and constructs a new Deleter by forwarding Args to it. | |
| void | retain () noexcept |
| Retains the object by increment it's reference count by one. | |
| bool | release () noexcept |
| Relases the object by decrementing it's reference count by one. | |
Private Member Functions | |
| Optional< FilePath > | resolveUUIDToPath (const ResourceID &uuid) |
| Resolves a resource UUID to it's package-relative path. | |
| Optional< ResourceID > | resolvePathToUUID (const FilePath &path) |
| Resolves a package-relative resource path to it's UUID. | |
Private Attributes | |
| PackageManager & | mManager |
| The package manager from which this package was loaded from. | |
| PackageURL | mPackageURL |
| An absolute URL to the package. | |
| PackageID | mPackageID |
| A UUID that uniquely identifies the package. | |
| SPtr< PackageMetadata > | mMetadata |
| A pointer to the package metadata object. | |
| UPtr< PrivateData > | mData |
| The package data. | |
| LockedObject< PackageIndex, SharedMutex > | mIndex |
| The package index. Contains information about the contents of the package. | |
Friends | |
| class | PackagedResourceData |
A package is a collection of resources that are stored in a single data blob.
Loading a package will not load the resources, but will instead load a small header that contains information about the resources contained in the package. However, loading a package will make all it's resources available on the resource system.
|
explicit |
Creates a new package.
| manager | The manager that will own the package. |
| packageURL | The URL to which the package will be stored at. |
|
noexcept |
| Async CeresEngine::Package::addResource | ( | const FilePath & | path, |
| const HResource & | resource, | ||
| bool | allowReplacing = false |
||
| ) |
Adds a new resource to the package.
| path | The path to add the resource inside the package. |
| resource | The resource to be added to the package. |
| allowReplacing | If true, will replace the resource inside the package if a resource already exists on the given path. |
|
inlinenoexcept |
Generates a hash for the provided type.
Type must have a std::hash specialization.
| T | the type to be hashed |
| v | The value to be hashed |
A UUID that uniquely identifies the package.
|
noexcept |
Checks if the package is currently empty and contains no resources.
Loads a resource from the package.
If the resource is already loaded, the loaded instance is returned.
| Async< HResource > CeresEngine::Package::loadResource | ( | const ResourceID & | resourceID | ) |
Loads a resource from the package.
If the resource is already loaded, the loaded instance is returned.
Removes the resource at the given path from the package.
| path | The path to remove the resource at. |
| Async CeresEngine::Package::removeResource | ( | const ResourceID & | resourceID | ) |
Removes the resource with the given ID from the package.
| path | The resource ID of the resource to be removed. |
|
private |
Resolves a package-relative resource path to it's UUID.
If no such resource exists on the package, an empty optional is returned.
|
private |
Resolves a resource UUID to it's package-relative path.
If no such resource exists on the package, an empty optional is returned.
| Async CeresEngine::Package::save | ( | ) |
| Async CeresEngine::Package::save | ( | const PackageURL & | url | ) |
|
inlinenoexcept |
Generates a hash for the provided type.
Type must have a std::hash specialization.
| T | the type to be hashed |
| v | The value to be hashed |
|
friend |
|
private |
The package data.
|
private |
The package index. Contains information about the contents of the package.
|
private |
The package manager from which this package was loaded from.
|
private |
A pointer to the package metadata object.
|
private |
An absolute URL to the package.
All contained resources use this as their base URL.