LogicBranchDefault

Provides a default branch in the rule chain.  The rule chain is stored in the RuleEngine using pieces of priority branching ILogic.  A rule chain should be flexible, allowing plugin modules to alter it by adding overriding branches, if needed.  However, if no plugin module alters the rule chain at a specific juncture, there must be something that gives that next IRule to execute in the chain.  Since this circumstance is so common, the class LogicBranchDefault provides a simple way of creating a default rule branch in the rule chain.  The LogicBranchDefault is simply created with the name of the IRule to branch to and can then be added to the <RuleSetDatabase> via the <IMPLEMENT_DEFAULT_BRANCH> macro.

Derived From

Logic

Project

RulesCore

Include

LogicBranchDefault.h

Summary
Provides a default branch in the rule chain.
The LogicBranchDefault constructor.
Returns the default rule in the output DataObject.
The default LogicBranchDefault constructor.
The name of the default IRule to branch to in the rule chain.

Public

Summary
The LogicBranchDefault constructor.
Returns the default rule in the output DataObject.

Constructors

LogicBranchDefault

LogicBranchDefault(const wxString &rule) : mRule(rule)

The LogicBranchDefault constructor.  Stores the given IRule name.

Parameters

ruleThe name of the default IRule to branch to in the rule chain.  Must not be empty.

Virtual Functions

Decide

virtual void Decide(const DataObject &input,
DataObject &output)

Returns the default rule in the output DataObject.  Since the purpose of the class is to have a default IRule to branch to, the class simply returns the name of the default IRule branch.

Parameters

inputThe input DataObjectUnused.
outputThe output DataObject.  Filled with the name of the default IRule.

Private

Summary
The default LogicBranchDefault constructor.
The name of the default IRule to branch to in the rule chain.

Constructors

LogicBranchDefault

LogicBranchDefault()

The default LogicBranchDefault constructor.  It is declared but not instantiated so that developers will get a compile error if they forget to create a LogicBranchDefault without an IRule name.

Variables

mRule

wxString mRule

The name of the default IRule to branch to in the rule chain.

LogicBranchDefault(const wxString &rule) : mRule(rule)
The LogicBranchDefault constructor.
virtual void Decide(const DataObject &input,
DataObject &output)
Returns the default rule in the output DataObject.
A generic container for passing any kind of data around.
wxString mRule
The name of the default IRule to branch to in the rule chain.
The interface for a single game rule.
The default implementation of the IRuleEngine interface.
The interface of a single piece of game logic.
The default implementation of ILogic for normal Game actions.
RulesCore is the HOSS of Cities3D.