IRule

The interface for a single game rule.  The class IRule is an implementation of the Command design pattern.  An IRule is a piece of code that does something in the Game.  What that something is is completely up to the IRule-derived object.  An IRule may call other IRules from within itself, or execute ILogic to determine what course of action to take.  IRules can also be extended by something derived from BaseMixin so that their behavior is pluggable, and different RuleSets can extend the functionality of exisiting IRules.  An IRule may make itself undoable by implementing the IUndoable interface.

All IRules are originally created and stored in a RuleSet within a plugin object.  An IRule within a RuleSet is stored in a string-based hash map.  All IRules have a string that is the key used to execute them.  When that RuleSet is loaded into the game via the IPluginEngine, all IRules (and ILogic) within the RuleSet are transferred from their RuleSet hash map into the into the main RuleEngine hash map, which, in the end, holds the aggregation of all IRules in all RuleSets for the game.

NOTE: An IRule-derived class should be created and stored in a RuleSet through one of the <IMPLEMENT_RULE>, <IMPLEMENT_RULE_REPLACE>, or <IMPLEMENT_RULE_MIXIN> macros in <RuleSetDatabase>.

Project

RulesCore

Include

IRule.h

Summary
The interface for a single game rule.
Executes a rule.
Unexecutes a rule.
The IRule destructor.

Public

Summary
Executes a rule.
Unexecutes a rule.

Pure Virtual Functions

Execute

virtual void Execute(const DataObject &object)=0

Executes a rule.  May use the given DataObject to assists its execution.

Parameters

objectThe DataObject that gives direction to the IRule.

Unexecute

virtual void Unexecute(const DataObject &object)

Unexecutes a rule.  Some rules can be undone, and must do the exact opposite of their Execute function when called with Unexecute.  However, not all rules need to be undone, so the function is not pure virtual, but instead provides a default (empty) function body.

Parameters

objectThe DataObject that gives direction to the IRule.  Must the the same DataObject that Execute was originally called with.

Protected

Summary
The IRule destructor.

Destructor

~IRule

virtual ~IRule()=0

The IRule destructor.  It is pure virtual because this class must be derived from in order to be used.

virtual void Execute(const DataObject &object)=0
Executes a rule.
virtual void Unexecute(const DataObject &object)
Unexecutes a rule.
virtual ~IRule()=0
The IRule destructor.
The interface for a single game rule.
Still volatile.
The interface of a single piece of game logic.
The base class for any IRule or ILogic mixin objects.
A repository of all things rules-related.
The interface for undoable IRules.
The interface of the plugin engine.
The default implementation of the IRuleEngine interface.
RulesCore is the HOSS of Cities3D.
A generic container for passing any kind of data around.