i6engine  1.0
GOFactory.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_MODULES_GOFACTORY_H__
26 #define __I6ENGINE_MODULES_GOFACTORY_H__
27 
28 #include <map>
29 
32 
34 
35 namespace i6e {
36 namespace api {
37  class GameObject;
38 } /* namespace api */
39 
40 namespace modules {
41 
42  class ComponentFactory;
44 
46 
52  class GOFactory {
53  public:
61 
69  void registerGOTemplate(const std::string & file);
70 
80  GOPtr createGO(const int64_t goid, const core::IPKey & owner, uint64_t uuid, const std::string & tpl, const api::objects::GOTemplate & templ, const bool sender);
81  GOPtr createGO(const std::string & tmpl, int64_t goid, const core::IPKey & owner, uint64_t uuid, const api::objects::GOTemplate & templ, const bool sender);
82 
90  void loadLevel(const std::string & file, const std::string & flags, const std::function<void(uint16_t)> & callback);
91 
92  private:
99  std::map<std::string, api::objects::GOTemplate> _templateList;
100 
104  ObjectManager * _manager;
105 
109  ComponentFactory * _compFactory;
110 
114  GOFactory(const GOFactory &) = delete;
115 
119  GOFactory & operator=(const GOFactory &) = delete;
120 
122  };
123 
124 } /* namespace modules */
125 } /* namespace i6e */
126 
127 #endif /* __I6ENGINE_MODULES_GOFACTORY_H__ */
128 
Factory in order to create Component.
GOPtr createGO(const int64_t goid, const core::IPKey &owner, uint64_t uuid, const std::string &tpl, const api::objects::GOTemplate &templ, const bool sender)
creates a new GameObject of that type
GOFactory(ObjectManager *m, ComponentFactory *c)
used to easily create special GameObjects
#define ASSERT_THREAD_SAFETY_HEADER
A shared pointer counting references and adds objects being not referenced any more to an internal li...
Definition: sharedPtr.h:50
internal representation of all GameObject templates
Definition: ObjectConfig.h:104
void registerGOTemplate(const std::string &file)
register a new Template After a template is registered you can easily create new objects of that type...
void loadLevel(const std::string &file, const std::string &flags, const std::function< void(uint16_t)> &callback)
loads a level out of the given file with the given flags
utils::sharedPtr< api::GameObject, api::GameObject > GOPtr
Definition: GOFactory.h:43
Factory in order to create GameObjects.
Definition: GOFactory.h:52