Implements the general AgentID functionality, which is present throughout the fipa specifications(FIPA at http://www.fipa.org). Functionality may need to be extended as further modules are implemented Important notice: the probably main field of an AgentID, the actual id, is not yet declared/implemented, as it was not need for the encoding and it was not discussed what should it be.
More...
#include <agent_id.h>
Inherited by fipa::acl::UndefinedAgentID.
|
| static bool | compareEqual (const AgentID &a, const AgentID &b, int depth) |
| | alternative function for equality operator; the depth can be specified through the depth param More...
|
| |
|
| static const std::string | UNDEFINED = "agent_id:undefined" |
| |
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIPA at http://www.fipa.org). Functionality may need to be extended as further modules are implemented Important notice: the probably main field of an AgentID, the actual id, is not yet declared/implemented, as it was not need for the encoding and it was not discussed what should it be.
Definition at line 37 of file agent_id.h.
◆ AgentID() [1/2]
| fipa::acl::AgentID::AgentID |
( |
| ) |
|
Default constructor.
Definition at line 21 of file agent_id.cpp.
void setName(const std::string &name)
the method checks whether the passed name string is a word or not(according to the fipa spec) ...
static const std::string UNDEFINED
◆ AgentID() [2/2]
| fipa::acl::AgentID::AgentID |
( |
const std::string & |
name | ) |
|
Construct an AgentID by name.
- Parameters
-
Definition at line 26 of file agent_id.cpp.
void setName(const std::string &name)
the method checks whether the passed name string is a word or not(according to the fipa spec) ...
◆ addAddress()
| void fipa::acl::AgentID::addAddress |
( |
const std::string & |
adr | ) |
|
the method checks whether the passed address string is a word or not(according to the fipa spec)
- Parameters
-
- Exceptions
-
| if | address contains invalid characters |
Definition at line 48 of file agent_id.cpp.
53 snprintf(buffer, 128,
"fipa::acl::AgentID: address '%s' contains invalid characters", address.c_str());
54 throw std::runtime_error(buffer);
56 mAddresses.push_back(address);
const std::string illegalWordStart
const std::string illegalWordChars
◆ addResolver()
| void fipa::acl::AgentID::addResolver |
( |
const AgentID & |
aid | ) |
|
Add resolver.
- Parameters
-
| aid | Resolver identified by its agentid |
Definition at line 59 of file agent_id.cpp.
63 if ( find(mResolvers.begin(), mResolvers.end(),aid) == mResolvers.end() )
65 mResolvers.push_back(aid);
◆ addUserdefParam()
| void fipa::acl::AgentID::addUserdefParam |
( |
const UserdefParam & |
p | ) |
|
Add a userdefined parameter.
- Parameters
-
| p | The userdefined parameter |
Definition at line 80 of file agent_id.cpp.
82 mParameters.push_back(p);
◆ compareEqual()
| bool fipa::acl::AgentID::compareEqual |
( |
const AgentID & |
a, |
|
|
const AgentID & |
b, |
|
|
int |
depth |
|
) |
| |
|
static |
alternative function for equality operator; the depth can be specified through the depth param
Definition at line 90 of file agent_id.cpp.
92 if (a.getName() != b.getName())
98 std::vector<std::string> addrA = a.getAddresses();
99 std::vector<std::string> addrB = b.getAddresses();
100 std::vector<std::string>::iterator sita = addrA.begin();
101 std::vector<std::string>::iterator sitb = addrB.begin();
103 while (sita != addrA.end())
106 sitb = addrB.begin();
107 while (sitb != addrB.end())
112 sita = addrA.begin();
136 std::vector<AgentID> agentsA = a.getResolvers();
137 std::vector<AgentID> agentsB = b.getResolvers();
138 std::vector<AgentID>::iterator ait = agentsA.begin();
139 std::vector<AgentID>::iterator bit = agentsB.begin();
141 while (ait != agentsA.end())
144 bit = agentsB.begin();
145 while (bit != agentsB.end())
150 ait = agentsA.begin();
162 if (!agentsA.empty())
164 if (!agentsB.empty())
171 std::vector<UserdefParam> paramsA = a.getUserdefParams();
172 std::vector<UserdefParam> paramsB = b.getUserdefParams();
173 std::vector<UserdefParam>::iterator pita = paramsA.begin();
174 std::vector<UserdefParam>::iterator pitb = paramsB.begin();
176 while (pita != paramsA.end())
179 pitb = paramsB.begin();
181 while (pitb != paramsB.end())
188 pita = paramsA.begin();
190 pitb = paramsB.end();
204 if ( paramsA.empty() && paramsB.empty())
static bool compareEqual(const AgentID &a, const AgentID &b, int depth)
alternative function for equality operator; the depth can be specified through the depth param ...
◆ deleteResolver()
| void fipa::acl::AgentID::deleteResolver |
( |
const AgentID & |
id | ) |
|
Delete a resolver.
- Parameters
-
Definition at line 69 of file agent_id.cpp.
71 std::vector<AgentID>::iterator it = find(mResolvers.begin(), mResolvers.end(),aid);
74 if( it != mResolvers.end() )
◆ empty()
| bool fipa::acl::AgentID::empty |
( |
| ) |
const |
Check if AgentId is empty, i.e. does not contain a name.
- Returns
- True, if empty, False otherwise
Definition at line 210 of file agent_id.cpp.
212 return mName.empty();
◆ getAddresses()
| const std::vector<std::string>& fipa::acl::AgentID::getAddresses |
( |
| ) |
const |
|
inline |
Retrieve list of addresses.
- Returns
- List of addresses
Definition at line 110 of file agent_id.h.
110 {
return mAddresses; }
◆ getName()
| const std::string& fipa::acl::AgentID::getName |
( |
| ) |
const |
|
inline |
setter and getter methods for all fields; they do not result in deep-copies assignments/retreivals, but this can be easily changed if needed through the overloaded operator which do
Definition at line 90 of file agent_id.h.
◆ getResolvers()
| const Resolvers& fipa::acl::AgentID::getResolvers |
( |
| ) |
const |
|
inline |
Get list of resolvers.
- Returns
- list of resolvers, i.e. agentids
Definition at line 127 of file agent_id.h.
127 {
return mResolvers; }
◆ getUserdefParams()
| const std::vector<UserdefParam>& fipa::acl::AgentID::getUserdefParams |
( |
| ) |
const |
|
inline |
Get the all userdefined parameter.
- Returns
- List of userdefined parameters
Definition at line 150 of file agent_id.h.
150 {
return mParameters; }
◆ isValid()
| bool fipa::acl::AgentID::isValid |
( |
| ) |
const |
Test if this is a valid agent, i.e. is neither an instance of an undefined agent nor has it an empty name field
Definition at line 31 of file agent_id.cpp.
bool empty() const
Check if AgentId is empty, i.e. does not contain a name.
static const std::string UNDEFINED
◆ operator!=()
| bool fipa::acl::AgentID::operator!= |
( |
const AgentID & |
other | ) |
const |
|
inline |
Allow testing on inequality of agents based on the agents' names only.
- Returns
- true if the agents' names are different, false otherwise
Definition at line 179 of file agent_id.h.
179 {
return !(*
this == other); }
◆ operator<()
| bool fipa::acl::AgentID::operator< |
( |
const AgentID & |
other | ) |
const |
|
inline |
Allow comparing two agents, based on the agent name only.
- Returns
- True if first agent's name < other agent's name
Definition at line 185 of file agent_id.h.
185 {
return this->
getName() < other.getName(); }
const std::string & getName() const
setter and getter methods for all fields; they do not result in deep-copies assignments/retreivals, but this can be easily changed if needed through the overloaded operator which do
◆ operator==()
| bool fipa::acl::AgentID::operator== |
( |
const AgentID & |
other | ) |
const |
overloaded equality operator for AgentID; the signature of the function was intentionally changed from the normal operator== (const type&, const type&)
The parameters are not passed by reference on purpose so that the copy constructor of the class is called. This is necessary because in the comparison, pointer fields are modified(removed) and we don't want this to affect the original object
Definition at line 85 of file agent_id.cpp.
static bool compareEqual(const AgentID &a, const AgentID &b, int depth)
alternative function for equality operator; the depth can be specified through the depth param ...
static int msResolverComparisonDepth
◆ setAddresses()
| void fipa::acl::AgentID::setAddresses |
( |
const std::vector< std::string > & |
addresses | ) |
|
|
inline |
Set list of addresses – overwrites existing list of addresses.
Definition at line 115 of file agent_id.h.
115 { mAddresses = addresses; }
◆ setName()
| void fipa::acl::AgentID::setName |
( |
const std::string & |
name | ) |
|
the method checks whether the passed name string is a word or not(according to the fipa spec)
- Parameters
-
- Exceptions
-
| if | name contains invalid characters |
Definition at line 36 of file agent_id.cpp.
41 snprintf(buffer, 128,
"fipa::acl::AgentID: name '%s' contains invalid characters", name.c_str());
42 throw std::runtime_error(buffer);
const std::string illegalWordStart
const std::string illegalWordChars
◆ setResolvers()
| void fipa::acl::AgentID::setResolvers |
( |
const Resolvers & |
resolvers | ) |
|
|
inline |
Set list of resolvers.
Definition at line 132 of file agent_id.h.
132 { mResolvers = resolvers; }
◆ setUserdefParams()
| void fipa::acl::AgentID::setUserdefParams |
( |
const std::vector< UserdefParam > & |
params | ) |
|
|
inline |
Set all userdefined parameters
Definition at line 155 of file agent_id.h.
155 { mParameters = params; }
◆ toString()
| std::string fipa::acl::AgentID::toString |
( |
size_t |
indent = 0 | ) |
const |
Stringify object
- Returns
- string representation of agent id
Definition at line 215 of file agent_id.cpp.
217 std::string hspace(indent,
' ');
218 std::stringstream ss;
219 ss << hspace <<
"AgentID: " <<
mName << std::endl;
220 ss << hspace <<
" addresses:" << std::endl;
221 std::vector<std::string>::const_iterator ait = mAddresses.begin();
222 for(; ait != mAddresses.end(); ++ait)
224 ss << hspace << *ait << std::endl;
226 ss << hspace <<
" resolvers:" << std::endl;
227 AgentIDList::const_iterator rit = mResolvers.begin();
228 for(; rit != mResolvers.end(); ++rit)
230 ss << rit->toString(indent + 4) << std::endl;
232 ss << hspace <<
" parameters:" << std::endl;
233 std::vector<UserdefParam>::const_iterator pit = mParameters.begin();
234 for(; pit != mParameters.end(); ++pit)
236 ss << hspace << pit->toString() << std::endl;
◆ ACLMessage
◆ mName
| std::string fipa::acl::AgentID::mName |
|
protected |
◆ msResolverComparisonDepth
| int fipa::acl::AgentID::msResolverComparisonDepth = 1 |
|
static |
◆ UNDEFINED
| const std::string fipa::acl::AgentID::UNDEFINED = "agent_id:undefined" |
|
staticprotected |
name representing an undefined agent
Definition at line 60 of file agent_id.h.
The documentation for this class was generated from the following files:
- /build/rock-master-18.09-multiagent-fipa-acl-0.20180914/src/message_generator/agent_id.h
- /build/rock-master-18.09-multiagent-fipa-acl-0.20180914/src/message_generator/agent_id.cpp