ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/grimes/L1Menu/interface/l1menu/RegisterTriggerMacro.h
Revision: 1.3
Committed: Thu Jul 4 13:08:55 2013 UTC (11 years, 10 months ago) by grimes
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
Moved the RegisterTriggerMacro.h file into implementation

File Contents

# Content
1 #ifndef l1menu_RegisterTriggerMacro_h
2 #define l1menu_RegisterTriggerMacro_h
3
4 #include "l1menu/TriggerTable.h"
5
6 /* Macro that registers the ITrigger subclass named in the trigger table.
7 *
8 * This macro works by creating a new class called <triggername>Factory that calls TriggerTable::registerTrigger()
9 * in its constructor. It also has a static method that creates an instance of the ITrigger subclass, this is the
10 * function pointer that is supplied to the TriggerTable.
11 *
12 * A single instance of the <triggername>Factory is instantiated at global scope (within whatever namespace the
13 * macro was called in) so that the trigger will be registered before control passes to main, or whatever the user
14 * entry point is.
15 */
16 #define DEFINE_TRIGGER_FACTORY( NAME ) class NAME##Factory \
17 { \
18 public: \
19 NAME##Factory( void (*pFunction)()=NULL ) \
20 { \
21 NAME temporaryInstance; \
22 TriggerTable::instance().registerTrigger( temporaryInstance.name(), temporaryInstance.version(), (&this->createTrigger) ); \
23 if( pFunction ) (*pFunction)(); \
24 } \
25 static std::unique_ptr<l1menu::ITrigger> createTrigger() \
26 { \
27 return std::unique_ptr<l1menu::ITrigger>(new NAME); \
28 } \
29 }; \
30
31 #define REGISTER_TRIGGER( NAME ) DEFINE_TRIGGER_FACTORY( NAME ) \
32 NAME##Factory NAME##FactoryOnlyInstance;
33
34 #define REGISTER_TRIGGER_AND_CUSTOMISE( NAME, CUSTOM_FUNCTION_POINTER ) DEFINE_TRIGGER_FACTORY( NAME ) \
35 NAME##Factory NAME##FactoryOnlyInstance( CUSTOM_FUNCTION_POINTER );
36
37 #endif