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

Public Member Functions

 SResource (std::string classType)
 
 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 ()
 
std::string GetHash () const
 
- Public Member Functions inherited from CSE::VariableBinder
virtual void SetValue (std::string name_str, Arguments value)=0
 
virtual std::string PrintValue () const =0
 
- Public Member Functions inherited from CSE::ReflectionObject
 ReflectionObject (std::string type)
 
void SetClassType (std::string type)
 
const char * GetClassType () const
 
bool IsSameClass (const char *classType) const
 

Static Public Member Functions

template<class T >
static T * Create (const std::string &name)
 
static SResourceCreate (const std::string &name, const std::string &classType)
 
template<class T >
static T * Create (const AssetMgr::AssetReference *asset)
 
static SResourceCreate (const AssetMgr::AssetReference *asset, const std::string &classType)
 
template<class T >
static T * Get (std::string name)
 
static SResourceGet (std::string &name)
 
- Static Public Member Functions inherited from CSE::ReflectionObject
static ReflectionObjectNewObject (const std::string &name)
 

Protected Member Functions

virtual void Init (const AssetMgr::AssetReference *asset)=0
 
- Protected Member Functions inherited from CSE::VariableBinder

Additional Inherited Members

- Protected Types inherited from CSE::VariableBinder
typedef std::vector< std::string > Arguments
 
- Protected Attributes inherited from CSE::SObject
std::string m_hash
 
- Protected Attributes inherited from CSE::ReflectionObject
std::string m_class
 

Detailed Description

Definition at line 17 of file SResource.h.

Constructor & Destructor Documentation

◆ SResource() [1/2]

SResource::SResource ( std::string classType)
explicit

Definition at line 17 of file SResource.cpp.

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

◆ SResource() [2/2]

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

Definition at line 23 of file SResource.cpp.

23 : SObject(isRegister),
24 ReflectionObject(resource->GetClassType()) {
25 if (isRegister) {
26 CORE->GetCore(ResMgr)->Register(this);
27 }
28 m_name = resource->m_name + " (instance)";
29}

Member Function Documentation

◆ Create() [1/4]

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

Definition at line 63 of file SResource.h.

63 {
64 if (asset == nullptr) return nullptr;
65 {
66 SResource* res = GetResource(asset->hash);
67 if (res != nullptr) return static_cast<T*>(res);
68 }
69 T* object = new T();
70 SResource* res = object;
71
72 res->SetResource(const_cast<AssetMgr::AssetReference*>(asset));
73 return object;
74 }

◆ Create() [2/4]

SResource * SResource::Create ( const AssetMgr::AssetReference * asset,
const std::string & classType )
static

Definition at line 102 of file SResource.cpp.

102 {
103 if (asset == nullptr) return nullptr;
104 {
105 SResource* res = GetResource(asset->hash);
106 if (res != nullptr) return res;
107 }
108 SResource* res = static_cast<SResource*>(ReflectionObject::NewObject(classType));
109 res->SetResource(const_cast<AssetMgr::AssetReference*>(asset));
110 return res;
111}

◆ Create() [3/4]

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

Definition at line 48 of file SResource.h.

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

◆ Create() [4/4]

SResource * SResource::Create ( const std::string & name,
const std::string & classType )
static

Definition at line 86 of file SResource.cpp.

86 {
87 {
88 SResource* res = GetResource(name);
89 if (res != nullptr) return res;
90 }
91 SResource* res = static_cast<SResource*>(ReflectionObject::NewObject(classType));
92 res->SetResource(name);
93 return res;
94}

◆ Get() [1/2]

SResource * SResource::Get ( std::string & name)
static

Definition at line 96 of file SResource.cpp.

96 {
97 SResource* res = GetResource(name);
98 if (res != nullptr) return res;
99 return nullptr;
100}

◆ Get() [2/2]

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

Definition at line 79 of file SResource.h.

79 {
80 SResource* res = GetResource(std::move(name));
81 if (res != nullptr) return static_cast<T*>(res);
82 return nullptr;
83 }

◆ GetAbsoluteID()

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

Definition at line 33 of file SResource.h.

33 {
34 return m_absoluteId;
35 }

◆ GetAssetReference()

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

Definition at line 81 of file SResource.cpp.

81 {
82 if (hash.empty()) hash = m_hash;
83 return CORE->GetCore(ResMgr)->GetAssetReference(std::move(hash));
84}

◆ GetName()

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

Definition at line 29 of file SResource.h.

29 {
30 return m_name;
31 }

◆ LinkResource() [1/2]

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

Definition at line 39 of file SResource.h.

39 {
40 SetResource(asset, false);
41 }

◆ LinkResource() [2/2]

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

Definition at line 43 of file SResource.h.

43 {
44 SetResource(std::move(name), false);
45 }

◆ SetAbsoluteID()

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

Definition at line 37 of file SResource.cpp.

37 {
38 m_absoluteId = std::move(id);
39}

◆ SetHash()

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

Reimplemented from CSE::SObject.

Definition at line 75 of file SResource.cpp.

75 {
76 std::string srcHash = m_hash;
77 SObject::SetHash(hash);
78 CORE->GetCore(ResMgr)->ChangeHash(srcHash, hash);
79}

◆ SetName()

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

Definition at line 33 of file SResource.cpp.

33 {
34 m_name = std::move(name);
35}

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