Atoms Crowd  7.0.0
BehaviourModules.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/Globals.h>
11 #include <AtomsCore/Globals.h>
12 #include <Atoms/BehaviourModule.h>
13 #include <map>
14 
15 
16 namespace Atoms
17 {
19 
21  class ATOMS_EXPORT BehaviourModules
22  {
23  public:
24 
25  enum ModuleType
26  {
27  kNone = -1,
28  kNative = 0,
29  kScript = 1
30  };
31 
32  typedef BehaviourModule* (*creatorFn)(const std::string& parameter);
33 
36 
38 
42  AtomsPtr<BehaviourModule> createBehaviourModule(const std::string& name);
43 
45 
49  BehaviourModule* createBehaviourModuleRawPtr(const std::string& name);
50 
52 
58  bool registerBehaviourModule(const std::string& moduleName, creatorFn func, unsigned int moduleType = kNative, bool replace = false, const std::string category = "");
59 
61 
65  bool deregisterBehaviourModule(const std::string& name);
66 
68 
71  std::vector<std::string> getRegisteredBehaviourModules();
72 
74 
77  const std::string getBehaviourModuleCategory(const std::string &moduleName);
78 
80 
84  bool isRegistered(const std::string& name);
85 
87  void clear();
88 
90  short moduleType(const std::string& name);
91 
92  private:
93 
96 
99 
102 
104  BehaviourModules& operator=(const BehaviourModules&);
105 
106  private:
107 
109 
112  std::map<std::string, creatorFn> m_factoryMap;
113 
114  std::map<std::string, short> m_moduleTypes;
115 
116  std::map<std::string, std::string> m_moduleCategories;
117  };
118 }
Behaviour module.
Definition: BehaviourModule.h:32
Behaviour module factory.
Definition: BehaviourModules.h:22
bool isRegistered(const std::string &name)
Check if a behaviour module is registered.
AtomsPtr< BehaviourModule > createBehaviourModule(const std::string &name)
Creates a behaviour module.
bool deregisterBehaviourModule(const std::string &name)
Deregisters a Behaviour module type from the factory.
const std::string getBehaviourModuleCategory(const std::string &moduleName)
Gets a registered behaviour category.
BehaviourModule * createBehaviourModuleRawPtr(const std::string &name)
Creates a behaviour module.
static BehaviourModules & instance()
Singleton access.
bool registerBehaviourModule(const std::string &moduleName, creatorFn func, unsigned int moduleType=kNative, bool replace=false, const std::string category="")
Registers a behaviour module in the factory.
std::vector< std::string > getRegisteredBehaviourModules()
Gets all registered behaviour modules.
void clear()
Clear factory.
short moduleType(const std::string &name)
Gets the module type.
Atoms namespace.
Definition: Agent.h:29