EzGL
Object.hpp
Go to the documentation of this file.
1 /* EzGL/Object.hpp
2  *
3  * Copyright (c) 2018 Kirk Lange <github.com/kirklange>
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 
22 #ifndef EZGL_OBJECT_HPP
23 #define EZGL_OBJECT_HPP
24 
29 #include "nlohmann/json.hpp"
30 
31 #include <memory>
32 #include <string>
33 
34 
35 
36 namespace EzGL
37 {
38 
40 using ObjectPtr = std::unique_ptr<class Object>;
41 
46 class Object final
47 {
48 public:
57  static int Main(std::string const &fileName);
58  static int Main(char const *fileName);
59 
69  static Object& Create(std::string const &objectName);
70 
78  static Object& Create(nlohmann::json &config);
79 
85  static bool Destroy(Object const &object);
86 
91  static void UpdateAll();
92 
93  bool operator==(Object const &other);
94  bool operator!=(Object const &other);
95 
96  void init(Object &main);
97  void update(Object &main);
98 
99  // One should never have to explicitly call this.
100  ~Object();
101 
107  nlohmann::json data;
108 
116  Object const *other;
117 
118 private:
119  Object(nlohmann::json &config);
120  Object(Object const &other) = delete;
121  //Object& operator=(Object const &other) = delete;
122 
123  class Impl;
124  Impl *impl;
125 };
126 
127 }; /* namespace EzGL */
128 
129 
130 
131 #endif /* EZGL_OBJECT_HPP */
Object factory and Main game executor.
Definition: Object.hpp:46
static bool Destroy(Object const &object)
Object destroyer.
Definition: Object.cpp:213
Object const * other
Interactor object pointer.
Definition: Object.hpp:116
std::unique_ptr< class Object > ObjectPtr
Object smart pointer type.
Definition: Object.hpp:40
nlohmann::json data
Modifiable object data.
Definition: Object.hpp:107
static Object & Create(std::string const &objectName)
Object factory.
Definition: Object.cpp:196
static void UpdateAll()
Only graphics API binding components should call this.
Definition: Object.cpp:231
static int Main(std::string const &fileName)
Initialize and run the game.
Definition: Object.cpp:102