1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/**********************************************************************
Audacity: A Digital Audio Editor
Registrar.cpp
James Crook
Audacity is free software.
This file is licensed under the wxWidgets license, see License.txt
********************************************************************//**
\class Registrar
\brief Registrar is a class that other classes register resources of
various kinds with. It makes a system that is much more amenable to
plugging in of new resources.
*//********************************************************************/
#include <wx/wx.h>
#include "Registrar.h"
Registrar * pRegistrar = NULL;
// By defining the external function and including it here, we save ourselves maintaing two lists.
// Also we save ourselves recompiling Registrar each time the classes that regiser change.
// Part of the idea is that the Registrar knows very little about the classes that
// register with it.
#define DISPATCH( Name ) extern int Name##Dispatch( Registrar & R, t_RegistrarDispatchType Type );\
Name##Dispatch( *pRegistrar, Type )
// Not a class function, otherwise the functions called
// are treated as belonging to the class.
int RegistrarDispatch( t_RegistrarDispatchType Type )
{
wxASSERT( pRegistrar != NULL );
DISPATCH( SkewedRuler );
DISPATCH( MidiArtist );
DISPATCH( WaveArtist );
DISPATCH( EnvelopeArtist );
DISPATCH( LabelArtist );
DISPATCH( DragGridSizer );
DISPATCH( TrackPanel2 );
return 0;
}
// Start()
// Static function. Allocates Registrar.
void Registrar::Start()
{
wxASSERT( pRegistrar ==NULL );
pRegistrar = new Registrar();
RegistrarDispatch( RegResource );
RegistrarDispatch( RegArtist );
RegistrarDispatch( RegDataType );
RegistrarDispatch( RegCommand );
RegistrarDispatch( RegMenuItem );
}
// Finish()
// Static function. DeAllocates Registrar.
void Registrar::Finish()
{
wxASSERT( pRegistrar !=NULL );
delete pRegistrar;
pRegistrar = NULL;
}
void Registrar::ShowNewPanel()
{
wxASSERT( pRegistrar !=NULL );
if( pRegistrar->pShowFn != NULL)
pRegistrar->pShowFn();
}
|