Atoms Crowd  7.0.0
AgentTypes.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 <Atoms/AgentType.h>
12 #include <map>
13 #include <vector>
14 #include <mutex>
15 
16 namespace Atoms
17 {
19  class ATOMS_EXPORT AgentTypes
20  {
21  public:
22 
25 
28 
31 
34 
36  static AgentTypes& instance();
37 
39 
43  AgentTypePtr agentType(const std::string& typeName);
44 
46 
50  AgentTypeCPtr agentType(const std::string& typeName) const;
51 
53 
57  void addAgentType(const std::string& name, const AgentType& agentType, bool replace = true);
58 
60 
63  void removeAgentType(const std::string& name);
64 
66 
69  std::vector<std::string> agentTypeNames() const;
70 
72 
76  bool agentTypeExists(const std::string& name) const;
77 
79  unsigned int numAgentTypes() const;
80 
82  void clear();
83 
84  private:
85 
86  typedef std::map<std::string, AgentTypePtr> AgentTypesMap;
87 
88  AgentTypesMap m_agentTypesMap;
89 
90  mutable std::mutex m_mutex;
91  };
92 }
Agent type.
Definition: AgentType.h:30
Container for all agent types.
Definition: AgentTypes.h:20
void addAgentType(const std::string &name, const AgentType &agentType, bool replace=true)
Adds an agent type to the map.
AgentTypes & operator=(const AgentTypes &)
Assign operator.
AgentTypeCPtr agentType(const std::string &typeName) const
Gets the agent type with the given name.
bool agentTypeExists(const std::string &name) const
Checks if an agent type with the given name exists.
std::vector< std::string > agentTypeNames() const
Gets all agent types names.
static AgentTypes & instance()
Singleton access for global data.
AgentTypePtr agentType(const std::string &typeName)
Gets the agent type with the given name.
void removeAgentType(const std::string &name)
Removes an agent type from the map.
~AgentTypes()
Destructor.
AgentTypes()
constructor
void clear()
Removes all agent types.
AgentTypes(const AgentTypes &)
Copy constructor.
unsigned int numAgentTypes() const
Gets the number of agent types.
Atoms namespace.
Definition: Agent.h:29
AtomsPtr< AgentType > AgentTypePtr
Agent type pointer.
Definition: AgentType.h:17
AtomsPtr< const AgentType > AgentTypeCPtr
Agent type const pointer.
Definition: AgentType.h:21