Atoms Crowd  4.1.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 }
Atoms::AgentTypes::AgentTypes
AgentTypes()
constructor
Atoms::AgentTypes::agentType
AgentTypePtr agentType(const std::string &typeName)
Gets the agent type with the given name.
Atoms::AgentTypes::AgentTypes
AgentTypes(const AgentTypes &)
Copy constructor.
Atoms::AgentTypes::clear
void clear()
Removes all agent types.
Atoms::AgentTypes::addAgentType
void addAgentType(const std::string &name, const AgentType &agentType, bool replace=true)
Adds an agent type to the map.
Atoms::AgentType
Agent type.
Definition: AgentType.h:30
Atoms::AgentTypes::operator=
AgentTypes & operator=(const AgentTypes &)
Assign operator.
Atoms::AgentTypes::~AgentTypes
~AgentTypes()
Destructor.
Atoms::AgentTypePtr
AtomsPtr< AgentType > AgentTypePtr
Agent type pointer.
Definition: AgentType.h:17
Atoms::AgentTypes::numAgentTypes
unsigned int numAgentTypes() const
Gets the number of agent types.
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::AgentTypes::agentTypeNames
std::vector< std::string > agentTypeNames() const
Gets all agent types names.
Atoms::AgentTypes
Container for all agent types.
Definition: AgentTypes.h:20
Atoms::AgentTypes::agentType
AgentTypeCPtr agentType(const std::string &typeName) const
Gets the agent type with the given name.
Atoms::AgentTypes::instance
static AgentTypes & instance()
Singleton access for global data.
Atoms::AgentTypes::removeAgentType
void removeAgentType(const std::string &name)
Removes an agent type from the map.
Atoms::AgentTypes::agentTypeExists
bool agentTypeExists(const std::string &name) const
Checks if an agent type with the given name exists.
Atoms::AgentTypeCPtr
AtomsPtr< const AgentType > AgentTypeCPtr
Agent type const pointer.
Definition: AgentType.h:21