The base class for any IRule or ILogic mixin objects. There are certain classes of rules or logic that require some kind of plugin architecture so that they can be extended by other modules. For example, at the start of the game, one IRule may handle initializing all of the Game data. However, what if other plugin modules have new data that needs to be initialized? Unless there was some way to notify that one IRule that there were other things that needed to be initialized, the situation would be hopeless.
Enter BaseMixin. The BaseMixin class provides a base class for new classes of mixin interfaces. An IRule may be derived from a mixin interface so that it supports being extended. The BaseMixin class stores a string-based hash map internally. In the RuleEngine, when an IRule is executed, the RuleEngine checks to see if the IRule has BaseMixin in its inheritancy chart (via a dynamic_cast<>). If so, the RuleEngine looks up in its internal string-based hash map to see if there are any mixin names for the IRule. If so, it copies those hash pairs into the BaseMixin hash map. A mixin value is nothing more than the name of another IRule or piece of ILogic that somehow extends the IRule with the mixin interface. It is up to the particular derived mixin interface to determine what it does with the actual mixin names. BaseMixin provides two means of accessing the hash map. If the derived mixin interface just wants to iterate through all of the available mixins, it can use the hash_begin and hash_end functions to iterate. If it needs to lookup the value at a particular key, it can use the hash_value function. See LogicBooleanMixin or RuleExtensionMixin for examples of derived mixin interfaces.
BaseMixin.h
Returns the mixin name at the given key. | |
Returns an iterator to the start of the mixin hash map. | |
Returns an iterator to the end of the mixin hash map. | |
The string-based hash of mixin names. |
|
Returns the mixin name at the given key. If none exists, an empty string is returned. It is up to the calling function to decide what to do with it.
| key | The key to look up in the mixin hash map. |
A const reference to a string containing the mixin name at the given key.
|
| IRuleEngine::StringHash::const_iterator hash_begin() const |
| IRuleEngine::StringHash::const_iterator hash_end() const |
| IRuleEngine::StringHash mStringHash |