RuleBase

A common base class for RuleSet and AI.  Both RuleSets and AIs have their own internal IRules, ILogic, and mixins.  The class RuleBase provides a common foundation so that no code has to be repeated in the higher-level classes.  RuleBase holds the string-based hash maps of IRules and ILogic, as well as the string-based hash map of mixin strings.

Project

RulesCore

Include

RuleBase.h

Summary
A common base class for RuleSet and AI.
Provides an iterator to the start of the IRule hash.
Provides an iterator to the end of the IRule hash.
Provides an iterator to the start of the ILogic hash.
Provides an iterator to the end of the ILogic hash.
Provides an iterator to the start of the mixin hash.
Provides an iterator to the end of the mixin hash.
The RuleBase destructor.
Adds an IRule to the rule hash.
Adds a piece of ILogic to the logic hash.
Adds a mixin to the mixin hash.
The string-based hash of IRules.
The string-based hash of ILogic.
The string-based hash of mixin strings.

Public

Summary
Provides an iterator to the start of the IRule hash.
Provides an iterator to the end of the IRule hash.
Provides an iterator to the start of the ILogic hash.
Provides an iterator to the end of the ILogic hash.
Provides an iterator to the start of the mixin hash.
Provides an iterator to the end of the mixin hash.

Functions

rules_begin

IRuleEngine::RuleHash::const_iterator rules_begin() const

Provides an iterator to the start of the IRule hash.

Returns

A const_iterator to the start of IRule hash.

rules_end

IRuleEngine::RuleHash::const_iterator rules_end() const

Provides an iterator to the end of the IRule hash.

Returns

A const_iterator to the end of IRule hash.

logic_begin

IRuleEngine::LogicHash::const_iterator logic_begin() const

Provides an iterator to the start of the ILogic hash.

Returns

A const_iterator to the start of ILogic hash.

logic_end

IRuleEngine::LogicHash::const_iterator logic_end() const

Provides an iterator to the end of the ILogic hash.

Returns

A const_iterator to the end of ILogic hash.

mixins_begin

IRuleEngine::MixinHash::const_iterator mixins_begin() const

Provides an iterator to the start of the mixin hash.

Returns

A const_iterator to the start of mixin hash.

mixins_end

IRuleEngine::MixinHash::const_iterator mixins_end() const

Provides an iterator to the end of the mixin hash.

Returns

A const_iterator to the end of mixin hash.

Protected

Summary
The RuleBase destructor.

Destructor

~RuleBase

virtual ~RuleBase()=0

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

Private

Summary
Adds an IRule to the rule hash.
Adds a piece of ILogic to the logic hash.
Adds a mixin to the mixin hash.
The string-based hash of IRules.
The string-based hash of ILogic.
The string-based hash of mixin strings.

Functions

RegisterRule

void RegisterRule(const RulePtr &rule,
const wxString &name)

Adds an IRule to the rule hash.  The given IRule is stored in the hash with the given string name as its key.

Parameters

ruleThe IRule to add to the hash.
nameThe name of the IRule.  Used as the key for the IRule in the hash.

RegisterLogic

void RegisterLogic(const LogicPtr &logic,
const wxString &name)

Adds a piece of ILogic to the logic hash.  The given ILogic is stored in the hash with the given string name as its key.

Parameters

ruleThe ILogic to add to the hash.
nameThe name of the ILogic.  Used as the key for the ILogic in the hash.

RegisterMixin

void RegisterMixin(const wxString &rule,
const wxString &key,
const wxString &mixin)

Adds a mixin to the mixin hash.  The mixin name is inserted at the given key into the hash map of mixins for the given rule name.

Parameters

ruleThe name of the IRule or ILogic the mixin name applies to.
keyThe hash key at which to store the mixin rule name.
mixinThe name of the mixin IRule or ILogic being applied.

Variables

mRuleHash

IRuleEngine::RuleHash mRuleHash

The string-based hash of IRules.

mLogicHash

IRuleEngine::LogicHash mLogicHash

The string-based hash of ILogic.

mMixinHash

IRuleEngine::MixinHash mMixinHash

The string-based hash of mixin strings.

A repository of all things rules-related.
Still volatile.
IRuleEngine::RuleHash::const_iterator rules_begin() const
Provides an iterator to the start of the IRule hash.
The interface for a single game rule.
IRuleEngine::RuleHash::const_iterator rules_end() const
Provides an iterator to the end of the IRule hash.
IRuleEngine::LogicHash::const_iterator logic_begin() const
Provides an iterator to the start of the ILogic hash.
The interface of a single piece of game logic.
IRuleEngine::LogicHash::const_iterator logic_end() const
Provides an iterator to the end of the ILogic hash.
IRuleEngine::MixinHash::const_iterator mixins_begin() const
Provides an iterator to the start of the mixin hash.
IRuleEngine::MixinHash::const_iterator mixins_end() const
Provides an iterator to the end of the mixin hash.
virtual ~RuleBase()=0
The RuleBase destructor.
void RegisterRule(const RulePtr &rule,
const wxString &name)
Adds an IRule to the rule hash.
void RegisterLogic(const LogicPtr &logic,
const wxString &name)
Adds a piece of ILogic to the logic hash.
void RegisterMixin(const wxString &rule,
const wxString &key,
const wxString &mixin)
Adds a mixin to the mixin hash.
IRuleEngine::RuleHash mRuleHash
The string-based hash of IRules.
IRuleEngine::LogicHash mLogicHash
The string-based hash of ILogic.
IRuleEngine::MixinHash mMixinHash
The string-based hash of mixin strings.
RulesCore is the HOSS of Cities3D.