fipa_acl  1.4
role.h
Go to the documentation of this file.
1 #ifndef FIPA_ACL_ROLE_H
2 #define FIPA_ACL_ROLE_H
3 
4 #include <map>
5 #include <string>
6 #include <fipa_acl/message_generator/agent_id.h>
7 
8 namespace fipa {
9 namespace acl {
10 
11 class AgentID;
12 
13 typedef std::string RoleId;
14 
15 class Role
16 {
17 
18 private:
19  RoleId mId;
20 
21 protected:
25  const static RoleId UNDEFINED_ID;
26  const static RoleId SELF_ID;
27 
28 public:
32  Role();
33 
37  Role(const RoleId& id);
38 
42  Role(const Role&);
43 
47  static const Role self();
48 
52  RoleId getId() const { return mId; }
53 
58  std::string toString() const { return mId; }
59 
60  bool operator<(const Role& other) const
61  {
62  return mId < other.mId;
63  }
64 
65  bool operator!=(const Role& other) const
66  {
67  return !(mId == other.mId);
68  }
69 
70  bool operator==(const Role& other) const
71  {
72  return mId == other.mId;
73  }
74 
75  Role& operator=(const Role& other)
76  {
77  mId = other.mId;
78  return *this;
79  }
80 };
81 
82 class UndefinedRole : public Role
83 {
84 public:
85  UndefinedRole();
86 };
87 
88 class SelfRole : public Role
89 {
90 public:
91  SelfRole();
92 };
93 
99 {
100 private:
101  // The mapping between roles and actual agents
102  std::map<Role, AgentIDList> mExpectedAgentMapping;
103 
104 public:
105 
109  RoleMapping();
110 
114  const std::map<Role, AgentIDList>& getMapping() const { return mExpectedAgentMapping; }
115 
119  void setSelf(const AgentID& id);
120 
124  bool isSelf(const AgentID& id) const;
125 
129  AgentID getSelf() const;
130 
134  void addRole(const Role& role);
135 
139  void addExpectedAgent(const Role& role, const AgentID& agent);
140 
144  void clearExpectedAgents(const Role& role);
145 
151  void resetExpectedAgents();
152 
157  const AgentIDList& getExpectedAgents(const Role& role) const;
158 
163  bool isExpected(const Role& role, const AgentID& agent) const;
164 
168  std::string toString() const;
169 };
170 
171 } // end namespace acl
172 } // end namespace fipa
173 #endif // FIPA_ACL_ROLE_H
std::string RoleId
Definition: role.h:11
Role & operator=(const Role &other)
Definition: role.h:75
bool operator!=(const Role &other) const
Definition: role.h:65
const std::map< Role, AgentIDList > & getMapping() const
Definition: role.h:114
std::vector< AgentID > AgentIDList
Definition: agent_id.h:20
bool operator==(const Role &other) const
Definition: role.h:70
RoleId getId() const
Definition: role.h:52
Mapping between roles and actual agent ids.
Definition: role.h:98
std::string toString() const
Definition: role.h:58
static const RoleId UNDEFINED_ID
Definition: role.h:25
static const RoleId SELF_ID
Definition: role.h:26
bool operator<(const Role &other) const
Definition: role.h:60
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
Definition: agent_id.h:37
Foundation of Physical Intelligent Agents.
Definition: conversation.cpp:6