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

In This Package:

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
OptionParser Class Reference

#include <OptionParser.h>

Collaboration diagram for OptionParser:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~OptionParser ()
bool validate ()

Static Public Member Functions

static OptionParserinstance (char *fname=0)
template<class Type >
static bool setOption (const std::string &client, const std::string &name, Type &var)
static bool addOption (const std::string &client, const std::string &name, const std::string &value)

Private Member Functions

 OptionParser (char *fname)
const std::string & name ()
bool getValueStr (const std::string &client, const std::string &name, std::string &value)

Private Attributes

Gaudi::Parsers::Cataloguem_entries
std::string m_name

Static Private Attributes

static OptionParser_instance = 0

Detailed Description

Definition at line 17 of file OptionParser.h.


Constructor & Destructor Documentation

OptionParser::~OptionParser ( ) [virtual]

Definition at line 59 of file OptionParser.cc.

{
    delete m_entries;
}
OptionParser::OptionParser ( char *  fname) [private]

Definition at line 38 of file OptionParser.cc.

    : m_name("OptionParser")
{
    m_entries = new Gaudi::Parsers::Catalogue();
    std::vector<std::string> m_included;
    Gaudi::Parsers::Parser parser(*m_entries, m_included);

    bool sc = parser.parse( fname );
    if ( !sc ) {
        using Gaudi::Parsers::Message;
        const std::vector<Message>& messages = parser.messages();
        for (std::vector<Message>::const_iterator it = messages.begin(); it != messages.end(); ++it ) {
            if ( it->severity() == Gaudi::Parsers::Message::E_ERROR ) {
                LogError << it->message() << std::endl;
            }
        }
        delete m_entries;
        throw LafException("OptionParser: error while parsing option file");
    }
}

Member Function Documentation

OptionParser * OptionParser::instance ( char *  fname = 0) [static]

Definition at line 9 of file OptionParser.cc.

{
    if ( _instance == 0 ) {
        _instance = new OptionParser(fname);
    }
    return _instance;
}
template<class Type >
bool OptionParser::setOption ( const std::string &  client,
const std::string &  name,
Type &  var 
) [static]

Definition at line 47 of file OptionParser.h.

{
    std::string value;
    if ( _instance->getValueStr(client, name, value) ) {
        return Gaudi::Parsers::parse(var, value);
    }
    return true;
}
bool OptionParser::addOption ( const std::string &  client,
const std::string &  name,
const std::string &  value 
) [static]

Definition at line 17 of file OptionParser.cc.

{
    std::string stringResult;
    std::vector<std::string> vectorResult;
    bool ok = Gaudi::Parsers::Utils::parseValue(value, stringResult, vectorResult);
    if ( ok ) {
        bool isVector = (vectorResult.size()>0) || (stringResult=="{}");
        if ( isVector ) {
            Gaudi::Parsers::PropertyEntry property(name, vectorResult);
            if ( _instance->m_entries->findProperty(client, name, property, false) ) {
                int count = 0;
                property.removeValues(vectorResult, count);
                property.addValues(vectorResult);
            }
            _instance->m_entries->addProperty(client, property);
        }
        return true;
    }
    return false;
}
bool OptionParser::validate ( )

Definition at line 64 of file OptionParser.cc.

{
    Gaudi::Parsers::Catalogue::CatalogueT left = m_entries->catalogue();
    if ( ! left.empty() ) {
        LogError << "INVALID OPTIONS FOUND." << std::endl;
        std::cout << "Attention: following line(s) in your configuration file is(are) not recognized:" << std::endl;
        m_entries->print(std::cout);
        std::cout << "Please ensure your spell is right, otherwise remove the useless settings!" << std::endl;
        return false;
    }
    return true;
}
const std::string& OptionParser::name ( void  ) [inline, private]

Definition at line 36 of file OptionParser.h.

{ return m_name; }
bool OptionParser::getValueStr ( const std::string &  client,
const std::string &  name,
std::string &  value 
) [private]

Definition at line 77 of file OptionParser.cc.

{
    Gaudi::Parsers::PropertyEntry property;
    if ( m_entries->findProperty(client, name, property, true) ) {
        value = property.value();
        return true;
    }
    return false;
}

Member Data Documentation

Definition at line 40 of file OptionParser.h.

std::string OptionParser::m_name [private]

Definition at line 41 of file OptionParser.h.

OptionParser * OptionParser::_instance = 0 [static, private]

Definition at line 43 of file OptionParser.h.


The documentation for this class was generated from the following files:
| 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