RepastHPC
2.3.1
|
Encapsulates a request made by one process for agents in another. More...
#include <AgentRequest.h>
Public Member Functions | |
AgentRequest (int sourceProcess) | |
Creates an AgentRequest that comes from the specified process. More... | |
AgentRequest (int sourceProcess, int targetProcess) | |
Creates an AgentRequest made from the source process to the target process. More... | |
void | addAll (const AgentRequest &req) |
Adds all the agent ids (both requests and cancellations) in req to this AgentRequest. More... | |
void | addAllRequests (const AgentRequest &req) |
Adds all the agent ids in req to this request, including only the ids that are requests and not those that are cancellations. More... | |
void | addAllCancellations (const AgentRequest &req) |
Adds all the agent ids in req to this request, including only the ids that are cancellations and not those that are requests. More... | |
const std::vector< AgentId > & | requestedAgents () const |
Gets a reference to the vector of requested agents. More... | |
const std::vector< AgentId > & | cancellations () const |
Gets a reference to the vector of cancellations. More... | |
bool | remove (const AgentId &id, bool removeAllInstances=true) |
Removes the specified id from the lists of requested agents, including both requests and cancellations. More... | |
bool | removeRequest (const AgentId &id, bool removeAllInstances=true) |
bool | removeCancellation (const AgentId &id, bool removeAllInstances=true) |
void | targets (std::set< int > &targets) |
Puts the targets of all the requests into the set. More... | |
void | targetsOfRequests (std::set< int > &targets) |
Puts the targets of all the requests into the set, including only the requests and not the cancellations. More... | |
void | targetsOfCancellations (std::set< int > &targets) |
Puts the targets of all the requests into the set, including only the requests and not the cancellations. More... | |
void | addRequest (const AgentId &id) |
Adds the specified agent to the collection agents being requested. More... | |
void | addCancellation (const AgentId &id) |
Adds the specified agent to the collection of agents for which a previous request is being cancelled. More... | |
int | requestCount () const |
Gets the number agents requested. More... | |
int | requestCountRequested () const |
Gets the number of agents requested, counting only the requests and not the cancellations. More... | |
int | requestCountCancellations () const |
Gets the number of agents requested, counting only the cancellations and not the requests. More... | |
bool | contains (const AgentId &id) |
Returns true if this AgentRequest contains a request for the specified id (either a request or a cancellation), otherwise false. More... | |
bool | containsInRequests (const AgentId &id) |
Returns true if the list of requests contains the specified id (the list of cancellations is ignored) More... | |
bool | containsInCancellations (const AgentId &id) |
Returns true if the list of cancellations contains the specified id (the list of requests is ignored) More... | |
int | sourceProcess () const |
Gets the source process of these requests, that is, the process making the request. More... | |
int | targetProcess () const |
If the requested agent ids are all on the same process then target process will identify that process. More... | |
Friends | |
class | boost::serialization::access |
class | Importer_LIST |
class | Importer_SET |
class | Importer_MAP_int |
std::ostream & | operator<< (std::ostream &os, const AgentRequest &request) |
Prints the specified AgentRequest to the specified ostream. | |
Encapsulates a request made by one process for agents in another.
Includes a list of requests and a list that represents cancellations of previous requests.
repast::AgentRequest::AgentRequest | ( | int | sourceProcess | ) |
Creates an AgentRequest that comes from the specified process.
sourceProcess | the rank of the process making the request |
repast::AgentRequest::AgentRequest | ( | int | sourceProcess, |
int | targetProcess | ||
) |
Creates an AgentRequest made from the source process to the target process.
This can be used when all the requested agents reside on the same process (i.e. the target process).
sourceProcess | the rank of the source process |
targetProcess | the rank of the target process |
void repast::AgentRequest::addAll | ( | const AgentRequest & | req | ) |
Adds all the agent ids (both requests and cancellations) in req to this AgentRequest.
req | the AgentRequest to add all the agent ids from |
void repast::AgentRequest::addAllCancellations | ( | const AgentRequest & | req | ) |
Adds all the agent ids in req to this request, including only the ids that are cancellations and not those that are requests.
req | the AgentRequest to add all the agent ids from |
void repast::AgentRequest::addAllRequests | ( | const AgentRequest & | req | ) |
Adds all the agent ids in req to this request, including only the ids that are requests and not those that are cancellations.
req | the AgentRequest to add all the agent ids from |
void repast::AgentRequest::addCancellation | ( | const AgentId & | id | ) |
Adds the specified agent to the collection of agents for which a previous request is being cancelled.
id | the AgentId of the agent for which the request is being cancelled |
void repast::AgentRequest::addRequest | ( | const AgentId & | id | ) |
Adds the specified agent to the collection agents being requested.
id | the requested agent |
|
inline |
Gets a reference to the vector of cancellations.
bool repast::AgentRequest::contains | ( | const AgentId & | id | ) |
Returns true if this AgentRequest contains a request for the specified id (either a request or a cancellation), otherwise false.
id | the id sought in the lists of requests and cancellations |
bool repast::AgentRequest::containsInCancellations | ( | const AgentId & | id | ) |
bool repast::AgentRequest::containsInRequests | ( | const AgentId & | id | ) |
bool repast::AgentRequest::remove | ( | const AgentId & | id, |
bool | removeAllInstances = true |
||
) |
Removes the specified id from the lists of requested agents, including both requests and cancellations.
id | the AgentId to be removed |
removeAllInstances | if true (the default), all instances of the AgentId are removed; if false, only the first instance found is removed |
bool repast::AgentRequest::removeCancellation | ( | const AgentId & | id, |
bool | removeAllInstances = true |
||
) |
Removes the specified id from the list of agent request cancellations; does not affect the list of requests. @param id the AgentId to be removed
removeAllInstances | if true (the default), all instances of the AgentId are removed; if false, only the first instance found is removed @return true if the id was found in the list of cancellations and removed, otherwise false |
bool repast::AgentRequest::removeRequest | ( | const AgentId & | id, |
bool | removeAllInstances = true |
||
) |
Removes the specified id from the list of agent requests; does not affect the list of cancellations. @param id the AgentId to be removed
removeAllInstances | if true (the default), all instances of the AgentId are removed; if false, only the first instance found is removed @return true if the id was found in the list of requests and removed, otherwise false |
|
inline |
Gets the number agents requested.
Includes both requests and cancellations; exactly equivalent to
requestCountRequested() + requestCountCancellations()
|
inline |
Gets the number of agents requested, counting only the cancellations and not the requests.
|
inline |
Gets the number of agents requested, counting only the requests and not the cancellations.
|
inline |
Gets a reference to the vector of requested agents.
|
inline |
Gets the source process of these requests, that is, the process making the request.
|
inline |
If the requested agent ids are all on the same process then target process will identify that process.
Otherwise this will return -1.
void repast::AgentRequest::targets | ( | std::set< int > & | targets | ) |
Puts the targets of all the requests into the set.
Includes both the requests and the cancellations.
targets | set into which targets will be placed |
void repast::AgentRequest::targetsOfCancellations | ( | std::set< int > & | targets | ) |
Puts the targets of all the requests into the set, including only the requests and not the cancellations.
targets | the set into which the targets will be placed |
void repast::AgentRequest::targetsOfRequests | ( | std::set< int > & | targets | ) |
Puts the targets of all the requests into the set, including only the requests and not the cancellations.
targets | the set into which the targets will be placed |