GG::PluginInterface Class Reference

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

#include <PluginInterface.h>

List of all members.

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)

Structors

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

Accessors

 operator int ConvertibleToBoolDummy::* () const

Public Types

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


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 59 of file PluginInterface.h.


Member Typedef Documentation

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

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

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

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

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

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

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

The type of function used to serialize Wnds.

Definition at line 75 of file PluginInterface.h.

The type of function used to deserialize Wnds.

Definition at line 77 of file PluginInterface.h.


Constructor & Destructor Documentation

GG::PluginInterface::PluginInterface (  ) 

default ctor.

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").

GG::PluginInterface::~PluginInterface (  ) 

dtor.


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 
) [inline]

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 161 of file PluginInterface.h.

References LoadWnd.


Member Data Documentation

returns the name of this plugin

Definition at line 100 of file PluginInterface.h.

returns the default font name that should be used to create controls using this plugin.

Definition at line 101 of file PluginInterface.h.

returns the default font point size that should be used to create controls using this plugin.

Definition at line 102 of file PluginInterface.h.

returns a shared_ptr to the plugin's style factory, which creates controls and dialogs

Definition at line 103 of file PluginInterface.h.

serializes a Wnd to the given XML archive.

Definition at line 104 of file PluginInterface.h.

creates a new Wnd from the next one found in the given XML archive.

Definition at line 105 of file PluginInterface.h.

Referenced by LoadWndT().


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

Generated on Wed Mar 26 19:41:05 2008 for GG by  doxygen 1.5.5