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 "commands.hxx"
8 #include "props_io.hxx"
12 ////////////////////////////////////////////////////////////////////////
13 // Implementation of SGCommandMgr class.
14 ////////////////////////////////////////////////////////////////////////
17 SGCommandMgr::SGCommandMgr ()
22 SGCommandMgr::~SGCommandMgr ()
28 SGCommandMgr::addCommand (const string &name, command_t command)
30 _commands[name] = command;
33 SGCommandMgr::command_t
34 SGCommandMgr::getCommand (const string &name) const
36 const command_map::const_iterator it = _commands.find(name);
37 return (it != _commands.end() ? it->second : 0);
41 SGCommandMgr::getCommandNames () const
44 command_map::const_iterator it = _commands.begin();
45 command_map::const_iterator last = _commands.end();
47 names.push_back(it->first);
54 SGCommandMgr::execute (const string &name, const SGPropertyNode * arg) const
56 command_t command = getCommand(name);
60 return (*command)(arg);
63 // end of commands.cxx