12 #include <base-logging/Logging.hpp> 33 return mName != AgentID::UNDEFINED && !
empty();
41 snprintf(buffer, 128,
"fipa::acl::AgentID: name '%s' contains invalid characters", name.c_str());
42 throw std::runtime_error(buffer);
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);
63 if ( find(mResolvers.begin(), mResolvers.end(),aid) == mResolvers.end() )
65 mResolvers.push_back(aid);
71 std::vector<AgentID>::iterator it = find(mResolvers.begin(), mResolvers.end(),aid);
74 if( it != mResolvers.end() )
82 mParameters.push_back(p);
87 return compareEqual(*
this, other, AgentID::msResolverComparisonDepth);
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();
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())
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())
212 return mName.empty();
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;
AgentID()
Default constructor.
void deleteResolver(const AgentID &id)
Delete a resolver.
bool operator==(const AgentID &other) const
overloaded equality operator for AgentID; the signature of the function was intentionally changed fro...
std::string toString(size_t indent=0) const
Defines the AgentID class.
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 bool compareEqual(const AgentID &a, const AgentID &b, int depth)
alternative function for equality operator; the depth can be specified through the depth param ...
void addResolver(const AgentID &aid)
Add resolver.
void addAddress(const std::string &adr)
the method checks whether the passed address string is a word or not(according to the fipa spec) ...
const std::string illegalWordStart
void addUserdefParam(const UserdefParam &p)
Add a userdefined parameter.
describes the general data structure of a message in conformity with the fipa specifications. The methods are pretty straight forward getter and setter methods. The set container is used for various colective fields, in order to avoid duplicates
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
const std::vector< std::string > & getAddresses() const
Retrieve list of addresses.
const std::vector< UserdefParam > & getUserdefParams() const
Get the all userdefined parameter.
bool empty() const
Check if AgentId is empty, i.e. does not contain a name.
static const std::string UNDEFINED
static int msResolverComparisonDepth
const Resolvers & getResolvers() const
Get list of resolvers.
overloaded equality operator for UserdefParam class objects
const std::string illegalWordChars
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
Foundation of Physical Intelligent Agents.