GG
Public Types

GG::PluginInterface Class Reference

The interface to custom-control plugins. More...

#include <PluginInterface.h>

List of all members.

Public Types

typedef const char *(* PluginNameFn )()
typedef const char *(* DefaultFontNameFn )()
typedef unsigned int(* DefaultFontSizeFn )()
typedef boost::shared_ptr
< StyleFactory >(* 
GetStyleFactoryFn )()
typedef GUI::SaveWndFn SaveWndFn
typedef GUI::LoadWndFn LoadWndFn

Structors

 PluginInterface ()
 PluginInterface (const std::string &lib_name)
 ~PluginInterface ()

Accessors

 operator int ConvertibleToBoolDummy::* () const

Mutators

PluginNameFn PluginName
DefaultFontNameFn DefaultFontName
DefaultFontSizeFn DefaultFontSize
GetStyleFactoryFn GetStyleFactory
SaveWndFn SaveWnd
LoadWndFn LoadWnd
bool Load (const std::string &lib_name)
template<class T >
void LoadWndT (T *&wnd, const std::string &name, boost::archive::xml_iarchive &ar)

Detailed Description

The interface to custom-control plugins.

This class is used to access derived GG controls and dialogs that are unknown until runtime, but are available for dynamic loading in shared libraries/DLLs. The interface basically allows you to create custom controls and dialogs (anything a StyleFactory can produce) from a dynamic-link library, which in turn allows you to change the styles of the controls in an application without recompiling, or even relinking. While the interface is in an unloaded state, the functions in the interface are all null, and calling any of them will crash your app. Once a plugin has been loaded, all the functions in the interface should be valid (if the plugin author did everything correctly). The plugin interface also provides SaveWnd() and LoadWnd() methods to serialize all types in the GG::Wnd hierarchy. Note that includes all the original GG types, not just the ones added by the plugin; if Wnd is not serializable, none of its descendents are either.

Definition at line 67 of file PluginInterface.h.


Member Typedef Documentation

typedef const char*(* GG::PluginInterface::PluginNameFn)()

The type of function that supplies the name of the plugin.

Definition at line 74 of file PluginInterface.h.

typedef const char*(* GG::PluginInterface::DefaultFontNameFn)()

The type of function that supplies the name of the plugin's default font.

Definition at line 77 of file PluginInterface.h.

typedef unsigned int(* GG::PluginInterface::DefaultFontSizeFn)()

The type of function that supplies the plugin's default font size.

Definition at line 79 of file PluginInterface.h.

typedef boost::shared_ptr<StyleFactory>(* GG::PluginInterface::GetStyleFactoryFn)()

The type of function that supplies the plugin's StyleFactory.

Definition at line 81 of file PluginInterface.h.

The type of function used to serialize Wnds.

Definition at line 84 of file PluginInterface.h.

The type of function used to deserialize Wnds.

Definition at line 86 of file PluginInterface.h.


Constructor & Destructor Documentation

GG::PluginInterface::PluginInterface ( const std::string &  lib_name)

Ctor that loads the plugin file lib_name. The base filename should be provided, without the extension (i.e. "foo", not "foo.so" or "foo.dll").


Member Function Documentation

GG::PluginInterface::operator int ConvertibleToBoolDummy::* ( ) const

Returns true iff this PluginInterface has a loaded plugin. This is a conversion operator, allowing you to test the validity of the interface, as you would a pointer (e.g. if (my_interface) my_interface.PluginName();).

Warning:
If this method returns false, the functions in the interface are invalid.
bool GG::PluginInterface::Load ( const std::string &  lib_name)

Loads the plugin lib_name, unloading the currently-loaded plugin if necessary.

template<class T >
void GG::PluginInterface::LoadWndT ( T *&  wnd,
const std::string &  name,
boost::archive::xml_iarchive &  ar 
)

Since LoadWnd() will only accept a referemce to a Wnd*, this method is provided to more conveniently accept Wnd subclass pointers. It unfortunately cannot overload the name of LoadWnd, which is a data member.

Definition at line 183 of file PluginInterface.h.

References LoadWnd.


The documentation for this class was generated from the following file: