X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2Fcommands.hxx;h=09f1c1bcf132799814e12a2d27be2aa47c9fbe72;hb=c82df0590dd46347e2f1d0dca4cc3712f67f3654;hp=4ab28a09960a7c320bdb90f4b31efcc3f9bd7c75;hpb=d22640ef4e938b523bdc30cd83370977d30de856;p=simgear.git diff --git a/simgear/structure/commands.hxx b/simgear/structure/commands.hxx index 4ab28a09..09f1c1bc 100644 --- a/simgear/structure/commands.hxx +++ b/simgear/structure/commands.hxx @@ -13,17 +13,14 @@ #include -#include STL_STRING +#include #include #include +#include +#include #include -SG_USING_STD(string); -SG_USING_STD(map); -SG_USING_STD(vector); - - /** * Manage commands. * @@ -44,17 +41,15 @@ public: 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. @@ -65,7 +60,7 @@ public: * 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); /** @@ -75,7 +70,7 @@ public: * @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; /** @@ -84,7 +79,7 @@ public: * @return A (possibly empty) vector of the names of all registered * commands. */ - virtual vector getCommandNames () const; + virtual string_list getCommandNames () const; /** @@ -97,13 +92,22 @@ public: * @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 command_map; + typedef std::map command_map; command_map _commands; + static SGMutex _instanceMutex; + }; #endif // __COMMANDS_HXX