SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
CommandLineProcessor.hh
Go to the documentation of this file.
1 #ifndef SLIC_COMMANDLINEPROCESSOR_HH_
2 #define SLIC_COMMANDLINEPROCESSOR_HH_ 1
3 
4 // STL
5 #include <string>
6 #include <map>
7 #include <vector>
8 
9 // SLIC
10 #include "CommandLineOption.hh"
11 #include "CommandQueue.hh"
12 #include "Module.hh"
13 #include "PackageInfo.hh"
14 #include "Singleton.hh"
15 
16 namespace slic {
17 
28 class CommandLineProcessor: public Module, public Singleton<CommandLineProcessor> {
29 
30  public:
31 
35  typedef std::pair<std::string, std::string> OptionsPair;
36 
40  typedef std::vector<CommandLineProcessor::OptionsPair> CommandLineArguments;
41 
45  typedef std::vector<CommandLineOption*> OptionsList;
46 
47  public:
48 
53 
57  virtual ~CommandLineProcessor();
58 
59  public:
60 
78  void process(int argc, char** argv);
79 
83  void printOptions();
84 
88  void printVersion() {
89  log() << LOG::okay << PackageInfo::getShortName() << " " << PackageInfo::getVersion() << LOG::done;
90  }
91 
98  return &m_g4q;
99  }
100 
104  void printUsage();
105 
106  private:
107 
112  void processOptions();
113 
121  void abort();
122 
129  void processOption(const std::string& option);
130 
137  void addOption(CommandLineOption* option);
138 
144  CommandLineOption* getCommandLineOption(const std::string& option);
145 
150  void createOptionsString();
151 
155  void registerOptions();
156 
162  bool hasOption(const std::string& option);
163 
164  private:
165 
168 
171 
174 
175  // Flags to be set by the process function.
179 
181  std::string m_getoptOptions;
182 };
183 }
184 
185 #endif
Command-line option with a single letter, full name and description plus an associated Geant4 command...
Command line processor for SLIC that uses getopt.
CommandLineOption * getCommandLineOption(const std::string &option)
std::vector< CommandLineProcessor::OptionsPair > CommandLineArguments
std::vector< CommandLineOption * > OptionsList
void processOption(const std::string &option)
CommandLineArguments m_commandline
void process(int argc, char **argv)
void addOption(CommandLineOption *option)
bool hasOption(const std::string &option)
std::pair< std::string, std::string > OptionsPair
A queue of G4 commands to be executed in order.
Definition: CommandQueue.hh:18
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
@ okay
Definition: LogStream.hh:33
@ done
Definition: LogStream.hh:26