/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

OptionParser.h
Go to the documentation of this file.
00001 #ifndef LAF_OPTION_PARSER_H
00002 #define LAF_OPTION_PARSER_H
00003 
00004 #include "LafKernel/Parsers.h"
00005 
00006 /**************************************************************************
00007  * Suppose in the options file, there exist:
00008  *    Object.Property = 9;
00009  * after calling:
00010  *     int  var;
00011  *     bool status = OptionParser::setOption("Object", "Property", var);
00012  * then the value "9" is assigned to "var" now.
00013  *************************************************************************/
00014 
00015 namespace Gaudi { namespace Parsers { class Catalogue; } }
00016 
00017 class OptionParser
00018 {
00019     public :
00020 
00021         static OptionParser* instance(char* fname = 0);
00022         virtual ~OptionParser();
00023 
00024         template<class Type>
00025         static bool setOption(const std::string& client, const std::string& name, Type& var);
00026 
00027         static bool addOption(const std::string& client, const std::string& name, const std::string& value);      
00028 
00029         bool validate();
00030 
00031 
00032     private :
00033 
00034         OptionParser(char* fname);
00035 
00036         const std::string& name() { return m_name; }
00037 
00038         bool getValueStr(const std::string& client, const std::string& name, std::string& value);
00039 
00040         Gaudi::Parsers::Catalogue*  m_entries;
00041         std::string  m_name;
00042 
00043         static OptionParser* _instance;
00044 };
00045 
00046 template<class Type>
00047 bool OptionParser::setOption(const std::string& client, const std::string& name, Type& var)
00048 {
00049     std::string value;
00050     if ( _instance->getValueStr(client, name, value) ) {
00051         return Gaudi::Parsers::parse(var, value);
00052     }
00053     return true;
00054 }
00055 
00056 #endif
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:18 for LafKernel by doxygen 1.7.4