You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lunarium_OLD/src/assets/loaders/asset_index.h

57 lines
1.5 KiB
C

/******************************************************************************
* File - asset_index.h
* Author - Joey Pollack
* Date - 2021/10/25 (y/m/d)
* Mod Date - 2021/10/25 (y/m/d)
* Description - Loads and stores the index.dat file. Allows querying
* the asset index by asset ID or name.
******************************************************************************/
#ifndef ASSET_INDEX_H_
#define ASSET_INDEX_H_
#include <core/common_defs.h>
#include <core/types.h>
#include <utils/op_res.h>
#include <assets/types/asset.h>
#include <string>
#include <map>
namespace lunarium
{
class AssetIndex
{
public:
struct AssetInfo
{
int32_t ID;
std::string Name;
AssetType Type;
std::string File; // The data file the asset is stored in
u32 Offset; // The offset into the file at which the asset can be found
};
public:
static AssetIndex& GetInstance();
static void FreeInstance();
OpRes LoadIndex(const char* filename);
const AssetInfo* GetAssetInfo(int id) const;
const AssetInfo* GetAssetInfo(const char* name) const;
private:
static AssetIndex* mpInstance;
std::map<int, AssetInfo*> mAssets;
std::map<std::string, AssetInfo*> mAssetsByName;
AssetIndex();
AssetIndex(const AssetIndex&) = delete;
AssetIndex& operator=(const AssetIndex&) = delete;
};
}
#endif // ASSET_INDEX_H_