|
Version: 3.2.1
|
#include <wx/module.h>
The module system is a very simple mechanism to allow applications (and parts of wxWidgets itself) to define initialization and cleanup functions that are automatically called on wxWidgets startup and exit.
To define a new kind of module, derive a class from wxModule, override the wxModule::OnInit and wxModule::OnExit functions, and add the wxDECLARE_DYNAMIC_CLASS and wxIMPLEMENT_DYNAMIC_CLASS to header and implementation files (which can be the same file). On initialization, wxWidgets will find all classes derived from wxModule, create an instance of each, and call each wxModule::OnInit function. On exit, wxWidgets will call the wxModule::OnExit function for each module instance.
Note that your module class does not have to be in a header file.
For example:
{
public:
wxDDEModule() { }
private:
};
{
public:
virtual bool OnInit() { ... code
using DDE ... }
private:
};
{
public:
virtual bool OnInit() { ... code
using DDE ... }
private:
};
◆ wxModule()
◆ ~wxModule()
| virtual wxModule::~wxModule |
( |
| ) |
|
|
virtual |
◆ AddDependency() [1/2]
| void wxModule::AddDependency |
( |
const char * |
classname | ) |
|
|
protected |
Call this function from the constructor of the derived class.
This overload allows a dependency to be added by name without access to the class info.
This is useful when a module is declared entirely in a source file and there is no header for the declaration of the module needed by wxCLASSINFO(), however errors are not detected until run-time, instead of compile-time, then. Note that circular dependencies are detected and result in a fatal error.
- Parameters
-
| classname | The class name of the dependent module. |
◆ AddDependency() [2/2]
Call this function from the constructor of the derived class.
dep must be the wxCLASSINFO() of a wxModule-derived class and the corresponding module will be loaded before and unloaded after this module.
- Parameters
-
| dep | The class information object for the dependent module. |
◆ OnExit()
| virtual void wxModule::OnExit |
( |
| ) |
|
|
pure virtual |
Provide this function with appropriate cleanup for your module.
◆ OnInit()
| virtual bool wxModule::OnInit |
( |
| ) |
|
|
pure virtual |
Provide this function with appropriate initialization for your module.
If the function returns false, wxWidgets will exit immediately.
The module system is a very simple mechanism to allow applications (and parts of wxWidgets itself) to...
Definition: module.h:78
#define wxIMPLEMENT_DYNAMIC_CLASS(className, baseClassName)
Used in a C++ implementation file to complete the declaration of a class that has run-time type infor...
Definition: object.h:788
void wxDDEInitialize()
Initializes the DDE system.
virtual void OnExit()=0
Provide this function with appropriate cleanup for your module.
virtual bool OnInit()=0
Provide this function with appropriate initialization for your module.
void wxDDECleanUp()
Called when wxWidgets exits, to clean up the DDE system.
#define wxCLASSINFO(className)
Returns a pointer to the wxClassInfo object associated with this class.
Definition: object.h:682
void AddDependency(wxClassInfo *dep)
Call this function from the constructor of the derived class.
#define wxDECLARE_DYNAMIC_CLASS(className)
Used inside a class declaration to make the class known to wxWidgets RTTI system and also declare tha...
Definition: object.h:730