cubos::core::ecs::Planner class

Layer on top of Schedule, used to build them with added abstractions such as tags.

Public types

struct TagId
Local identifier for tags.

Public functions

void clear()
Resets the planner to its initial state.
auto add() -> TagId
Adds a new unnamed tag to the planner.
auto add(std::string name) -> TagId
Adds a new named tag to the planner.
auto add(std::string name, SystemId systemId) -> TagId
Adds a new system to the planner.
void remove(TagId tagId)
Removes a tag from the planner and any constraints related to it.
auto tag(TagId childId, TagId parentId) -> bool
Makes the given tag a child of the the given tag.
void order(TagId beforeId, TagId afterId)
Specifies that the given tag must run before another tag.
void onlyIf(TagId tagId, ConditionId conditionId)
Specifies that systems within the given tag should only run if the given condition evaluates to true.
auto repeatWhile(TagId tagId, ConditionId conditionId) -> bool
Specifies that the given tag is a repeating tag. Can only be specified once per tag.
auto build() const -> memory::Opt<Schedule>
Constructs a new schedule from the constraints specified until now.

Function documentation

TagId cubos::core::ecs::Planner::add()

Adds a new unnamed tag to the planner.

Returns Tag identifier.

TagId cubos::core::ecs::Planner::add(std::string name)

Adds a new named tag to the planner.

Parameters
name Debug name.
Returns Tag identifier.

TagId cubos::core::ecs::Planner::add(std::string name, SystemId systemId)

Adds a new system to the planner.

Parameters
name Debug name.
systemId System identifier.
Returns Tag identifier which includes only the system itself.

void cubos::core::ecs::Planner::remove(TagId tagId)

Removes a tag from the planner and any constraints related to it.

Parameters
tagId Tag identifier.

Any directly associated systems and conditions are also removed.

bool cubos::core::ecs::Planner::tag(TagId childId, TagId parentId)

Makes the given tag a child of the the given tag.

Parameters
childId Child tag identifier.
parentId Parent tag identifier.
Returns Whether the operation was successful.

Essentially makes the child inherit all constraints of the parent. Tags may have multiple parents, but only one of them must be a repeated tag.

Returns false if the tag identified by parentId is a leaf tag (i.e., created through add(SystemId)).

void cubos::core::ecs::Planner::order(TagId beforeId, TagId afterId)

Specifies that the given tag must run before another tag.

Parameters
beforeId Before tag identifier.
afterId After tag identifier.

void cubos::core::ecs::Planner::onlyIf(TagId tagId, ConditionId conditionId)

Specifies that systems within the given tag should only run if the given condition evaluates to true.

Parameters
tagId Tag identifier.
conditionId Condition identifier.

The condition itself inherits all of the constraints of the tag.

bool cubos::core::ecs::Planner::repeatWhile(TagId tagId, ConditionId conditionId)

Specifies that the given tag is a repeating tag. Can only be specified once per tag.

Parameters
tagId Tag identifier.
conditionId Condition identifier.
Returns Whether the operation was successful.

Returns false if the given tag was already a repeating tag.

memory::Opt<Schedule> cubos::core::ecs::Planner::build() const

Constructs a new schedule from the constraints specified until now.

Returns Schedule, or nothing if the constraints couldn't be fulfilled.