cesium-native
0.41.0
|
An asset that is potentially shared between multiple objects, such as an image shared between multiple glTF models. This is intended to be the base class for such assets. More...
#include <CesiumUtility/SharedAsset.h>
Public Member Functions | |
void | addReference () const noexcept |
Adds a counted reference to this object. Use CesiumUtility::IntrusivePointer instead of calling this method directly. | |
void | releaseReference () const noexcept |
Removes a counted reference from this object. When the last reference is removed, this method will delete this instance. Use CesiumUtility::IntrusivePointer instead of calling this method directly. | |
const IDepotOwningAsset< T > * | getDepot () const |
Gets the shared asset depot that owns this asset, or nullptr if this asset is independent of an asset depot. | |
IDepotOwningAsset< T > * | getDepot () |
Gets the shared asset depot that owns this asset, or nullptr if this asset is independent of an asset depot. | |
Public Member Functions inherited from CesiumUtility::ExtensibleObject | |
template<typename T > | |
bool | hasExtension () const noexcept |
Checks if an extension exists given its static type. More... | |
template<typename T > | |
const T * | getExtension () const noexcept |
Gets an extension given its static type. More... | |
template<typename T > | |
T * | getExtension () noexcept |
Gets an extension given its static type. More... | |
const JsonValue * | getGenericExtension (const std::string &extensionName) const noexcept |
Gets a generic extension with the given name as a CesiumUtility::JsonValue. More... | |
JsonValue * | getGenericExtension (const std::string &extensionName) noexcept |
Gets a generic extension with the given name as a CesiumUtility::JsonValue. More... | |
template<typename T , typename... ConstructorArgumentTypes> | |
T & | addExtension (ConstructorArgumentTypes &&... constructorArguments) |
Adds a statically-typed extension to this object. More... | |
template<typename T > | |
void | removeExtension () |
Removes a statically-typed extension from this object. More... | |
Protected Member Functions | |
SharedAsset (const SharedAsset &rhs) | |
SharedAsset (SharedAsset &&rhs) | |
SharedAsset & | operator= (const SharedAsset &rhs) |
SharedAsset & | operator= (SharedAsset &&rhs) |
Friends | |
template<typename TAssetType , typename TAssetKey > | |
class | CesiumAsync::SharedAssetDepot |
Additional Inherited Members | |
Public Attributes inherited from CesiumUtility::ExtensibleObject | |
std::unordered_map< std::string, std::any > | extensions |
The extensions attached to this object. More... | |
JsonValue::Object | extras |
Application-specific data. More... | |
JsonValue::Object | unknownProperties |
Unknown properties that exist on this object but do not have any representation in the statically-typed classes. More... | |
An asset that is potentially shared between multiple objects, such as an image shared between multiple glTF models. This is intended to be the base class for such assets.
The lifetime of instances of this class should be managed by reference counting with IntrusivePointer.
T | The type that is deriving from this class. For example, you should declare your class as class MyClass : public SharedAsset<MyClass> { ... }; |
A SharedAsset
can be in one of three possible states:
Independent Asset An independent asset isn't affiliated with an asset depot at all. Its lifetime is controlled exclusively by IntrusivePointer / reference counting. When the asset's reference count goes to zero, it deletes itself. An independent asset's getDepot returns nullptr.
Active Depot Asset This is an asset that is owned by an asset depot and that is in use, meaning it has a reference count greater than zero. The asset depot owns the asset via an std::unique_ptr
, not via adding to the reference count. So when the reference count goes to zero, only the asset depot itself still has a reference to it, so it becomes an inactive depot asset.
Inactive Depot Asset This is also an asset that is owned by the asset depot, but there are no other references to it (it has a reference count of zero). It is found in the asset depot's deletionCandidates
list. When a reference to it is added, it is removed from deletionCandidates
and it becomes an active depot asset.
Definition at line 52 of file SharedAsset.h.
|
inlineprotected |
Assets can be copied, but the fresh instance has no references and is not in the asset depot.
Definition at line 89 of file SharedAsset.h.
|
inlineprotected |
After a move construction, the content of the asset is moved to the new instance, but the asset depot still references the old instance.
Definition at line 96 of file SharedAsset.h.
|
inlineprotected |
Assignment does not affect the asset's relationship with the depot, but is useful to assign the data in derived classes.
Definition at line 105 of file SharedAsset.h.