]> git.mxchange.org Git - simgear.git/blobdiff - simgear/structure/commands.cxx
Fix case typo
[simgear.git] / simgear / structure / commands.cxx
index 2e2c59215494430a72498266e4617960d4f0bab9..b2391e3ba7f1cff7986f8eacf5364e985739ee56 100644 (file)
@@ -4,10 +4,20 @@
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
+#include <memory>
 #include <simgear/props/props_io.hxx>
 
+#include <OpenThreads/Mutex>
+#include <OpenThreads/ScopedLock>
+
 #include "commands.hxx"
 
+#include <simgear/math/SGMath.hxx>
+
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -25,6 +35,23 @@ SGCommandMgr::~SGCommandMgr ()
   // no-op
 }
 
+OpenThreads::Mutex SGCommandMgr::_instanceMutex;
+
+SGCommandMgr*
+SGCommandMgr::instance()
+{
+  static std::auto_ptr<SGCommandMgr> mgr;
+  if (mgr.get())
+    return mgr.get();
+
+  OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_instanceMutex);
+  if (mgr.get())
+    return mgr.get();
+
+  mgr = std::auto_ptr<SGCommandMgr>(new SGCommandMgr);
+  return mgr.get();
+}
+
 void
 SGCommandMgr::addCommand (const string &name, command_t command)
 {