Class AgentFunctionDescription
Defined in File AgentFunctionDescription.h
Inheritance Relationships
Base Type
public flamegpu::DependencyNode
(Class DependencyNode)
Class Documentation
-
class 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 also
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
- 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::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
- 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(const 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::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 also
AgentFunctionDescription::setMessageOutputOptional(const 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(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 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(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)
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 also
- 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 also
- 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(const 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
-
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 also
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 also
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 also
AgentFunctionDescription::setMessageInput(MessageDescription &)
- Returns
True if setMessageInput() has been called successfully
-
bool hasMessageOutput() const
-
See also
AgentFunctionDescription::setMessageOutput(MessageDescription &)
- Returns
True if setMessageOutput() has been called successfully
-
bool hasAgentOutput() const
See also
AgentFunctionDescription::setAgentOutput(const std::string &)
See also
AgentFunctionDescription::setAgentOutput(AgentDescription &)
- Returns
True if setAgentOutput() has been called successfully
-
bool hasFunctionCondition() const
-
- 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
-
bool operator==(const AgentFunctionDescription &rhs) const