You.i Engine
YiAsset.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_ASSET_H_
3 #define _YI_ASSET_H_
4 
5 #include "utility/YiRtti.h"
6 #include "utility/YiString.h"
8 
9 #include <memory>
10 
11 class CYIAssetLoadParams;
12 class IYIGPUObject;
13 
33 class CYIAsset : public std::enable_shared_from_this<CYIAsset>, public CYIScriptableRTTIObject
34 {
35  friend class CYIAssetManager;
36  friend class CYIAssetLoader;
37  friend class CYIDecoderThread;
38 
39 public:
40 
44  enum PATH_TYPE
45  {
48  };
49 
50  virtual ~CYIAsset();
51 
57  const CYIString &GetPath() const;
58 
64 
72  virtual std::pair<uint32_t, uint32_t> GetApproximateSize() const;
73 
83  bool SetName(const CYIString &name);
84 
90  const CYIString &GetName() const;
91 
96  bool Load();
97 
102  void Unload();
103 
107  bool IsLoaded() const;
108 
114  bool Equals(const std::shared_ptr<CYIAsset> &pAsset);
115 
122  virtual bool Prepare();
123 
124 protected:
126 
127  CYIAsset();
128 
133  ssize_t GetID() const;
134 
142  void SetPath(const CYIString &path, PATH_TYPE ePathType);
143  void SetApproximateSize(uint32_t nSize);
144  void SetLoaded(bool bAssetLoaded);
145  void SetLoadParameters(std::unique_ptr<CYIAssetLoadParams> pParams);
146 
147  virtual void OnLoad();
148  virtual void OnUnload();
149 
150 private:
155  void SetID(ssize_t id);
156 
157  bool m_bIsLoaded;
158  ssize_t m_nID;
159  uint32_t m_uResourceSize;
160  CYIString m_Name;
161  CYIString m_Path;
162  std::unique_ptr<CYIAssetLoadParams> m_pLoadParams;
163 
165  YI_TYPE_BASES_WITH_SCRIPTABLE_BASE(CYIAsset)
166 };
167 
170 #endif // _YI_ASSET_H_
virtual void OnUnload()
The base class for an C++ object that has RTTI information and is accesible from script source code...
Definition: YiScriptableRTTIObject.h:28
#define YI_DISALLOW_COPY_AND_ASSIGN(TypeName)
Delete the copy constructor and assignment operator (and consequently the move constructor as well) ...
Definition: YiPredef.h:114
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:35
bool SetName(const CYIString &name)
void SetApproximateSize(uint32_t nSize)
virtual std::pair< uint32_t, uint32_t > GetApproximateSize() const
Definition: YiAsset.h:46
PATH_TYPE
Definition: YiAsset.h:44
Base class for decoders which can accept specialized parameter objects.
Definition: YiAssetLoadParams.h:16
friend class CYIDecoderThread
Definition: YiAsset.h:37
void SetLoaded(bool bAssetLoaded)
An interface for managing GPU-bound objects such as shaders and textures.
Definition: YiGPUObject.h:18
bool Equals(const std::shared_ptr< CYIAsset > &pAsset)
virtual ~CYIAsset()
bool Load()
bool IsLoaded() const
void SetLoadParameters(std::unique_ptr< CYIAssetLoadParams > pParams)
void SetPath(const CYIString &path, PATH_TYPE ePathType)
This class provides a cache that users can use to store various types of assets.
Definition: YiAssetManager.h:43
const CYIString & GetName() const
int ssize_t
Definition: YiPredefWin32.h:133
static ssize_t INVALID_ID
Definition: YiAsset.h:125
Base class for any asset. An asset provides functions for dynamically loading and unloading itself an...
Definition: YiAsset.h:33
Definition: YiAsset.h:47
virtual bool Prepare()
const CYIString & GetPath() const
This file contains the classes and macros used to implement RTTI in You.i Engine. ...
ssize_t GetID() const
virtual void OnLoad()
void Unload()
CYIAssetLoadParams * GetLoadParameters() const
The asset loader provides an interface for loading asset objects, which in turn wrap resource objects...
Definition: YiAssetLoader.h:39