Class AgentFunctionDescription

Inheritance Relationships

Base Type

Class Documentation

class AgentFunctionDescription : public flamegpu::CAgentFunctionDescription

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 also

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

Public Functions

explicit AgentFunctionDescription(std::shared_ptr<AgentFunctionData> data)

Constructors

AgentFunctionDescription(const AgentFunctionDescription &other_agent) = default

Copy constructor

AgentFunctionDescription(AgentFunctionDescription &&other_agent) = default
AgentFunctionDescription &operator=(const AgentFunctionDescription &other_function) = default

Assignment operator

AgentFunctionDescription &operator=(AgentFunctionDescription &&other_function) = default
void setInitialState(const std::string &init_state)

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

Accessors

Parameters:

init_state – Name of the desired state

Throws:

exception::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

Parameters:

end_state – Name of the desired state

Throws:

exception::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 also

AgentFunctionDescription::setMessageInput(MessageDescription &)

Parameters:

message_name – Name of the message type to be input

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

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

void setMessageInput(MessageBruteForce::CDescription 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

Parameters:

message – Type of message to be input

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

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

  • exception::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 also

AgentFunctionDescription::setMessageOutput(MessageDescription &)

See also

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

Parameters:

message_name – Name of the message type to be output

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

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

void setMessageOutput(MessageBruteForce::CDescription 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 also

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

Parameters:

message – Type of message to be output

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

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

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

void setMessageOutputOptional(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 also

AgentFunctionDescription::setAgentOutput(AgentDescription &)

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

  • state – The stage agents should be created in

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

  • exception::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 also

AgentFunctionDescription::setAgentOutput(AgentDescription &)

Parameters:
  • agent – Type of agent to be output

  • state – The stage agents should be created in

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

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

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

void setAllowAgentDeath(bool has_death)

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

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.

Parameters:

func_cond_src – Source containing RTC agent function condition source

void setRTCFunctionConditionFile(const std::string &file_path)

Sets the RTC function condition for the agent function, with an agent function condition loaded from file This is file 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.

Parameters:

file_path – Location on disk of file containing RTC agent function condition source

MessageBruteForce::Description MessageInput()

See also

AgentFunctionDescription::getMessageInput() for the immutable version

Throws:

exception::OutOfBoundsException – If the message input has not been set

Returns:

A mutable reference to the message input of this agent function

MessageBruteForce::Description MessageOutput()

See also

AgentFunctionDescription::getMessageOutput() for the immutable version

Throws:

exception::OutOfBoundsException – If the message output has not been set

Returns:

An mutable reference to the message output of this agent function

bool &MessageOutputOptional()

See also

AgentFunctionDescription::getAgentOutputOptional()

See also

AgentFunctionDescription::setAgentOutputOptional(bool)

Returns:

A mutable reference to the message output optional configuration flag

bool &AllowAgentDeath()

Returns:

A mutable reference to the allow agent death configuration flag

AgentDescription AgentOutput()
Throws:

exception::OutOfBoundsException – If the agent output has not been set

Returns:

An interface to the agent output of this agent function