SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
Module.cc
Go to the documentation of this file.
1 // SLIC
2 #include "Module.hh"
3 #include "ModuleRegistry.hh"
4 
5 namespace slic {
6 
7 Module::Module(const std::string& name, bool deleteOnExit, bool autoRegister) :
8  m_deleteOnExit(deleteOnExit) {
9  m_name = name;
10 
11  // If requested, register the module with the ModuleRegistry.
12  if (autoRegister) {
13  ModuleRegistry::instance()->registerModule(this);
14  }
15 
16  // Create a logger for this module.
17  m_log = LogManager::instance()->createLogWithMessenger(m_name, LOG::okay);
18 
19  // Init message.
20 #ifdef SLIC_LOG
21  log().verbose( "Initialized module <" + getName() + ">" );
22 #endif
23 }
24 
26 #ifdef SLIC_LOG
27  log().verbose( getName() + " is being deleted." );
28 #endif
29  LogManager::instance()->removeLog(m_log);
30  ModuleRegistry::instance()->deregisterModule(this);
31 }
32 }
static ModuleRegistry * instance()
LogStream & verbose()
Definition: LogStream.hh:238
virtual ~Module()
Definition: Module.cc:25
const std::string & getName() const
Definition: Module.hh:54
Module(const std::string &name, bool deleteOnExit=true, bool autoRegister=true)
Definition: Module.cc:7
LogStream * m_log
Definition: Module.hh:155
std::string m_name
Definition: Module.hh:154
LogStream & log()
Definition: Module.hh:99
@ okay
Definition: LogStream.hh:33
@ name
Definition: LogStream.hh:26