]> git.mxchange.org Git - simgear.git/commitdiff
Create a singleton for the parser table
authorTim Moore <timoore@redhat.com>
Sun, 19 Jul 2009 21:05:04 +0000 (23:05 +0200)
committerTim Moore <timoore@redhat.com>
Sun, 19 Jul 2009 21:05:04 +0000 (23:05 +0200)
simgear/structure/SGExpression.cxx
simgear/structure/SGExpression.hxx

index fa6650300fce9a0bf55f395b91b805ae4f6eb01b..162414876eb39d5a7b6229bcd7ee5bb65cfc08e9 100644 (file)
@@ -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)
index 2dac8efb1863c105bfd78b045af4289180df6c06..1589aab1ce95a4ae9bc8b809eb2b19e22b6dc390 100644 (file)
@@ -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;
+      };
   };
 
   /**