Mapping between roles and actual agent ids.
More...
#include <role.h>
Mapping between roles and actual agent ids.
Definition at line 98 of file role.h.
◆ RoleMapping()
| fipa::acl::RoleMapping::RoleMapping |
( |
| ) |
|
Default constructor
Definition at line 36 of file role.cpp.
void addRole(const Role &role)
void addExpectedAgent(const Role &role, const AgentID &agent)
◆ addExpectedAgent()
| void fipa::acl::RoleMapping::addExpectedAgent |
( |
const Role & |
role, |
|
|
const AgentID & |
agent |
|
) |
| |
Add an agent to the list of expected agents for a specific role
Definition at line 83 of file role.cpp.
85 std::map<Role, AgentIDList>::iterator it = mExpectedAgentMapping.find(role);
86 if(it == mExpectedAgentMapping.end())
88 std::string msg =
"Unexpected role '" + role.toString() +
"'.";
89 LOG_ERROR(
"%s", msg.c_str());
90 throw std::runtime_error(msg);
94 AgentIDList::iterator eit = std::find(expectedAgents.begin(), expectedAgents.end(), agent);
95 if(eit == expectedAgents.end())
97 expectedAgents.push_back(agent);
std::vector< AgentID > AgentIDList
◆ addRole()
| void fipa::acl::RoleMapping::addRole |
( |
const Role & |
role | ) |
|
Add a role to this rolemapping
Definition at line 78 of file role.cpp.
80 mExpectedAgentMapping.insert( std::pair<Role, AgentIDList>(role,
AgentIDList()));
std::vector< AgentID > AgentIDList
◆ clearExpectedAgents()
| void fipa::acl::RoleMapping::clearExpectedAgents |
( |
const Role & |
role | ) |
|
Clear list of expected agents for a specific role
Definition at line 103 of file role.cpp.
105 std::map<Role, AgentIDList>::iterator it = mExpectedAgentMapping.find(role);
106 if(it != mExpectedAgentMapping.end())
◆ getExpectedAgents()
| const AgentIDList & fipa::acl::RoleMapping::getExpectedAgents |
( |
const Role & |
role | ) |
const |
Get the list of expected agents for a given role
- Exceptions
-
| std::runtime_error | if the role does not exist |
Definition at line 153 of file role.cpp.
155 std::map<Role, AgentIDList>::const_iterator it = mExpectedAgentMapping.find(role);
156 if(it == mExpectedAgentMapping.end())
158 std::string msg =
"Unexpected role '" + role.toString() +
"'.";
159 LOG_ERROR(
"%s", msg.c_str());
160 throw std::runtime_error(msg);
◆ getMapping()
| const std::map<Role, AgentIDList>& fipa::acl::RoleMapping::getMapping |
( |
| ) |
const |
|
inline |
Returns the mapping
Definition at line 114 of file role.h.
114 {
return mExpectedAgentMapping; }
◆ getSelf()
| AgentID fipa::acl::RoleMapping::getSelf |
( |
| ) |
const |
Retrieve the AgentID of self
Definition at line 59 of file role.cpp.
61 std::map<Role, AgentIDList>::const_iterator it = mExpectedAgentMapping.find(SelfRole());
62 if(it != mExpectedAgentMapping.end())
64 return it->second.front();
70 return UndefinedAgentID();
◆ isExpected()
| bool fipa::acl::RoleMapping::isExpected |
( |
const Role & |
role, |
|
|
const AgentID & |
agent |
|
) |
| const |
Check whether the given agent belongs to the list of expected receivers
- Exceptions
-
| If | role is completely unknown to this role mapping |
Definition at line 120 of file role.cpp.
124 boost::regex roleRegex(role.getId());
125 if(regex_match(agent.getName(), roleRegex))
132 bool expected =
false;
134 if(expectedAgents.empty())
140 AgentIDList::const_iterator eit = expectedAgents.begin();
141 for(; eit != expectedAgents.end(); ++eit)
143 boost::regex regex(eit->getName() +
"$");
144 if(regex_match(agent.getName(), regex))
std::vector< AgentID > AgentIDList
const AgentIDList & getExpectedAgents(const Role &role) const
◆ isSelf()
| bool fipa::acl::RoleMapping::isSelf |
( |
const AgentID & |
id | ) |
const |
Test whether an agent id represents 'self'
Definition at line 73 of file role.cpp.
◆ resetExpectedAgents()
| void fipa::acl::RoleMapping::resetExpectedAgents |
( |
| ) |
|
Clear list of expected agents for all known roles
Note that the self role remains with will be reset to UndefinedAgentID
Definition at line 112 of file role.cpp.
114 mExpectedAgentMapping.clear();
void addRole(const Role &role)
void addExpectedAgent(const Role &role, const AgentID &agent)
◆ setSelf()
| void fipa::acl::RoleMapping::setSelf |
( |
const AgentID & |
id | ) |
|
Add the role 'self'
Definition at line 42 of file role.cpp.
44 std::map<Role, AgentIDList>::iterator it = mExpectedAgentMapping.find(SelfRole());
46 assert(!it->second.empty());
48 if(it->second.front() == UndefinedAgentID())
53 std::string msg =
"Self is already set";
55 throw std::runtime_error(msg);
void addExpectedAgent(const Role &role, const AgentID &agent)
◆ toString()
| std::string fipa::acl::RoleMapping::toString |
( |
| ) |
const |
Stringify role mapping
Definition at line 165 of file role.cpp.
167 std::stringstream ss;
168 std::map<Role, AgentIDList>::const_iterator cit = mExpectedAgentMapping.begin();
169 for(; cit != mExpectedAgentMapping.end(); ++cit)
171 ss <<
"'" << cit->first.toString() <<
"': ";
std::vector< AgentID > AgentIDList
The documentation for this class was generated from the following files:
- /build/rock-master-18.09-multiagent-fipa-acl-0.20180914/src/conversation_monitor/role.h
- /build/rock-master-18.09-multiagent-fipa-acl-0.20180914/src/conversation_monitor/role.cpp