Class LayerDescription

Class Documentation

class LayerDescription

Within the model hierarchy, this class represents an execution layer for a FLAMEGPU model This class is used to configure which agent and host functions execute at a stage of the model’s execution

See

ModelDescription::newLayer(const std::string&) For creating instances of this class

Public Functions

bool operator==(const LayerDescription &rhs) const

Equality operator, checks whether LayerDescription hierarchies are functionally the same

Note

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

Returns

True when layers are the same

bool operator!=(const LayerDescription &rhs) const

Equality operator, checks whether LayerDescription hierarchies are functionally different

Note

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

Returns

True when layers are not the same

template<typename AgentFunction>
void addAgentFunction(AgentFunction a = AgentFunction())

Adds an agent function to this layer The agent function will be called during this stage of model execution

See

AgentDescription::newFunction(const std::string &, AgentFunction)

Note

The agent function must first be added to an Agent

Parameters

a – Agent function as defined using FLAMEGPU_AGENT_FUNCTION notation

Template Parameters

AgentFunction – Struct containing agent function definition

Throws
  • InvalidAgentFunc – If the agent function does not exist within the model hierarchy

  • InvalidAgentFunc – If the agent function has already been added to the layer

  • InvalidLayerMember – If the layer already contains a SubModel

  • InvalidLayerMember – If the agent function outputs to a message list output to by an existing agent function of the layer

void addAgentFunction(const AgentFunctionDescription &afd)

Adds an agent function to this layer The agent function will be called during this stage of model execution

Parameters

afd – Agent function description to execute during this layer

Throws
  • InvalidAgentFunc – If the agent function does not exist within the model hierarchy

  • InvalidAgentFunc – If the agent function has already been added to the layer

  • InvalidLayerMember – If the layer already contains a SubModel

  • InvalidLayerMember – If the agent function outputs to a message list output to by an existing agent function of the layer

  • InvalidLayerMember – If the agent function outputs an agent in the same agent state as an existing agent function’s input state (or vice versa)

void addAgentFunction(const std::string &agentName, const std::string &functionName)

Adds an agent function to this layer The agent function will be called during this stage of model execution

Parameters
  • agentName – Name of the agent which owns the function to execute during this layer

  • functionName – Name of the agent function description to execute during this layer

Throws
  • InvalidAgentFunc – If the agent function does not exist within the model hierarchy

  • InvalidAgentFunc – If the agent function has already been added to the layer

  • InvalidLayerMember – If the layer already contains a SubModel

  • InvalidLayerMember – If the agent function outputs to a message list output to by an existing agent function of the layer

  • InvalidLayerMember – If the agent function outputs an agent in the same agent state as an existing agent function’s input state (or vice versa)

void addAgentFunction(const char *agentName, const char *functionName)

Adds an agent function to this layer The agent function will be called during this stage of model execution

Note

This version exists because the template overload was preventing implicit cast to std::string

Parameters
  • agentName – Name of the agent which owns the function to execute during this layer

  • functionName – Name of the agent function description to execute during this layer

Throws
  • InvalidAgentFunc – If the agent function does not exist within the model hierarchy

  • InvalidAgentFunc – If the agent function has already been added to the layer

  • InvalidLayerMember – If the layer already contains a SubModel

  • InvalidLayerMember – If the agent function outputs to a message list output to by an existing agent function of the layer

  • InvalidLayerMember – If the agent function outputs an agent in the same agent state as an existing agent function’s input state (or vice versa)

void addHostFunction(FLAMEGPU_HOST_FUNCTION_POINTER func_p)

Adds a host function to this layer The host function will be called during this stage of model execution

Note

There is no guarantee on the order in which multiple host functions in the same layer will be executed

Parameters

func_p – Function pointer to the host function declared using FLAMEGPU_HOST_FUNCTION notation

Throws
void addSubModel(const std::string &name)

Adds a submodel to a layer If layer contains a submodel, it may contain nothing else

See

addSubModel(const SubModelDescription &)

Parameters

name – Name of the submodel (passed to ModelDescription::newSubModel() was called)

Throws
void addSubModel(const SubModelDescription &submodel)

Adds a submodel to a layer If layer contains a submodel, it may contain nothing else

See

addSubModel(const std::string &)

Parameters

submodel – SubModel description of the layer to be bound

Throws
void _addHostFunctionCallback(HostFunctionCallback *func_callback)

Adds a host function to this layer, similar to addHostFunction however the runnable function is encapsulated within an object which permits cross language support in swig. The host function will be called during this stage of model execution

Note

ONLY USED INTERNALLY AND BY PYTHON API - DO NOT CALL IN C++ BUILD

Parameters

func_callback – a Host function callback object

Throws

InvalidHostFunc – If the function has already been added to the layer

std::string getName() const
Returns

The layer’s name

ModelData::size_type getIndex() const
Returns

The index of the layer within the model’s execution

ModelData::size_type getAgentFunctionsCount() const
Returns

The total number of agent functions within the layer

ModelData::size_type getHostFunctionsCount() const
Returns

The total number of host functions within the layer

const AgentFunctionDescription &getAgentFunction(unsigned int index) const

See

LayerDescription::getAgentFunctionsCount()

Note

Functions are stored in a set, so order may change as new functions are added

Parameters

index – Index of the function to return

Throws

OutOfBoundsException – When index exceeds number of agent functions in the layer

Returns

An immutable reference to the agent function at the provided index

FLAMEGPU_HOST_FUNCTION_POINTER getHostFunction(unsigned int index) const

See

LayerDescription::getHostFunctionsCount()

Note

Functions are stored in a set, so order may change as new functions are added

Parameters

index – Index of the function to return

Throws

OutOfBoundsException – When index exceeds number of host functions in the layer

Returns

A function pointer to the host function at the provided index