Public Member Functions | Private Attributes | List of all members
dai::AssetManager Class Reference

AssetManager can store assets and serialize. More...

#include <AssetManager.hpp>

Public Member Functions

void addExisting (std::vector< std::shared_ptr< Asset >> assets)
 
std::shared_ptr< Assetget (const std::string &key)
 
std::shared_ptr< const Assetget (const std::string &key) const
 
std::vector< std::shared_ptr< Asset > > getAll ()
 
std::vector< std::shared_ptr< const Asset > > getAll () const
 
void remove (const std::string &key)
 
void serialize (AssetsMutable &assets, std::vector< std::uint8_t > &assetStorage, std::string prefix="") const
 Serializes. More...
 
std::shared_ptr< dai::Assetset (Asset asset)
 
std::shared_ptr< dai::Assetset (const std::string &key, Asset asset)
 
std::shared_ptr< dai::Assetset (const std::string &key, const dai::Path &path, int alignment=64)
 
std::shared_ptr< dai::Assetset (const std::string &key, const std::vector< std::uint8_t > &data, int alignment=64)
 
std::shared_ptr< dai::Assetset (const std::string &key, std::vector< std::uint8_t > &&data, int alignment=64)
 
std::size_t size () const
 

Private Attributes

std::map< std::string, std::shared_ptr< Asset > > assetMap
 

Detailed Description

AssetManager can store assets and serialize.

Definition at line 33 of file AssetManager.hpp.

Member Function Documentation

◆ addExisting()

void dai::AssetManager::addExisting ( std::vector< std::shared_ptr< Asset >>  assets)

Adds all assets in an array to the AssetManager

Parameters
assetsVector of assets to add

Definition at line 78 of file AssetManager.cpp.

◆ get() [1/2]

std::shared_ptr< Asset > dai::AssetManager::get ( const std::string &  key)
Returns
Asset assigned to the specified key or a nullptr otherwise

Definition at line 71 of file AssetManager.cpp.

◆ get() [2/2]

std::shared_ptr< const Asset > dai::AssetManager::get ( const std::string &  key) const
Returns
Asset assigned to the specified key or a nullptr otherwise

Definition at line 64 of file AssetManager.cpp.

◆ getAll() [1/2]

std::vector<std::shared_ptr<Asset> > dai::AssetManager::getAll ( )
Returns
All asset stored in the AssetManager

◆ getAll() [2/2]

std::vector< std::shared_ptr< Asset > > dai::AssetManager::getAll ( ) const
Returns
All asset stored in the AssetManager

Definition at line 87 of file AssetManager.cpp.

◆ remove()

void dai::AssetManager::remove ( const std::string &  key)

Removes asset with key

Parameters
keyKey of asset to remove

Definition at line 107 of file AssetManager.cpp.

◆ serialize()

void dai::AssetManager::serialize ( AssetsMutable assets,
std::vector< std::uint8_t > &  assetStorage,
std::string  prefix = "" 
) const

Serializes.

Definition at line 111 of file AssetManager.cpp.

◆ set() [1/5]

std::shared_ptr< dai::Asset > dai::AssetManager::set ( Asset  asset)

Adds or overwrites an asset object to AssetManager.

Parameters
assetAsset to add
Returns
Shared pointer to asset

Definition at line 15 of file AssetManager.cpp.

◆ set() [2/5]

std::shared_ptr< dai::Asset > dai::AssetManager::set ( const std::string &  key,
Asset  asset 
)

Adds or overwrites an asset object to AssetManager with a specified key. Key value will be assigned to an Asset as well

Parameters
keyKey under which the asset should be stored
assetAsset to store
Returns
Shared pointer to asset

Definition at line 21 of file AssetManager.cpp.

◆ set() [3/5]

std::shared_ptr< dai::Asset > dai::AssetManager::set ( const std::string &  key,
const dai::Path path,
int  alignment = 64 
)

Loads file into asset manager under specified key.

Parameters
keyKey under which the asset should be stored
pathPath to file which to load as asset
alignment[Optional] alignment of asset data in asset storage. Default is 64B

Definition at line 29 of file AssetManager.cpp.

◆ set() [4/5]

std::shared_ptr< dai::Asset > dai::AssetManager::set ( const std::string &  key,
const std::vector< std::uint8_t > &  data,
int  alignment = 64 
)

Loads file into asset manager under specified key.

Parameters
keyKey under which the asset should be stored
dataAsset data
alignment[Optional] alignment of asset data in asset storage. Default is 64B
Returns
Shared pointer to asset

Definition at line 46 of file AssetManager.cpp.

◆ set() [5/5]

std::shared_ptr< dai::Asset > dai::AssetManager::set ( const std::string &  key,
std::vector< std::uint8_t > &&  data,
int  alignment = 64 
)

Definition at line 55 of file AssetManager.cpp.

◆ size()

std::size_t dai::AssetManager::size ( ) const
Returns
Number of asset stored in the AssetManager

Definition at line 103 of file AssetManager.cpp.

Member Data Documentation

◆ assetMap

std::map<std::string, std::shared_ptr<Asset> > dai::AssetManager::assetMap
private

Definition at line 34 of file AssetManager.hpp.


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


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:20