CommandLineProcessor.hh

Go to the documentation of this file.
00001 // $id: $
00002 #ifndef SLIC_COMMANDLINEPROCESSOR_HH
00003 #define SLIC_COMMANDLINEPROCESSOR_HH
00004 
00005 // stl
00006 #include <string>
00007 #include <map>
00008 #include <vector>
00009 
00010 // slic
00011 #include "CommandLineOption.hh"
00012 #include "CommandQueue.hh"
00013 #include "Module.hh"
00014 #include "PackageInfo.hh"
00015 #include "Singleton.hh"
00016 
00017 namespace slic
00018 { 
00031   class CommandLineProcessor : public Module, public Singleton<CommandLineProcessor>
00032   {
00033 
00034   public:
00035 
00039     typedef std::pair<std::string, std::string> OptionsPair;
00040 
00044     typedef std::vector<CommandLineProcessor::OptionsPair> CommandLineArguments;
00045 
00049     typedef std::vector<CommandLineOption*> OptionsList;
00050 
00051   public:
00052     virtual ~CommandLineProcessor();
00053     CommandLineProcessor();
00054 
00055   public:
00056 
00072     void process(int argc, char** argv);
00073 
00077     void printOptions();
00078 
00082     void printVersion()
00083     {    
00084       log() << LOG::okay << PackageInfo::getFullApplicationString() << LOG::done;
00085     }
00086 
00091     CommandQueue* getCommandQueue()
00092     {
00093       return &m_g4q;
00094     }
00095 
00099     void printUsage();
00100 
00101   private:
00102 
00107     void processOptions();
00108 
00116     inline void abort();
00117 
00123     inline void processOption(const std::string&);
00124 
00130     inline void addOption(CommandLineOption*);
00131  
00135     inline CommandLineOption* getCommandLineOption(const std::string& opt);
00136 
00141     inline void createOptionsString();
00142 
00146     inline void registerOptions();
00147 
00151     inline bool hasOption(const std::string& opt);
00152 
00153   private:
00154     
00155     // A vector of options with their arguments.
00156     CommandLineArguments m_commandline;
00157 
00158     // A list of Geant4 macro commands filled by processing the command line arguments.
00159     CommandQueue m_g4q;
00160 
00161     // The list of valid options and their associated meta-data.
00162     OptionsList m_cmds;
00163 
00164     // Flags to be set by the process function.
00165     int m_help_flag;
00166     int m_interactive_flag;
00167     int m_version_flag;
00168 
00169     // The getopt options string, which is created automatically.
00170     std::string m_getoptOptions;
00171   };
00172 }
00173 
00174 #endif

Generated on Thu Nov 15 15:24:15 2007 for Simulator for the Linear Collider by  doxygen 1.5.4