![]() |
fpmas 1.6
|
#include <model.h>
Public Member Functions | |
AgentGroupBase (GroupId group_id, api::model::AgentGraph &agent_graph) | |
AgentGroupBase (const AgentGroupBase &)=delete | |
AgentGroupBase & | operator= (const AgentGroupBase &)=delete |
AgentGroupBase (GroupId group_id, api::model::AgentGraph &agent_graph, const api::model::Behavior &behavior) | |
GroupId | groupId () const override |
const api::model::Behavior & | behavior () override |
void | add (api::model::Agent *) override |
void | remove (api::model::Agent *) override |
void | insert (api::model::AgentPtr *) override |
void | erase (api::model::AgentPtr *) override |
void | clear () override |
scheduler::Job & | job () override |
const scheduler::Job & | job () const override |
api::scheduler::Job & | agentExecutionJob () override |
const api::scheduler::Job & | agentExecutionJob () const override |
std::vector< api::model::Agent * > | agents () const override |
std::vector< api::model::Agent * > | localAgents () const override |
std::vector< api::model::Agent * > | distantAgents () const override |
void | addEventHandler (Event event, api::utils::Callback< api::model::Agent * > *callback) override |
void | removeEventHandler (Event event, api::utils::Callback< api::model::Agent * > *callback) override |
![]() | |
virtual GroupId | groupId () const =0 |
virtual const Behavior & | behavior ()=0 |
virtual void | add (Agent *agent)=0 |
virtual void | remove (Agent *agent)=0 |
virtual void | clear ()=0 |
virtual void | insert (AgentPtr *agent)=0 |
virtual void | erase (AgentPtr *agent)=0 |
virtual std::vector< Agent * > | agents () const =0 |
virtual std::vector< Agent * > | localAgents () const =0 |
virtual std::vector< Agent * > | distantAgents () const =0 |
virtual api::scheduler::Job & | job ()=0 |
virtual const api::scheduler::Job & | job () const =0 |
virtual api::scheduler::Job & | agentExecutionJob ()=0 |
virtual const api::scheduler::Job & | agentExecutionJob () const =0 |
virtual api::scheduler::JobList | jobs () const =0 |
virtual void | addEventHandler (Event event, api::utils::Callback< Agent * > *callback)=0 |
virtual void | removeEventHandler (Event event, api::utils::Callback< Agent * > *callback)=0 |
Additional Inherited Members | |
![]() | |
enum | Event { INSERT , ERASE , ADD , REMOVE } |
api::model::AgentGroup implementation.
fpmas::model::detail::AgentGroupBase::AgentGroupBase | ( | GroupId | group_id, |
api::model::AgentGraph & | agent_graph | ||
) |
AgentGroupBase constructor.
group_id | unique id of the group |
agent_graph | associated agent graph |
|
delete |
Deletes copy constructor.
fpmas::model::detail::AgentGroupBase::AgentGroupBase | ( | GroupId | group_id, |
api::model::AgentGraph & | agent_graph, | ||
const api::model::Behavior & | behavior | ||
) |
AgentGroupBase constructor.
group_id | unique id of the group |
agent_graph | associated agent graph |
behavior | group behavior |
|
delete |
Deletes copy assignment operator.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Returns the Behavior associated to this group.
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Adds a new Agent to this group.
AgentGroups to which an agent
is added take ownership of the agent
, that must be dynamically allocated (using a new
statement). The agent
lives while it belongs to at least one group, and is deleted when it is removed from the last group.
add() builds a new AgentNode into the current AgentGraph and associates it to the Agent if the agent
was not contained in any group yet.
This group's groupId() is added to agent
s Agent::groupIds().
A task is also bound to the agent
and Agent::groups() is updated as defined in insert().
Moreover, if the agent
is LOCAL, the previous task is added to agentExecutionJob().
In consequence, it is possible to dynamically add() LOCAL agents to groups.
Notice that when the agent
is not bound to a node yet, i.e. this is the first group the agent is inserted into so that a new node is built, the agent
automatically becomes LOCAL, since the new node is built locally.
If a DISTANT agent
is added to the group, it is just inserted in the group. However, this is a mechanic that must be used only internally, since adding a DISTANT agent to the group is not guaranteed to report the operation on other processes.
agent | agent to add |
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Removes an Agent from this group.
If this was the last group containing the Agent, it is completely removed from the simulation, so the associated AgentNode is also globally removed from the AgentGraph.
Else, the agent is simply removed from this group as defined in erase().
If the agent
is LOCAL, the task associated to this group's behavior() is removed from agentExecutionJob().
agent | agent to remove |
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Inserts an Agent into this AgentGroup.
This function is only used during the node migration process, and is not supposed to be used by the final user.
Contrary to add(), this method assumes that an AgentNode has already been built for the Agent.
When this method is called, it is assumed that agent
's Agent::groupIds() list already contains this groupId(), so the agent
should be inserted in the group.
Upon return, agent
's Agent::groups() must be updated, and a task that execute behavior() on this agent must be bound to the agent. The corresponding task is then accessible from Agent::task(GroupId) and Agent::tasks().
agent | agent to insert into this group |
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Erases an Agent from this AgentGroup.
This function is only used during the node migration process, and is not supposed to be used by the final user.
Contrary to remove(), this method does not globally removes the Agent (and its associated AgentNode) from the simulation.
Upon return, agent
's Agent::groupIds() and Agent::groups() must be updated, and the task previously bound to the agent by insert() must be unbound.
agent | agent to erase from this group |
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Removes all local agents from this group.
Implements fpmas::api::model::AgentGroup.
|
inlineoverridevirtual |
Returns a reference to the Job associated to this AgentGroup.
This Job contains all the AgentTasks associated to all Agents in this group.
This Job can be scheduled to define when this AgentGroup must be executed.
See the complete api::scheduler::Scheduler interface for more scheduling options.
This method as been deprecated and will be removed in a next release. Use agentExecutionJob() or jobs() instead, depending on use case.
Implements fpmas::api::model::AgentGroup.
|
inlineoverridevirtual |
Returns a reference to the Job associated to this AgentGroup.
This Job contains all the AgentTasks associated to all Agents in this group.
This Job can be scheduled to define when this AgentGroup must be executed.
See the complete api::scheduler::Scheduler interface for more scheduling options.
This method as been deprecated and will be removed in a next release. Use agentExecutionJob() or jobs() instead, depending on use case.
Implements fpmas::api::model::AgentGroup.
|
inlineoverridevirtual |
Returns a reference to the internal Job specifically used to execute behavior() on the agents() of the group.
Any necessary graph synchronization is included at the end of the Job, after all agents execution.
However this job is not intended to be scheduled directly: use jobs() instead.
Implements fpmas::api::model::AgentGroup.
|
inlineoverridevirtual |
Returns a reference to the internal Job specifically used to execute behavior() on the agents() of the group.
Any necessary graph synchronization is included at the end of the Job, after all agents execution.
However this job is not intended to be scheduled directly: use jobs() instead.
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Returns the list of all Agents currently in this AgentGroup, including DISTANT
representations of Agents not executed on the current process.
The returned list is invalidated by the following operations:
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Returns the list of LOCAL Agents currently in this AgentGroup, that are executed on the current process.
The returned list is invalidated by the following operations:
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Returns the list of DISTANT Agents currently in this AgentGroup, represented to preserve LOCAL agents neighbors but not executed on this process.
The process on which a DISTANT agent
is executed can be retrieved with agent->node()->location()
.
The returned list is invalidated by the following operations:
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Registers a callback function to be called when the specified Event is emitted.
event | event that triggers the callback |
callback | callback called when the event occurs |
Implements fpmas::api::model::AgentGroup.
|
overridevirtual |
Unregisters a callback function previously registered for the spespecified event.
The behavior is undefined if the callback was not previously registered using addEventHandler().
event | event that triggers the callback |
callback | callback called when the event occurs |
Implements fpmas::api::model::AgentGroup.