Class AgentFunctionDescription

Inheritance Relationships

Base Type

Class Documentation

class AgentFunctionDescription : public DependencyNode

Within the model hierarchy, this class represents an agent function for a FLAMEGPU model This class is used to configure external elements of agent functions, such as inputs and outputs

See

AgentDescription::newFunction(const std::string&, AgentFunction) For creating instances of this class

Public Functions

bool operator==(const AgentFunctionDescription &rhs) const

Equality operator, checks whether AgentFunctionDescription hierarchies are functionally the same

Note

Instead compare pointers if you wish to check that they are the same instance

Returns

True when agent functions are the same

bool operator!=(const AgentFunctionDescription &rhs) const

Equality operator, checks whether AgentFunctionDescription hierarchies are functionally different

Note

Instead compare pointers if you wish to check that they are not the same instance

Returns

True when agent functions are not the same

void setInitialState(const std::string &init_state)

Sets the initial state which agents must be in to execute this function

Accessors

See

AgentFunctionDescription::setEndState(const std::string &)

Parameters

init_state – Name of the desired state

Throws

InvalidStateName – If the named state is not found within the agent

void setEndState(const std::string &end_state)

Sets the end state which agents enter after executing this function

See

AgentFunctionDescription::setInitialState(const std::string &)

Parameters

end_state – Name of the desired state

Throws

InvalidStateName – If the named state is not found within the agent

void setMessageInput(const std::string &message_name)

Sets the message type that can be read during this agent function This is optional, and only one type of message can be read per agent function

See

AgentFunctionDescription::setMessageInput(MessageDescription &)

Parameters

message_name – Name of the message type to be input

Throws
  • InvalidMessageName – If a message with the same name is not found within the model’s hierarchy

  • InvalidMessageName – If the same message is already bound to the message output of this agent function

void setMessageInput(MsgBruteForce::Description &message)

Sets the message type that can be read during this agent function This is optional, and only one type of message can be read per agent function

See

AgentFunctionDescription::setMessageInput(const std::string &)

Parameters

message – Type of message to be input

Throws
  • DifferentModel – If the message is not from this model hierarchy

  • InvalidMessageName – If a message with the same name is not found within the model’s hierarchy

  • InvalidMessageName – If the same message is already bound to the message output of this agent function

void setMessageOutput(const std::string &message_name)

Sets the message type that can be output during this agent function This is optional, and only one type of message can be output per agent function

See

AgentFunctionDescription::setMessageOutput(MessageDescription &)

See

AgentFunctionDescription::setMessageOutputOptional(const bool &) To configure whether all agents must output messages

Parameters

message_name – Name of the message type to be output

Throws
  • InvalidMessageName – If a message with the same name is not found within the model’s hierarchy

  • InvalidMessageName – If the same message is already bound to the message input of this agent function

void setMessageOutput(MsgBruteForce::Description &message)

Sets the message type that can be output during this agent function This is optional, and only one type of message can be output per agent function

See

AgentFunctionDescription::setMessageInput(const std::string &)

See

AgentFunctionDescription::setMessageOutputOptional(const bool &) To configure whether all agents must output messages

Parameters

message – Type of message to be output

Throws
  • DifferentModel – If the message is not from this model hierarchy

  • InvalidMessageName – If a message with the same name is not found within the model’s hierarchy

  • InvalidMessageName – If the same message is already bound to the message input of this agent function

void setMessageOutputOptional(const bool &output_is_optional)

Configures whether message output from this agent function is optional (e.g. whether all agents must output a message each time the function is called) If the function has no message output, this can be ignored

Note

Defaults to false

Parameters

output_is_optional – True if not all agents executing this function will output messages

void setAgentOutput(const std::string &agent_name, const std::string state = ModelData::DEFAULT_STATE)

Sets the agent type that can be output during this agent function This is optional, and only one type of agent can be output per agent function

See

AgentFunctionDescription::setAgentOutput(AgentDescription &)

Parameters
  • agent_name – Name of the agent type to be output

  • state – The stage agents should be created in

Throws
  • InvalidAgentName – If an agent with the same name is not found within the model’s hierarchy

  • InvalidStateName – If the named agent does not contain the named state

void setAgentOutput(AgentDescription &agent, const std::string state = ModelData::DEFAULT_STATE)

Sets the agent type that can be output during this agent function This is optional, and only one type of agent can be output per agent function

See

AgentFunctionDescription::setAgentOutput(AgentDescription &)

Parameters
  • agent – Type of agent to be output

  • state – The stage agents should be created in

Throws
  • DifferentModel – If the agent is not from this model hierarchy

  • InvalidAgentName – If an agent with the same name is not found within the model’s hierarchy

  • InvalidStateName – If the named agent does not contain the named state

void setAllowAgentDeath(const bool &has_death)

Configures whether agents can die during execution of this function (e.g. by returning FLAME_GPU_AGENT_STATUS::DEAD from the agent function)

See

AgentFunctionDescription::AllowAgentDeath()

See

AgentFunctionDescription::getAllowAgentDeath()

Note

Defaults to false

Parameters

has_death – True if some agents executing this agent function may die

template<typename AgentFunctionCondition>
void setFunctionCondition(AgentFunctionCondition)

Sets the function condition for the agent function This is an FLAMEGPU_AGENT_FUNCTION_CONDITION which returns a boolean value (true or false) Only agents which return true perform the attached FLAMEGPU_AGENT_FUNCTION and transition from the initial to end state

void setRTCFunctionCondition(std::string func_cond_src)

Sets the RTC function condition for the agent function This is string containing a definition of an FLAMEGPU_AGENT_FUNCTION_CONDITION which returns a boolean value (true or false) Only agents which return true perform the attached FLAMEGPU_AGENT_FUNCTION and transition from the initial to end state. The string will be compiled at runtime.

MsgBruteForce::Description &MessageInput()

See

AgentFunctionDescription::getMessageInput() for the immutable version

Throws

OutOfBoundsException – If the message input has not been set

Returns

A mutable reference to the message input of this agent function

MsgBruteForce::Description &MessageOutput()

See

AgentFunctionDescription::getMessageOutput() for the immutable version

Throws

OutOfBoundsException – If the message output has not been set

Returns

An mutable reference to the message output of this agent function

bool &MessageOutputOptional()

See

AgentFunctionDescription::getAgentOutputOptional()

See

AgentFunctionDescription::setAgentOutputOptional(const bool &)

Returns

A mutable reference to the message output optional configuration flag

bool &AllowAgentDeath()

See

AgentFunctionDescription::getAllowAgentDeath()

See

AgentFunctionDescription::setAllowAgentDeath(const bool &)

Returns

A mutable reference to the allow agent death configuration flag

std::string getName() const

Const Accessors

Returns

The function’s name

std::string getInitialState() const
Returns

The state which agents must be in to execute this agent function

std::string getEndState() const
Returns

The state which agents executing this function enter

const MsgBruteForce::Description &getMessageInput() const

See

AgentFunctionDescription::MessageInput() for the mutable version

Throws

OutOfBoundsException – If the message input has not been set

Returns

An immutable reference to the message input of this agent function

const MsgBruteForce::Description &getMessageOutput() const

See

AgentFunctionDescription::MessageOutput() for the mutable version

Throws

OutOfBoundsException – If the message output has not been set

Returns

An immutable reference to the message output of this agent function

bool getMessageOutputOptional() const
Returns

True if message output from this agent function is optional

const AgentDescription &getAgentOutput() const
Throws

OutOfBoundsException – If the agent output has not been set

Returns

An immutable reference to the agent output of this agent function

std::string getAgentOutputState() const
Throws

OutOfBoundsException – If the agent output has not been set

Returns

The state output agents will be output in

bool getAllowAgentDeath() const
Returns

True if this agent function can kill agents

bool hasMessageInput() const

See

AgentFunctionDescription::setMessageInput(const std::string &)

See

AgentFunctionDescription::setMessageInput(MessageDescription &)

Returns

True if setMessageInput() has been called successfully

bool hasMessageOutput() const

See

AgentFunctionDescription::setMessageOutput(const std::string &)

See

AgentFunctionDescription::setMessageOutput(MessageDescription &)

Returns

True if setMessageOutput() has been called successfully

bool hasAgentOutput() const

See

AgentFunctionDescription::setAgentOutput(const std::string &)

See

AgentFunctionDescription::setAgentOutput(AgentDescription &)

Returns

True if setAgentOutput() has been called successfully

bool hasFunctionCondition() const

See

AgentFunctionDescription::setFunctionCondition(AgentFunctionCondition)

Returns

True if setFunctionCondition() has been called successfully

AgentFunctionWrapper *getFunctionPtr() const
Returns

The cuda kernel entry point for executing the agent function

AgentFunctionConditionWrapper *getConditionPtr() const
Returns

The cuda kernel entry point for executing the agent function condition

bool isRTC() const
Returns

True if the function is a runtime time specified function