1 // commands.cxx - encapsulated commands.
2 // Started Spring 2001 by David Megginson, david@megginson.com
3 // This code is released into the Public Domain.
7 #include <simgear/props/props_io.hxx>
9 #include "commands.hxx"
13 ////////////////////////////////////////////////////////////////////////
14 // Implementation of SGCommandMgr class.
15 ////////////////////////////////////////////////////////////////////////
18 SGCommandMgr::SGCommandMgr ()
23 SGCommandMgr::~SGCommandMgr ()
29 SGCommandMgr::addCommand (const string &name, command_t command)
31 _commands[name] = command;
34 SGCommandMgr::command_t
35 SGCommandMgr::getCommand (const string &name) const
37 const command_map::const_iterator it = _commands.find(name);
38 return (it != _commands.end() ? it->second : 0);
42 SGCommandMgr::getCommandNames () const
45 command_map::const_iterator it = _commands.begin();
46 command_map::const_iterator last = _commands.end();
48 names.push_back(it->first);
55 SGCommandMgr::execute (const string &name, const SGPropertyNode * arg) const
57 command_t command = getCommand(name);
61 return (*command)(arg);
64 // end of commands.cxx