1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: module.h
|
|
|
|
// Purpose: Modules handling
|
|
|
|
// Author: Wolfram Gloger/adapted by Guilhem Lavaux
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/11/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Wolfram Gloger and Guilhem Lavaux
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_MODULEH__
|
|
|
|
#define _WX_MODULEH__
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2002-08-31 11:29:13 +00:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1999-01-17 22:44:04 +00:00
|
|
|
#pragma interface "module.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/list.h"
|
|
|
|
|
1999-01-17 22:44:04 +00:00
|
|
|
// declare a linked list of modules
|
|
|
|
class wxModule;
|
2000-07-15 19:51:35 +00:00
|
|
|
WX_DECLARE_EXPORTED_LIST(wxModule, wxModuleList);
|
1999-01-17 22:44:04 +00:00
|
|
|
|
|
|
|
// declaring a class derived from wxModule will automatically create an
|
|
|
|
// instance of this class on program startup, call its OnInit() method and call
|
|
|
|
// OnExit() on program termination (but only if OnInit() succeeded)
|
|
|
|
class WXDLLEXPORT wxModule : public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
|
|
|
public:
|
1999-01-17 22:44:04 +00:00
|
|
|
wxModule() {}
|
|
|
|
virtual ~wxModule() {}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2001-12-19 07:09:58 +00:00
|
|
|
// if module init routine returns FALSE application
|
|
|
|
// will fail to startup
|
|
|
|
|
1999-01-17 22:44:04 +00:00
|
|
|
bool Init() { return OnInit(); }
|
|
|
|
void Exit() { OnExit(); }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2001-12-19 07:09:58 +00:00
|
|
|
// Override both of these
|
1999-01-17 22:44:04 +00:00
|
|
|
// called on program startup
|
2001-12-19 07:09:58 +00:00
|
|
|
|
1999-01-17 22:44:04 +00:00
|
|
|
virtual bool OnInit() = 0;
|
2001-12-19 07:09:58 +00:00
|
|
|
|
|
|
|
// called just before program termination, but only if OnInit()
|
1999-01-17 22:44:04 +00:00
|
|
|
// succeeded
|
2001-12-19 07:09:58 +00:00
|
|
|
|
1999-01-17 22:44:04 +00:00
|
|
|
virtual void OnExit() = 0;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
static void RegisterModule(wxModule* module);
|
1999-01-17 22:44:04 +00:00
|
|
|
static void RegisterModules();
|
|
|
|
static bool InitializeModules();
|
|
|
|
static void CleanUpModules();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2001-12-19 07:09:58 +00:00
|
|
|
// used by wxObjectLoader when unloading shared libs's
|
|
|
|
|
|
|
|
static void UnregisterModule(wxModule* module);
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
protected:
|
1999-01-17 22:44:04 +00:00
|
|
|
static wxModuleList m_modules;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-01-17 22:44:04 +00:00
|
|
|
DECLARE_CLASS(wxModule)
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
1999-01-17 22:44:04 +00:00
|
|
|
#endif // _WX_MODULEH__
|
1998-05-20 14:01:55 +00:00
|
|
|
|