CSEngine
Loading...
Searching...
No Matches
CSE::ResMgr Class Reference
Inheritance diagram for CSE::ResMgr:
CSE::CoreBase CSE::SContainerHash< SResource * > CSE::SIContainer< S, T, M >

Public Member Functions

void Init () override
 
void InitResource ()
 
void Exterminate ()
 
void Remove (SResource *m_object) override
 
template<class TYPE >
TYPE * GetObjectByHash (const std::string &hash) const
 
SResourceGetSResource (std::string name) const
 
int GetStringHash (const std::string &str)
 
AssetMgr::AssetReferenceGetAssetReference (std::string name) const
 
std::list< AssetMgr::AssetReference * > GetAssetReferences (AssetMgr::TYPE type) const
 
- Public Member Functions inherited from CSE::CoreBase
virtual void Update (float elapsedTime)
 
- Public Member Functions inherited from CSE::SContainerHash< SResource * >
void Register (SResource * object) override
 
void Remove (SResource * object) override
 
bool HasHash (const std::string &hash) const
 
SResourceGet (std::string index) const override
 
std::unordered_map< std::string, SResource * > GetAll () const override
 
std::string GetID (SResource * object) const override
 
int GetSize () const override
 
void ChangeHash (const std::string &srcHash, const std::string &dstHash)
 
- Public Member Functions inherited from CSE::SIContainer< S, T, M >
virtual void Register (T object)=0
 
virtual void Remove (T object)=0
 
virtual T Get (M index) const =0
 
virtual M GetID (T object) const =0
 

Friends

class AssetMgr
 

Additional Inherited Members

- Protected Attributes inherited from CSE::SContainerHash< SResource * >
std::unordered_map< std::string, SResource * > m_objects
 
int m_size
 

Detailed Description

Definition at line 24 of file ResMgr.h.

Constructor & Destructor Documentation

◆ ~ResMgr()

ResMgr::~ResMgr ( )
override

Definition at line 15 of file ResMgr.cpp.

15 {
16 Exterminate();
17}

Member Function Documentation

◆ Exterminate()

void ResMgr::Exterminate ( )

Definition at line 32 of file ResMgr.cpp.

32 {
33 SAFE_DELETE(m_assetManager);
34}

◆ GetAssetReference()

AssetMgr::AssetReference * ResMgr::GetAssetReference ( std::string  name) const

Definition at line 50 of file ResMgr.cpp.

50 {
51 return m_assetManager->GetAsset(name);
52}

◆ GetAssetReferences()

std::list< AssetMgr::AssetReference * > ResMgr::GetAssetReferences ( AssetMgr::TYPE  type) const

Definition at line 67 of file ResMgr.cpp.

67 {
68 return m_assetManager->GetAssets(type);
69}

◆ GetObjectByHash()

template<class TYPE >
TYPE * CSE::ResMgr::GetObjectByHash ( const std::string &  hash) const

Definition at line 66 of file ResMgr.h.

66 {
67 if(m_objects.count(hash) <= 0) return nullptr;
68
69 return static_cast<TYPE*>(Get(hash));
70 }

◆ GetSResource()

SResource * ResMgr::GetSResource ( std::string  name) const

Definition at line 54 of file ResMgr.cpp.

54 {
55 if(m_objects.count(name) > 0) return Get(name);
56 make_lower(name);
57 for (const auto& pair : m_objects) {
58 const auto& res = pair.second;
59 if (make_lower_copy(res->GetName()) == name)
60 return res;
61 if (make_lower_copy(res->GetAbsoluteID()) == name)
62 return res;
63 }
64 return nullptr;
65}

◆ GetStringHash()

int ResMgr::GetStringHash ( const std::string &  str)

Definition at line 41 of file ResMgr.cpp.

41 {
42 auto result = std::find(m_stringIds.begin(), m_stringIds.end(), str);
43 if (result != m_stringIds.end())
44 return result - m_stringIds.begin();
45
46 m_stringIds.push_back(str);
47 return m_stringIds.size() - 1;
48}

◆ Init()

void ResMgr::Init ( )
overridevirtual

Implements CSE::CoreBase.

Definition at line 19 of file ResMgr.cpp.

19 {
20 InitResource();
21}

◆ InitResource()

void ResMgr::InitResource ( )

Definition at line 23 of file ResMgr.cpp.

23 {
24 //Make Asset Manager
25 if(m_assetManager == nullptr)
26 m_assetManager = new AssetMgr();
27
28 //Load Assets
29 m_assetManager->LoadAssets(Settings::IsAssetsPacked());
30}

◆ Remove()

void ResMgr::Remove ( SResource m_object)
override

Definition at line 36 of file ResMgr.cpp.

36 {
38 CORE->GetCore(MemoryMgr)->ReleaseObject(m_object, true);
39}

Friends And Related Symbol Documentation

◆ AssetMgr

friend class AssetMgr
friend

Definition at line 62 of file ResMgr.h.


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