3#define NW_DECL_RES_LIST(key,AssetClass) static std::unordered_map<key, AssetClass> resList; 
    4#define NW_IMPL_RES_LIST(key,AssetClass) std::unordered_map<key, AssetClass> AssetClass::resList; 
   11    int _usageCounter = 0;
 
 
   71        return (T*)_asset.GetFromCache();
 
 
   82        return (T*)_asset.LoadFromFileOrGetFromCache(identifier, path, data);
 
 
   92        return (T*)_asset.LoadFromFile(path, data);
 
 
  102        return (T*)_asset.LoadFromBuffer(buffer, data);
 
 
  113        return (T*)_asset.LoadFromBufferOrGetFromCache(identifier, buffer, data);
 
 
 
  117template<
typename T, 
typename T_Identifier>
 
  118T_Identifier GetIDWithAsset(T assetChildInstancePtr) {
 
  119    auto list = assetChildInstancePtr->resList;
 
  120    auto iter = list.begin();
 
  121    for (iter; iter != list.end(); ++iter) {
 
  122        if (&iter->second == assetChildInstancePtr) {
 
  129template<
typename ResListType, 
typename T>
 
  130void EraseRes(
const T& identifier) {
 
  131    ResListType::resList.erase(identifier);
 
  134template<
typename T, 
typename IDType>
 
  135T* InsertRes(IDType 
id) {
 
  136    T* temp = (T*)T::GetResFromCache(
id);
 
  137    if (temp != 
nullptr) {
 
  140    T::resList.emplace(
id, T());
 
  144T LoadAssetFromFile(
const char* path, 
void* data = 
nullptr) {
 
  146    return = (T*)l.LoadFromFile(path, data);
 
  150void hashCombine(
size_t& s, 
const T& v) {
 
  152    s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
 
The base class for all assets.
Definition Asset.h:9
 
virtual Asset * GetFromCache(void *identifier)
Get the asset from the cache based on the identifier.
Definition Asset.cpp:3
 
virtual Asset * LoadFromFile(const char *path, void *data=nullptr)
Load the asset from file based on the file path.
Definition Asset.cpp:22
 
virtual Asset * LoadFromFileOrGetFromCache(void *identifier, const char *path, void *data)
Load the asset from file or get it from the cache based on the identifier and file path.
Definition Asset.cpp:4
 
virtual Asset * LoadFromBuffer(void *buffer, void *data)
Load the asset from a buffer.
Definition Asset.cpp:23
 
virtual void Clean()
Clean up the asset.
Definition Asset.cpp:24
 
virtual Asset * LoadFromBufferOrGetFromCache(void *identifier, void *buffer, void *data)
Load the asset from a buffer or get it from the cache based on the identifier.
Definition Asset.cpp:15
 
T * GetFromCache(void *identifier)
Get the asset from the cache based on the identifier.
Definition Asset.h:70
 
T * LoadFromBuffer(void *buffer, void *data)
Load the asset from a buffer.
Definition Asset.h:101
 
T * LoadFromFileOrGetFromCache(void *identifier, const char *path, void *data)
Load the asset from file or get it from the cache based on the identifier and file path.
Definition Asset.h:81
 
T * LoadFromBufferOrGetFromCache(void *identifier, void *buffer, void *data)
Load the asset from a buffer or get it from the cache based on the identifier.
Definition Asset.h:112
 
T * LoadFromFile(const char *path, void *data=nullptr)
Load the asset from file based on the file path.
Definition Asset.h:91