00001
00010 #ifndef __COMMANDS_HXX
00011 #define __COMMANDS_HXX
00012
00013
00014 #include <simgear/compiler.h>
00015
00016 #include <string>
00017 #include <map>
00018 #include <vector>
00019
00020 #include <OpenThreads/Mutex>
00021
00022 #include <simgear/props/props.hxx>
00023
00024 using std::string;
00025 using std::map;
00026 using std::vector;
00027
00028
00039 class SGCommandMgr
00040 {
00041 public:
00042
00046 typedef bool (*command_t) (const SGPropertyNode * arg);
00047
00048
00052 virtual ~SGCommandMgr ();
00053
00057 static SGCommandMgr* instance();
00058
00068 virtual void addCommand (const string &name, command_t command);
00069
00070
00078 virtual command_t getCommand (const string &name) const;
00079
00080
00087 virtual vector<string> getCommandNames () const;
00088
00089
00100 virtual bool execute (const string &name, const SGPropertyNode * arg) const;
00101
00102 protected:
00106 SGCommandMgr ();
00107
00108
00109 private:
00110
00111 typedef map<string,command_t> command_map;
00112 command_map _commands;
00113
00114 static OpenThreads::Mutex _instanceMutex;
00115
00116 };
00117
00118 #endif // __COMMANDS_HXX
00119
00120