fpmas 1.6
Classes | Public Member Functions | List of all members
fpmas::model::Behavior< AgentType > Class Template Reference

#include <model.h>

Inheritance diagram for fpmas::model::Behavior< AgentType >:
Inheritance graph
[legend]
Collaboration diagram for fpmas::model::Behavior< AgentType >:
Collaboration graph
[legend]

Public Member Functions

template<typename ... T>
 Behavior (T... behaviors)
 
void execute (api::model::Agent *agent) const
 
virtual void execute (Agent *agent) const =0
 

Detailed Description

template<typename AgentType>
class fpmas::model::Behavior< AgentType >

api::model::Behavior implementation.

This Behavior can be defined from any sequence of member methods of AgentType.

Constructor & Destructor Documentation

◆ Behavior()

template<typename AgentType >
template<typename ... T>
fpmas::model::Behavior< AgentType >::Behavior ( T...  behaviors)
inline

Behavior constructor.

Builds an Agent behavior from the member methods specified as arguments. Those methods must take no argument, and will be called in the order specified on each Agent to which this behavior is applied.

Each agent to which this behavior is applied must be of type AgentType, or be a child class of AgentType, so that specified methods can be called on agent. Otherwise, the behavior of execute() is undefined.

Notice that AgentType might be an abstract class, and specified methods can be virtual. In such a case, this Behavior can be applied to any AgentType implementation.

example
class Agent : public fpmas::model::AgentBase<Agent> {
public:
void behavior1() {};
void behavior2() {};
};
int main() {
...
// behavior1() and behavior2() methods will be called
// successively on Agents to which this behavior is
// applied.
&Agent::behavior1, &Agent::behavior2
};
// behavior will be applied to any agent of this group
auto& group = model.buildGroup(AGENT_GROUP_ID, behavior);
// Agents added to the group must be convertible to
// Agent.
group.add(new Agent);
}
virtual void add(Agent *agent)=0
Definition: model.h:480
Definition: model.h:722
Definition: model.h:638
api::model::AgentGroup & buildGroup(api::model::GroupId id) override
Definition: model.cpp:101
Parameters
behaviorsA comma separated list of AgentType member methods, in the form &AgentType::method

Member Function Documentation

◆ execute()

template<typename AgentType >
void fpmas::model::Behavior< AgentType >::execute ( api::model::Agent agent) const
inlinevirtual

Executes this behavior on the specified agent.

Parameters
agenton which this behavior must be executed.

Implements fpmas::api::model::Behavior.


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