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"
11 ////////////////////////////////////////////////////////////////////////
12 // Implementation of SGCommandMgr class.
13 ////////////////////////////////////////////////////////////////////////
16 SGCommandMgr::SGCommandMgr ()
21 SGCommandMgr::~SGCommandMgr ()
27 SGCommandMgr::addCommand (const string &name, command_t command)
29 _commands[name] = command;
32 SGCommandMgr::command_t
33 SGCommandMgr::getCommand (const string &name) const
35 const command_map::const_iterator it = _commands.find(name);
36 return (it != _commands.end() ? it->second : 0);
40 SGCommandMgr::getCommandNames () const
43 command_map::const_iterator it = _commands.begin();
44 command_map::const_iterator last = _commands.end();
46 names.push_back(it->first);
53 SGCommandMgr::execute (const string &name, const SGPropertyNode * arg) const
55 command_t command = getCommand(name);
59 return (*command)(arg);
64 SGCommandMgr::execute (const string &name) const
73 SGCommandMgr::execute (const string &name, bool value) const
77 node.setBoolValue(value);
83 SGCommandMgr::execute (const string &name, int value) const
87 node.setIntValue(value);
93 SGCommandMgr::execute (const string &name, long value) const
97 node.setLongValue(value);
103 SGCommandMgr::execute (const string &name, float value) const
107 node.setFloatValue(value);
108 execute(name, &node);
113 SGCommandMgr::execute (const string &name, double value) const
117 node.setDoubleValue(value);
118 execute(name, &node);
123 SGCommandMgr::execute (const string &name, string value) const
127 node.setStringValue(value);
128 execute(name, &node);
132 // end of commands.cxx