]> git.mxchange.org Git - simgear.git/blob - simgear/misc/commands.cxx
- added missing return statements for execute methods
[simgear.git] / simgear / misc / commands.cxx
1 // commands.cxx - encapsulated commands.
2 // Started Spring 2001 by David Megginson, david@megginson.com
3 // This code is released into the Public Domain.
4 //
5 // $Id$
6
7 #include "commands.hxx"
8
9
10 \f
11 ////////////////////////////////////////////////////////////////////////
12 // Implementation of SGCommandMgr class.
13 ////////////////////////////////////////////////////////////////////////
14
15
16 SGCommandMgr::SGCommandMgr ()
17 {
18   // no-op
19 }
20
21 SGCommandMgr::~SGCommandMgr ()
22 {
23   // no-op
24 }
25
26 void
27 SGCommandMgr::addCommand (const string &name, command_t command)
28 {
29   _commands[name] = command;
30 }
31
32 SGCommandMgr::command_t
33 SGCommandMgr::getCommand (const string &name) const
34 {
35   const command_map::const_iterator it = _commands.find(name);
36   return (it != _commands.end() ? it->second : 0);
37 }
38
39 vector<string>
40 SGCommandMgr::getCommandNames () const
41 {
42   vector<string> names;
43   command_map::const_iterator it = _commands.begin();
44   command_map::const_iterator last = _commands.end();
45   while (it != last) {
46     names.push_back(it->first);
47     it++;
48   }
49   return names;
50 }
51
52 bool
53 SGCommandMgr::execute (const string &name, const SGPropertyNode * arg) const
54 {
55   command_t command = getCommand(name);
56   if (command == 0)
57     return false;
58   else
59     return (*command)(arg);
60 }
61
62
63 bool
64 SGCommandMgr::execute (const string &name) const
65 {
66                                 // FIXME
67   SGPropertyNode node;
68   return execute(name, &node);
69 }
70
71
72 bool
73 SGCommandMgr::execute (const string &name, bool value) const
74 {
75                                 // FIXME
76   SGPropertyNode node;
77   node.setBoolValue(value);
78   return execute(name, &node);
79 }
80
81
82 bool
83 SGCommandMgr::execute (const string &name, int value) const
84 {
85                                 // FIXME
86   SGPropertyNode node;
87   node.setIntValue(value);
88   return execute(name, &node);
89 }
90
91
92 bool
93 SGCommandMgr::execute (const string &name, long value) const
94 {
95                                 // FIXME
96   SGPropertyNode node;
97   node.setLongValue(value);
98   return execute(name, &node);
99 }
100
101
102 bool
103 SGCommandMgr::execute (const string &name, float value) const
104 {
105                                 // FIXME
106   SGPropertyNode node;
107   node.setFloatValue(value);
108   return execute(name, &node);
109 }
110
111
112 bool
113 SGCommandMgr::execute (const string &name, double value) const
114 {
115                                 // FIXME
116   SGPropertyNode node;
117   node.setDoubleValue(value);
118   return execute(name, &node);
119 }
120
121
122 bool
123 SGCommandMgr::execute (const string &name, string value) const
124 {
125                                 // FIXME
126   SGPropertyNode node;
127   node.setStringValue(value);
128   return execute(name, &node);
129 }
130
131
132 // end of commands.cxx