LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
UserActionFactory.h File Reference

A class for generating concrete UserAction derived classes based on the factory pattern. This code supplies a CPP macro which allows the classes to self-register and thus no modification of this class is needed in order to expand the list of classes it knows about. More...

#include <string>
#include <vector>
#include <map>
#include "nutools/G4Base/UserAction.h"

Go to the source code of this file.

Classes

class  g4b::UserActionFactory
 
struct  g4b::UserActionFactory::Cleaner
 

Namespaces

 g4b
 basic interface to Geant4 for ART-based software
 

Macros

#define USERACTIONREG(_name)
 
#define USERACTIONREG3(_ns, _name, _fqname)
 
#define USERACTIONREG4(_nsa, _nsb, _name, _fqname)
 

Typedefs

typedef g4b::UserAction *(* g4b::UserActionCtorFuncPtr_t) ()
 

Detailed Description

A class for generating concrete UserAction derived classes based on the factory pattern. This code supplies a CPP macro which allows the classes to self-register and thus no modification of this class is needed in order to expand the list of classes it knows about.

Implemented as a singleton holding a map between names and pointers-to-functions (that call a class default constructor). The functions pointers must return UserAction*.

Version
Author
Robert Hatcher <rhatcher fnal.gov> Fermi National Accelerator Laboratory

Definition in file UserActionFactory.h.

Macro Definition Documentation

#define USERACTIONREG (   _name)
Value:
g4b::UserAction* _name ## _ctor_function () { return new _name; } \
static bool _name ## _creator_registered = \
g4b::UserActionFactory::Instance().RegisterCreator(# _name, \
& _name ## _ctor_function, \
& _name ## _creator_registered );

Definition at line 112 of file UserActionFactory.h.

#define USERACTIONREG3 (   _ns,
  _name,
  _fqname 
)
Value:
namespace _ns { \
g4b::UserAction* _name ## _ctor_function () { return new _fqname; } \
static bool _name ## _creator_registered = \
g4b::UserActionFactory::Instance().RegisterCreator(# _fqname, \
& _fqname ## _ctor_function, \
& _fqname ## _creator_registered );}

Definition at line 119 of file UserActionFactory.h.

#define USERACTIONREG4 (   _nsa,
  _nsb,
  _name,
  _fqname 
)
Value:
namespace _nsa { \
namespace _nsb { \
g4b::UserAction* _name ## _ctor_function () { return new _fqname; } \
static bool _name ## _creator_registered = \
g4b::UserActionFactory::Instance().RegisterCreator(# _fqname, \
& _fqname ## _ctor_function, \
& _fqname ## _creator_registered );}}

Definition at line 127 of file UserActionFactory.h.