PluginEngine

The default implementation of the IPluginEngine interface.  PluginEngine finds and keeps track of all plugin modules located in the /plugins subdirectory.  The functions required by the IPluginEngine interface are implemented using the various methods of storing the plugin module information.  See the function and variable documentation below.

Derived From

IPluginEngine

Project

RulesCore

Include

PluginEngine.h

Summary
The default implementation of the IPluginEngine interface.
The PlugineEngine constructor.
Starts the PluginEngine.
Stops the PluginEngine.
Fills the given array with all loaded RuleSets.
Determines if a plugin module is loaded.
Determines if a RuleSet within a given module is loaded.
Loads a RuleSet into the GameEngine.
Loads an AI into the GameEngine.
Retrieves BankData from all of the currently loaded RuleSets.
Retreives PlayerData from all of the currently loaded RuleSets.
Retreives BuildData from all of the currently loaded RuleSets.
The default PluginEngine constructor.
Loads data from the given RuleSet into the GameEngine.
Still volatile.
Finds plugin modules in the /plugins directory.
The std::map of the names of RuleSet-providing modules to the paths to those modules.
The std::map of the names of AI-providing modules to the paths to those modules.
The std::map of RuleSet-providing module names to the wxDynamicLibrary containing the loaded module.
The std::map of AI-providing module names to the wxDynamicLibrary containing the loaded module.
The std::vector of loaded RuleSets, grouped by the module they were loaded from, and preserved in load order.
The std::vector of loaded AIs, grouped by the module they were loaded from, and preserved in load order.
The boost::weak_ptr to the RuleEngine that will receive IRule and ILogic data from any RuleSets being loaded.
The boost::weak_ptr to the GameObjectEngine that will receive IGameObject data from any RuleSets being loaded.
The boost::weak_ptr to the DrawObjectEngine that will receive IDrawObject data from any RuleSets being loaded.
The boost::weak_ptr to the ImageEngine that will receive ImageSet data from any RuleSets being loaded.

Public

Summary
The PlugineEngine constructor.
Starts the PluginEngine.
Stops the PluginEngine.
Fills the given array with all loaded RuleSets.
Determines if a plugin module is loaded.
Determines if a RuleSet within a given module is loaded.
Loads a RuleSet into the GameEngine.
Loads an AI into the GameEngine.
Retrieves BankData from all of the currently loaded RuleSets.
Retreives PlayerData from all of the currently loaded RuleSets.
Retreives BuildData from all of the currently loaded RuleSets.

Constructors

PluginEngine

PluginEngine(boost::weak_ptr<RuleEngine> engine,
boost::weak_ptr<GameObjectEngine> game,
boost::weak_ptr<DrawObjectEngine> draw,
boost::weak_ptr<ImageEngine> image)

The PlugineEngine constructor.  Stores the given boost::weak_ptrs to other engines.

Functions

Start

void Start()

Starts the PluginEngine.  Calls FindPlugins to locate available plugin modules.  Then loads the Core RuleSet out of the CoreRules module.

Stop

void Stop()

Stops the PluginEngine.  Clears all AI and RuleSet paths.  Clears all loaded AI and RuleSet names and modules.

GetLoadedRuleSets

void GetLoadedRuleSets(StringPairArray &array)

Fills the given array with all loaded RuleSets.  The RuleSets are stored in the array in a std::pair where the first element is the name of the module the RuleSet is in, and the second element is the name of the <Ruleset> itself.

Parameters

arrayThe array to fill with loaded RuleSet information.

Virtual Functions

IsLoaded

virtual bool IsLoaded(const wxString &module)

Determines if a plugin module is loaded.  Checks in the RuleSet PluginMap for a module with the given name.  If an entry is found, the RuleSet has been loaded.

Parameters

moduleThe name of the plugin module to check.

Returns

A bool stating if the module is loaded.  The value is true if it is, false if not.

IsLoaded

virtual bool IsLoaded(const wxString &module,
const wxString &ruleset)

Determines if a RuleSet within a given module is loaded.  First calls the module-only version of IsLoaded to see if the module has been loaded.  If so, checks in the std::list of loaded RuleSets for that module name to see if the given RuleSet has been loaded.

Parameters

moduleThe name of the module the RuleSet is in.
rulesetThe name of the RuleSet to check.

Returns

A bool stating if the RuleSet is loaded.  The value is true if both the module and RuleSet or loaded, and false if either the RuleSet, or the module is not loaded.

LoadRuleset

virtual bool LoadRuleset(const wxString &module,
const wxString &ruleset)

Loads a RuleSet into the GameEngine.  Immediately checks to see if the module is even available to load.  If yes, and the module has not been loaded into memory, it is loaded via wxWidget’s wxDynamicLibrary class.  The loaded module is then queried for the ProvideRuleSets function.  If the module fails to load, or fails to provide the proper access function, LoadRuleset fails and returns false.

Once the ProvideRuleSets function has been located, a const reference to a std::map of RuleSets is created from the return value of the ProvideRuleSets function.  The std::map is searched for the name of the RuleSet to load.  If the module does not provide the RuleSet (i.e., it is not in the std::map), the function fails and returns false.  If the module provides the given RuleSet, it is then loaded into the GameEngine by calling LoadRulesetPrivate.

Parameters

moduleThe name of the module the RuleSet is in.
rulesetThe RuleSet to load.

Returns

A bool indicating the success of the load.  The value is true if the RuleSet was loaded, false if not.

LoadAI

virtual bool LoadAI(const wxString &module,
const wxString &ai)

Loads an AI into the GameEngine.  Still volatile.

Parameters

moduleThe name of the module the AI is in.
aiThe AI to load.

Returns

A bool indicating the success of the load.  The value is true if the AI was loaded, false if not.

LoadBankData

virtual void LoadBankData(std::vector<BankDataPtr> &array)

Retrieves BankData from all of the currently loaded RuleSets.  Searches through all loaded RuleSets, checking to see if they provide any BankData.  If BankData is provided by a RuleSet, it is appended to the outgoing std::vector.

Parameters

arrayThe outgoing array of BankData that will be filled by the function.

LoadPlayerData

virtual void LoadPlayerData(std::vector<PlayerDataPtr> &array)

Retreives PlayerData from all of the currently loaded RuleSets.  Searches through all loaded RuleSets, checking to see if they provide any PlayerData.  If PlayerData is provided by a RuleSet, it is appended to the outgoing std::vector.

Parameters

arrayThe outgoing array of PlayerData that will be filled by the function.

LoadBuildData

virtual void LoadBuildData(std::vector<BuildDataPtr> &array)

Retreives BuildData from all of the currently loaded RuleSets.  Searches through all loaded RuleSets, checking to see if they provide any BuildData.  If BuildData is provided by a RuleSet, it is appended to the outgoing std::vector.

Parameters

arrayThe outgoing array of BuildData that will be filled by the function.

Private

Summary
The default PluginEngine constructor.
Loads data from the given RuleSet into the GameEngine.
Still volatile.
Finds plugin modules in the /plugins directory.
The std::map of the names of RuleSet-providing modules to the paths to those modules.
The std::map of the names of AI-providing modules to the paths to those modules.
The std::map of RuleSet-providing module names to the wxDynamicLibrary containing the loaded module.
The std::map of AI-providing module names to the wxDynamicLibrary containing the loaded module.
The std::vector of loaded RuleSets, grouped by the module they were loaded from, and preserved in load order.
The std::vector of loaded AIs, grouped by the module they were loaded from, and preserved in load order.
The boost::weak_ptr to the RuleEngine that will receive IRule and ILogic data from any RuleSets being loaded.
The boost::weak_ptr to the GameObjectEngine that will receive IGameObject data from any RuleSets being loaded.
The boost::weak_ptr to the DrawObjectEngine that will receive IDrawObject data from any RuleSets being loaded.
The boost::weak_ptr to the ImageEngine that will receive ImageSet data from any RuleSets being loaded.

Constructors

The default PluginEngine constructor.  Declared private so that the PluginEngine is always created with pointers to the other game engines.

Functions

LoadRulesetPrivate

void LoadRulesetPrivate(const RuleSetPtr &ruleset,
const wxString &module,
const wxString &name)

Loads data from the given RuleSet into the GameEngine.  First appends the RuleSet name and module name to the std::vector of std::lists of open rulesets to record the loading of the RuleSet and the order in which it happened.  Then locks the boost::weak_ptrs to the RuleEngine, DrawObjectEngine, and ImageEngine so that they can be used.  Copies all of the IRules, ILogic, mixin strings, and branch priority ILogic from the RuleSet into the RuleEngine.  Copies all of the IGameObjects from the RuleSet into the GameObjectEngine.  Copies all of the IDrawObjects from the RuleSet into the DrawObjectEngine.  Copies all of the ImageSets from the RuleSet into the ImageEngine.

Parameters

rulesetThe RuleSet being loaded.
moduleThe name of the module the RuleSet is in.
nameThe name of the RuleSet.

LoadAIPrivate

void LoadAIPrivate(const AIPtr &ai,
const wxString &module,
const wxString &name)

Still volatile.

Parameters

aiThe AI being loaded.
moduleThe name of the module the AI is in.
nameThe name of the AI.

FindPlugins

void FindPlugins()

Finds plugin modules in the /plugins directory.  Examines each file that ends in .dll on Win32 or .so on Linux, within the plugins subdirectory.  Examines each dynamic library to see if it provides a ProvideRuleSets or a ProvideAI function.  If either is provided, the module name and path to the module are added as entries in the PluginMaps of RuleSets or AIs, respectively.

Variables

mRulesetPaths

StringMap mRulesetPaths

The std::map of the names of RuleSet-providing modules to the paths to those modules.

mAIPaths

StringMap mAIPaths

The std::map of the names of AI-providing modules to the paths to those modules.

mRulePlugins

PluginMap mRulePlugins

The std::map of RuleSet-providing module names to the wxDynamicLibrary containing the loaded module.  A wxDynamicLibrary unloads its module from memory when it is destroyed, which means that the destruction of the std::map must happen after all previous memory shared across address spaces has been cleaned up.

mRulePlugins

The std::map of AI-providing module names to the wxDynamicLibrary containing the loaded module.  A wxDynamicLibrary unloads its module from memory when it is destroyed, which means that the destruction of the std::map must happen after all previous memory shared across address spaces has been cleaned up.

mLoadedRulesets

StringListPairArray mLoadedRulesets

The std::vector of loaded RuleSets, grouped by the module they were loaded from, and preserved in load order.

mLoadedAIs

StringListPairArray mLoadedAIs

The std::vector of loaded AIs, grouped by the module they were loaded from, and preserved in load order.

mpRuleEngine

boost::weak_ptr<RuleEngine> mpRuleEngine

The boost::weak_ptr to the RuleEngine that will receive IRule and ILogic data from any RuleSets being loaded.

mpGameObjectEngine

boost::weak_ptr<GameObjectEngine> mpGameObjectEngine

The boost::weak_ptr to the GameObjectEngine that will receive IGameObject data from any RuleSets being loaded.

mpDrawObjectEngine

boost::weak_ptr<DrawObjectEngine> mpDrawObjectEngine

The boost::weak_ptr to the DrawObjectEngine that will receive IDrawObject data from any RuleSets being loaded.

mpImageEngine

boost::weak_ptr<ImageEngine> mpImageEngine

The boost::weak_ptr to the ImageEngine that will receive ImageSet data from any RuleSets being loaded.

The interface of the plugin engine.
PluginEngine(boost::weak_ptr<RuleEngine> engine,
boost::weak_ptr<GameObjectEngine> game,
boost::weak_ptr<DrawObjectEngine> draw,
boost::weak_ptr<ImageEngine> image)
The PlugineEngine constructor.
void Start()
Starts the PluginEngine.
void Stop()
Stops the PluginEngine.
void GetLoadedRuleSets(StringPairArray &array)
Fills the given array with all loaded RuleSets.
A repository of all things rules-related.
virtual bool IsLoaded(const wxString &module)
Determines if a plugin module is loaded.
virtual bool LoadRuleset(const wxString &module,
const wxString &ruleset)
Loads a RuleSet into the GameEngine.
The engine that drives the game.
virtual bool LoadAI(const wxString &module,
const wxString &ai)
Loads an AI into the GameEngine.
Still volatile.
virtual void LoadBankData(std::vector<BankDataPtr> &array)
Retrieves BankData from all of the currently loaded RuleSets.
Describes a stack of cards to be drawn in the BankUI.
virtual void LoadPlayerData(std::vector<PlayerDataPtr> &array)
Retreives PlayerData from all of the currently loaded RuleSets.
Describes a piece of information that needs to be displayed in the PlayerUI.
virtual void LoadBuildData(std::vector<BuildDataPtr> &array)
Retreives BuildData from all of the currently loaded RuleSets.
RulesCore
void LoadRulesetPrivate(const RuleSetPtr &ruleset,
const wxString &module,
const wxString &name)
Loads data from the given RuleSet into the GameEngine.
void LoadAIPrivate(const AIPtr &ai,
const wxString &module,
const wxString &name)
Still volatile.
void FindPlugins()
Finds plugin modules in the /plugins directory.
StringMap mRulesetPaths
The std::map of the names of RuleSet-providing modules to the paths to those modules.
StringMap mAIPaths
The std::map of the names of AI-providing modules to the paths to those modules.
PluginMap mRulePlugins
The std::map of RuleSet-providing module names to the wxDynamicLibrary containing the loaded module.
StringListPairArray mLoadedRulesets
The std::vector of loaded RuleSets, grouped by the module they were loaded from, and preserved in load order.
StringListPairArray mLoadedAIs
The std::vector of loaded AIs, grouped by the module they were loaded from, and preserved in load order.
boost::weak_ptr<RuleEngine> mpRuleEngine
The boost::weak_ptr to the RuleEngine that will receive IRule and ILogic data from any RuleSets being loaded.
The default implementation of the IRuleEngine interface.
The interface for a single game rule.
The interface of a single piece of game logic.
boost::weak_ptr<GameObjectEngine> mpGameObjectEngine
The boost::weak_ptr to the GameObjectEngine that will receive IGameObject data from any RuleSets being loaded.
The default implementation of the IGameObjectEngine interface.
An interface for all game objects.
boost::weak_ptr<DrawObjectEngine> mpDrawObjectEngine
The boost::weak_ptr to the DrawObjectEngine that will receive IDrawObject data from any RuleSets being loaded.
The standard implementation of the IDrawObjectEngine interface.
The interface for objects that are drawn on screen.
boost::weak_ptr<ImageEngine> mpImageEngine
The boost::weak_ptr to the ImageEngine that will receive ImageSet data from any RuleSets being loaded.
The standard implementation of the IImageEngine interface.
A repository of knowledge about a .tex file.
RulesCore is the HOSS of Cities3D.