Class AgentFunctionDescription

Inheritance Relationships

Base Type

Class Documentation

class flamegpu::AgentFunctionDescription : public flamegpu::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

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

See

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

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

AgentFunctionDescription::setMessageInput(MessageDescription &)

Parameters

message_name – Name of the message type to be input

Throws
void setMessageInput(MessageBruteForce::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
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
void setMessageOutput(MessageBruteForce::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
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
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
void setAllowAgentDeath(const bool &has_death)

Configures whether agents can die during execution of this function (e.g. by returning 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.

See

setRTCFunctionConditionFile()

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.

See

setRTCFunctionCondition()

Parameters

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

MessageBruteForce::Description &MessageInput()

See

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

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

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 MessageBruteForce::Description &getMessageInput() const

See

AgentFunctionDescription::MessageInput() for the mutable version

Throws

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

Returns

An immutable reference to the message input of this agent function

const MessageBruteForce::Description &getMessageOutput() const

See

AgentFunctionDescription::MessageOutput() for the mutable version

Throws

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

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

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