#include <simgear/compiler.h>
-#include STL_STRING
+#include <string>
#include <map>
#include <vector>
+#include <simgear/threads/SGThread.hxx>
+#include <simgear/math/sg_types.hxx>
#include <simgear/props/props.hxx>
-SG_USING_STD(string);
-SG_USING_STD(map);
-SG_USING_STD(vector);
-
-
/**
* Manage commands.
*
typedef bool (*command_t) (const SGPropertyNode * arg);
- /**
- * Default constructor.
- */
- SGCommandMgr ();
-
-
/**
* Destructor.
*/
virtual ~SGCommandMgr ();
+ /**
+ * Implement the classical singleton.
+ */
+ static SGCommandMgr* instance();
/**
* Register a new command with the manager.
* a bool result. The argument is always a const pointer to
* an SGPropertyNode (which may contain multiple values).
*/
- virtual void addCommand (const string &name, command_t command);
+ virtual void addCommand (const std::string &name, command_t command);
/**
* @return A pointer to the command, or 0 if there is no registered
* command with the name specified.
*/
- virtual command_t getCommand (const string &name) const;
+ virtual command_t getCommand (const std::string &name) const;
/**
* @return A (possibly empty) vector of the names of all registered
* commands.
*/
- virtual vector<string> getCommandNames () const;
+ virtual string_list getCommandNames () const;
/**
* @return true if the command is present and executes successfully,
* false otherwise.
*/
- virtual bool execute (const string &name, const SGPropertyNode * arg) const;
+ virtual bool execute (const std::string &name, const SGPropertyNode * arg) const;
+
+protected:
+ /**
+ * Default constructor.
+ */
+ SGCommandMgr ();
+
private:
- typedef map<string,command_t> command_map;
+ typedef std::map<std::string,command_t> command_map;
command_map _commands;
+ static SGMutex _instanceMutex;
+
};
#endif // __COMMANDS_HXX