Create a singleton for the parser table
This commit is contained in:
@@ -690,11 +690,10 @@ bool Parser::readChildren(const SGPropertyNode* exp,
|
||||
return true;
|
||||
}
|
||||
|
||||
Parser::ParserMap ExpressionParser::_parserTable;
|
||||
|
||||
void ExpressionParser::addExpParser(const string& token, exp_parser parsefn)
|
||||
{
|
||||
_parserTable.insert(std::make_pair(token, parsefn));
|
||||
ParserMapSingleton::instance()
|
||||
->_parserTable.insert(std::make_pair(token, parsefn));
|
||||
}
|
||||
|
||||
Expression* valueParser(const SGPropertyNode* exp, Parser* parser)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
#include <simgear/scene/model/persparam.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/structure/Singleton.hxx>
|
||||
|
||||
/// Expression tree implementation.
|
||||
|
||||
@@ -1009,10 +1010,16 @@ namespace simgear
|
||||
class ExpressionParser : public Parser
|
||||
{
|
||||
public:
|
||||
ParserMap& getParserMap() { return _parserTable; }
|
||||
ParserMap& getParserMap()
|
||||
{
|
||||
return ParserMapSingleton::instance()->_parserTable;
|
||||
}
|
||||
static void addExpParser(const std::string&, exp_parser);
|
||||
protected:
|
||||
static ParserMap _parserTable;
|
||||
struct ParserMapSingleton : public simgear::Singleton<ParserMapSingleton>
|
||||
{
|
||||
ParserMap _parserTable;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user