Atoms Crowd  4.1.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 }
Atoms::BehaviourModules::getRegisteredBehaviourModules
std::vector< std::string > getRegisteredBehaviourModules()
Gets all registered behaviour modules.
Atoms::BehaviourModules::clear
void clear()
Clear factory.
Atoms::BehaviourModules::registerBehaviourModule
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.
Atoms::BehaviourModules::deregisterBehaviourModule
bool deregisterBehaviourModule(const std::string &name)
Deregisters a Behaviour module type from the factory.
Atoms::BehaviourModules
Behaviour module factory.
Definition: BehaviourModules.h:22
Atoms::BehaviourModules::instance
static BehaviourModules & instance()
Singleton access.
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::BehaviourModule
Behaviour module.
Definition: BehaviourModule.h:31
Atoms::BehaviourModules::moduleType
short moduleType(const std::string &name)
Gets the module type.
Atoms::BehaviourModules::createBehaviourModuleRawPtr
BehaviourModule * createBehaviourModuleRawPtr(const std::string &name)
Creates a behaviour module.
Atoms::BehaviourModules::getBehaviourModuleCategory
const std::string getBehaviourModuleCategory(const std::string &moduleName)
Gets a registered behaviour category.
Atoms::BehaviourModules::isRegistered
bool isRegistered(const std::string &name)
Check if a behaviour module is registered.
Atoms::BehaviourModules::createBehaviourModule
AtomsPtr< BehaviourModule > createBehaviourModule(const std::string &name)
Creates a behaviour module.