RepastHPC  2.3.1
Public Member Functions | Friends | List of all members
repast::AgentRequest Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AgentRequest() [1/2]

repast::AgentRequest::AgentRequest ( int  sourceProcess)

Creates an AgentRequest that comes from the specified process.

Parameters
sourceProcessthe rank of the process making the request

◆ AgentRequest() [2/2]

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).

Parameters
sourceProcessthe rank of the source process
targetProcessthe rank of the target process

Member Function Documentation

◆ addAll()

void repast::AgentRequest::addAll ( const AgentRequest req)

Adds all the agent ids (both requests and cancellations) in req to this AgentRequest.

Parameters
reqthe AgentRequest to add all the agent ids from

◆ addAllCancellations()

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.

Parameters
reqthe AgentRequest to add all the agent ids from

◆ addAllRequests()

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.

Parameters
reqthe AgentRequest to add all the agent ids from

◆ addCancellation()

void repast::AgentRequest::addCancellation ( const AgentId id)

Adds the specified agent to the collection of agents for which a previous request is being cancelled.

Parameters
idthe AgentId of the agent for which the request is being cancelled

◆ addRequest()

void repast::AgentRequest::addRequest ( const AgentId id)

Adds the specified agent to the collection agents being requested.

Parameters
idthe requested agent

◆ cancellations()

const std::vector<AgentId>& repast::AgentRequest::cancellations ( ) const
inline

Gets a reference to the vector of cancellations.

Returns
a reference to the vector of AgentIds representing cancellations.

◆ contains()

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.

Parameters
idthe id sought in the lists of requests and cancellations
Returns
true if either the list of requests or the list of cancellations contains the specified id

◆ containsInCancellations()

bool repast::AgentRequest::containsInCancellations ( const AgentId id)

Returns true if the list of cancellations contains the specified id (the list of requests is ignored)

Parameters
idthe AgentId sought
Returns
true if the specified AgentId is in the list of cancellations

◆ containsInRequests()

bool repast::AgentRequest::containsInRequests ( const AgentId id)

Returns true if the list of requests contains the specified id (the list of cancellations is ignored)

Parameters
idthe AgentId sought
Returns
true if the specified AgentId is in the list of requests

◆ remove()

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.

Parameters
idthe AgentId to be removed
removeAllInstancesif true (the default), all instances of the AgentId are removed; if false, only the first instance found is removed
Returns
true if the id was found (in either list) and removed, otherwise false.

◆ removeCancellation()

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
Parameters
removeAllInstancesif 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

◆ removeRequest()

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
Parameters
removeAllInstancesif 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

◆ requestCount()

int repast::AgentRequest::requestCount ( ) const
inline

Gets the number agents requested.

Includes both requests and cancellations; exactly equivalent to

requestCountRequested() + requestCountCancellations()

Returns
the number agents requested.

◆ requestCountCancellations()

int repast::AgentRequest::requestCountCancellations ( ) const
inline

Gets the number of agents requested, counting only the cancellations and not the requests.

Returns
the number of agents requested (cancellations only)

◆ requestCountRequested()

int repast::AgentRequest::requestCountRequested ( ) const
inline

Gets the number of agents requested, counting only the requests and not the cancellations.

Returns
the number of agents requested (requests only)

◆ requestedAgents()

const std::vector<AgentId>& repast::AgentRequest::requestedAgents ( ) const
inline

Gets a reference to the vector of requested agents.

Returns
a reference to the vector of requested agents.

◆ sourceProcess()

int repast::AgentRequest::sourceProcess ( ) const
inline

Gets the source process of these requests, that is, the process making the request.

Returns
the process making the request

◆ targetProcess()

int repast::AgentRequest::targetProcess ( ) const
inline

If the requested agent ids are all on the same process then target process will identify that process.

Otherwise this will return -1.

◆ targets()

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.

Parameters
targetsset into which targets will be placed

◆ targetsOfCancellations()

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.

Parameters
targetsthe set into which the targets will be placed

◆ targetsOfRequests()

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.

Parameters
targetsthe set into which the targets will be placed

The documentation for this class was generated from the following files: