CUGL
Cornell University Game Library
CUAsset.h
1 //
2 // CUAssetManager.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module provides an abstract class for generic assets (such as a model
6 // file or level layout) not explicitly included in the existing asset classes.
7 // It is fairly experimental, so use at your own risk. If there are certain
8 // assets that we overlooked that are the same across all projects, we will
9 // consider adding them to the engine at a later date.
10 //
11 // As this is an abstract class, it has no static constructors. However, we
12 // still separate initialization from the constructor as with all classes in
13 // this engine.
14 //
15 //
16 // CUGL zlib License:
17 // This software is provided 'as-is', without any express or implied
18 // warranty. In no event will the authors be held liable for any damages
19 // arising from the use of this software.
20 //
21 // Permission is granted to anyone to use this software for any purpose,
22 // including commercial applications, and to alter it and redistribute it
23 // freely, subject to the following restrictions:
24 //
25 // 1. The origin of this software must not be misrepresented; you must not
26 // claim that you wrote the original software. If you use this software
27 // in a product, an acknowledgment in the product documentation would be
28 // appreciated but is not required.
29 //
30 // 2. Altered source versions must be plainly marked as such, and must not
31 // be misrepresented as being the original software.
32 //
33 // 3. This notice may not be removed or altered from any source distribution.
34 //
35 // Author: Walker White
36 // Version: 1/7/16
37 //
38 #ifndef __CU_ASSET_H__
39 #define __CU_ASSET_H__
40 #include <cugl/assets/CULoader.h>
41 
42 namespace cugl {
43 
66 class Asset {
67 public:
68 #pragma mark -
69 #pragma mark Initializers
70 
80  virtual bool init(const std::string& file) {
81  bool success = preload(file);
82  return success && materialize();
83  }
84 
100  virtual bool init(const std::shared_ptr<JsonValue>& json) {
101  bool success = preload(json);
102  return success && materialize();
103  }
104 
105 #pragma mark -
106 #pragma mark Loading Interface
107 
128  virtual bool preload(const std::string& file) { return false; }
129 
156  virtual bool preload(const std::shared_ptr<JsonValue>& json) { return false; }
157 
168  virtual bool materialize() { return true; };
169 };
170 
171 }
172 
173 #endif /* __CU_ASSET_H__ */
virtual bool preload(const std::string &file)
Definition: CUAsset.h:128
virtual bool materialize()
Definition: CUAsset.h:168
virtual bool init(const std::string &file)
Definition: CUAsset.h:80
virtual bool preload(const std::shared_ptr< JsonValue > &json)
Definition: CUAsset.h:156
virtual bool init(const std::shared_ptr< JsonValue > &json)
Definition: CUAsset.h:100
Definition: CUAnimationNode.h:52
Definition: CUAsset.h:66