vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::Resource Class Reference

Base class for every asset type, carrying the identity the ResourceManager indexes by. More...

#include <resource.h>

Inheritance diagram for Vkm::Engine::Resource:
Vkm::Engine::AnimationClipAsset Vkm::Engine::AudioClipAsset Vkm::Engine::FontAsset Vkm::Engine::MaterialAsset Vkm::Engine::MeshAsset Vkm::Engine::SkeletonAsset Vkm::Engine::TextureAsset

Public Member Functions

 Resource (const Resource &other)
 Duplicate other's contents and name, but not its identity.
const std::string & name () const noexcept
 Serializable identity; non-empty and unique within its type once added.
uint64_t uid () const noexcept
 Process-unique id stamped by add(); names the asset, not the slot it sits in.
uint64_t version () const noexcept
 Change counter the backend keys GPU re-uploads on; moved by commit().
bool isHidden () const noexcept
 Added by ResourceManager::addPrivate: not user-facing, not saved.
nlohmann::json & sourceJson ()
 Mutable source JSON, allocating a null document if there is none.
const nlohmann::json & sourceJson () const
 Const source JSON; asserts hasSource(), so guard the call with it.

Detailed Description

Base class for every asset type, carrying the identity the ResourceManager indexes by.

Only the manager writes the identity fields: name an asset with add(asset, name), change it with rename(handle, name). A subclass is a plain data struct of bare public members.

Constructor & Destructor Documentation

◆ Resource()

Vkm::Engine::Resource::Resource ( const Resource & other)

Duplicate other's contents and name, but not its identity.

Carries the contents, name and source descriptor; not the uid or version, which add() stamps afresh.

Parameters
otherThe asset to duplicate.

Member Function Documentation

◆ sourceJson() [1/2]

nlohmann::json & Vkm::Engine::Resource::sourceJson ( )

Mutable source JSON, allocating a null document if there is none.

Callers must #include <nlohmann/json.hpp>.

Returns
The source descriptor.

◆ sourceJson() [2/2]

const nlohmann::json & Vkm::Engine::Resource::sourceJson ( ) const

Const source JSON; asserts hasSource(), so guard the call with it.

Returns
The existing source descriptor.

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