CSEngine
Loading...
Searching...
No Matches
CSE::SResource Class Referenceabstract
Inheritance diagram for CSE::SResource:
CSE::SObject CSE::Animation CSE::GLProgramHandle CSE::SFrameBuffer CSE::SISurface CSE::SMaterial CSE::SPrefab CSE::SScriptObject CSE::SShaderGroup CSE::STexture CSE::Skeleton

Public Member Functions

 SResource (bool isRegister)
 
 SResource (const SResource *resource, bool isRegister)
 
void SetName (std::string name)
 
void SetAbsoluteID (std::string id)
 
std::string GetName () const
 
std::string GetAbsoluteID () const
 
AssetMgr::AssetReferenceGetAssetReference (std::string hash="") const
 
void LinkResource (AssetMgr::AssetReference *asset)
 
void LinkResource (std::string name)
 
void SetHash (std::string &hash) override
 
- Public Member Functions inherited from CSE::SObject
 SObject (bool isRegister)
 
virtual void Exterminate ()=0
 
virtual void SetUndestroyable (bool enable)
 
virtual void Destroy ()
 
virtual void __FORCE_DESTROY__ ()
 
virtual std::string GenerateMeta ()
 
std::string GetHash () const
 

Static Public Member Functions

template<class T >
static T * Create (const std::string &name)
 
template<class T >
static T * Create (const AssetMgr::AssetReference *asset)
 
template<class T >
static T * Get (std::string name)
 

Protected Member Functions

virtual void Init (const AssetMgr::AssetReference *asset)=0
 

Additional Inherited Members

- Protected Attributes inherited from CSE::SObject
std::string m_hash
 

Detailed Description

Definition at line 14 of file SResource.h.

Constructor & Destructor Documentation

◆ SResource() [1/3]

SResource::SResource ( )

Definition at line 17 of file SResource.cpp.

17 {
18 auto resMgr = CORE->GetCore(ResMgr);
19 resMgr->Register(this);
20 m_name = "Resource " + std::to_string(resMgr->GetSize());
21}

◆ SResource() [2/3]

SResource::SResource ( bool  isRegister)
explicit

Definition at line 23 of file SResource.cpp.

23 {
24 m_name = "Unregister Resource";
25}

◆ SResource() [3/3]

SResource::SResource ( const SResource resource,
bool  isRegister 
)

Definition at line 27 of file SResource.cpp.

27 : SObject(isRegister) {
28 if(isRegister) {
29 CORE->GetCore(ResMgr)->Register(this);
30 }
31 m_name = resource->m_name + " (instance)";
32}

Member Function Documentation

◆ Create() [1/2]

template<class T >
static T * CSE::SResource::Create ( const AssetMgr::AssetReference asset)
inlinestatic

Definition at line 58 of file SResource.h.

58 {
59 if (asset == nullptr) return nullptr;
60 {
61 SResource* res = GetResource(asset->name);
62 if (res != nullptr) return static_cast<T*>(res);
63 }
64 T* object = new T();
65 SResource* res = object;
66
67 res->SetResource(asset);
68 return object;
69 }

◆ Create() [2/2]

template<class T >
static T * CSE::SResource::Create ( const std::string &  name)
inlinestatic

Definition at line 45 of file SResource.h.

45 {
46 {
47 SResource* res = GetResource(name);
48 if (res != nullptr) return static_cast<T*>(res);
49 }
50 T* object = new T();
51 SResource* res = object;
52
53 res->SetResource(name);
54 return object;
55 }

◆ Get()

template<class T >
static T * CSE::SResource::Get ( std::string  name)
inlinestatic

Definition at line 72 of file SResource.h.

72 {
73 SResource* res = GetResource(std::move(name));
74 if (res != nullptr) return static_cast<T*>(res);
75 return nullptr;
76 }

◆ GetAbsoluteID()

std::string CSE::SResource::GetAbsoluteID ( ) const
inline

Definition at line 30 of file SResource.h.

30 {
31 return m_absoluteId;
32 }

◆ GetAssetReference()

AssetMgr::AssetReference * SResource::GetAssetReference ( std::string  hash = "") const

Definition at line 85 of file SResource.cpp.

85 {
86 if(hash.empty()) hash = m_hash;
87 return CORE->GetCore(ResMgr)->GetAssetReference(std::move(hash));
88}

◆ GetName()

std::string CSE::SResource::GetName ( ) const
inline

Definition at line 26 of file SResource.h.

26 {
27 return m_name;
28 }

◆ LinkResource() [1/2]

void CSE::SResource::LinkResource ( AssetMgr::AssetReference asset)
inline

Definition at line 36 of file SResource.h.

36 {
37 SetResource(asset, false);
38 }

◆ LinkResource() [2/2]

void CSE::SResource::LinkResource ( std::string  name)
inline

Definition at line 40 of file SResource.h.

40 {
41 SetResource(std::move(name), false);
42 }

◆ SetAbsoluteID()

void SResource::SetAbsoluteID ( std::string  id)

Definition at line 40 of file SResource.cpp.

40 {
41 m_absoluteId = std::move(id);
42}

◆ SetHash()

void SResource::SetHash ( std::string &  hash)
overridevirtual

Reimplemented from CSE::SObject.

Definition at line 79 of file SResource.cpp.

79 {
80 std::string srcHash = m_hash;
81 SObject::SetHash(hash);
82 CORE->GetCore(ResMgr)->ChangeHash(srcHash, hash);
83}

◆ SetName()

void SResource::SetName ( std::string  name)

Definition at line 36 of file SResource.cpp.

36 {
37 m_name = std::move(name);
38}

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