TrueReality  v0.1.1912
ApplicationUsage.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
23 
29 namespace trUtil
30 {
33  {
34  mAppUsage = new osg::ApplicationUsage();
35  }
36 
38  ApplicationUsage::ApplicationUsage(osg::ApplicationUsage* applicationUsage)
39  {
40  mAppUsage = applicationUsage;
41  }
42 
44  ApplicationUsage::ApplicationUsage(const std::string& commandLineUsage)
45  {
46  mAppUsage = new osg::ApplicationUsage(commandLineUsage);
47  }
48 
51  {
52  }
53 
55  void ApplicationUsage::SetApplicationName(const std::string& name)
56  {
57  mAppUsage->setApplicationName(name);
58  }
59 
61  const std::string& ApplicationUsage::GetApplicationName() const
62  {
63  return mAppUsage->getApplicationName();
64  }
65 
67  void ApplicationUsage::SetDescription(const std::string& desc)
68  {
69  mAppUsage->setDescription(desc);
70  }
71 
73  const std::string& ApplicationUsage::GetDescription() const
74  {
75  return mAppUsage->getDescription();
76  }
77 
79  void ApplicationUsage::AddUsageExplanation(Type type, const std::string & option, const std::string & explanation)
80  {
81  mAppUsage->addUsageExplanation(static_cast<osg::ApplicationUsage::Type>(type), option, explanation);
82  }
83 
85  void ApplicationUsage::SetCommandLineUsage(const std::string& explanation)
86  {
87  mAppUsage->setCommandLineUsage(explanation);
88  }
89 
91  const std::string& ApplicationUsage::GetCommandLineUsage() const
92  {
93  return mAppUsage->getCommandLineUsage();
94  }
95 
97  void ApplicationUsage::AddCommandLineOption(const std::string& option, const std::string& explanation, const std::string& defaultValue)
98  {
99  mAppUsage->addCommandLineOption(option, explanation, defaultValue);
100  }
101 
104  {
105  mAppUsage->setCommandLineOptions(usageMap);
106  }
107 
110  {
111  return mAppUsage->getCommandLineOptions();
112  }
113 
116  {
117  mAppUsage->setCommandLineOptionsDefaults(usageMap);
118  }
119 
122  {
123  return mAppUsage->getCommandLineOptionsDefaults();
124  }
125 
127  void ApplicationUsage::AddEnvironmentalVariable(const std::string& option, const std::string& explanation, const std::string& defaultValue)
128  {
129  mAppUsage->addEnvironmentalVariable(option, explanation, defaultValue);
130  }
131 
134  {
135  mAppUsage->setEnvironmentalVariables(usageMap);
136  }
137 
140  {
141  return mAppUsage->getEnvironmentalVariables();
142  }
143 
146  {
147  mAppUsage->setEnvironmentalVariablesDefaults(usageMap);
148  }
149 
152  {
153  return mAppUsage->getEnvironmentalVariablesDefaults();
154  }
155 
157  void ApplicationUsage::AddKeyboardMouseBinding(const std::string& prefix, int key, const std::string& explanation)
158  {
159  mAppUsage->addKeyboardMouseBinding(prefix, key, explanation);
160  }
161 
163  void ApplicationUsage::AddKeyboardMouseBinding(int key, const std::string& explanation)
164  {
165  mAppUsage->addKeyboardMouseBinding(key, explanation);
166  }
167 
169  void ApplicationUsage::AddKeyboardMouseBinding(const std::string& option, const std::string& explanation)
170  {
171  mAppUsage->addKeyboardMouseBinding(option, explanation);
172  }
173 
176  {
177  mAppUsage->setKeyboardMouseBindings(usageMap);
178  }
179 
182  {
183  return mAppUsage->getKeyboardMouseBindings();
184  }
185 
187  void ApplicationUsage::GetFormattedString(std::string& str, const UsageMap& um, unsigned int widthOfOutput, bool showDefaults, const UsageMap& ud)
188  {
189  mAppUsage->getFormattedString(str, um, widthOfOutput, showDefaults, ud);
190  }
191 
193  void ApplicationUsage::Write(std::ostream& output, const UsageMap& um, unsigned int widthOfOutput, bool showDefaults, const UsageMap& ud)
194  {
195  mAppUsage->write(output, um, widthOfOutput, showDefaults, ud);
196  }
197 
199  void ApplicationUsage::Write(std::ostream& output, Type type, unsigned int widthOfOutput, bool showDefaults)
200  {
201  mAppUsage->write(output, static_cast<unsigned int>(type), widthOfOutput, showDefaults);
202  }
203 
206  {
207  mAppUsage->writeEnvironmentSettings(output);
208  }
209 
211  ApplicationUsage::operator osg::ApplicationUsage&()
212  {
213  return *mAppUsage.get();
214  }
215 
217  ApplicationUsage::operator const osg::ApplicationUsage&() const
218  {
219  return *mAppUsage.get();
220  }
221 
223  ApplicationUsage::operator osg::ApplicationUsage*()
224  {
225  return mAppUsage.get();
226  }
227 
229  ApplicationUsage::operator const osg::ApplicationUsage*() const
230  {
231  return mAppUsage.get();
232  }
233 }
void SetCommandLineUsage(const std::string &explanation)
Sets command line usage.
void SetApplicationName(const std::string &name)
Sets the Applications Name.
const UsageMap & GetKeyboardMouseBindings() const
Gets keyboard mouse bindings usage.
const UsageMap & GetEnvironmentalVariables() const
Gets environmental variables usage.
void Write(std::ostream &output, const UsageMap &um, unsigned int widthOfOutput=80, bool showDefaults=false, const UsageMap &ud=UsageMap())
Writes out all the settings to the screen.
void GetFormattedString(std::string &str, const UsageMap &um, unsigned int widthOfOutput=80, bool showDefaults=false, const UsageMap &ud=UsageMap())
Gets formatted string.
const UsageMap & GetCommandLineOptionsDefaults() const
Gets command line options defaults.
void SetEnvironmentalVariables(const UsageMap &usageMap)
Sets environmental variables usage.
const std::string & GetCommandLineUsage() const
Gets command line usage.
const UsageMap & GetCommandLineOptions() const
Gets command line options.
const UsageMap & GetEnvironmentalVariablesDefaults() const
Gets environmental variables usage default usage map.
void SetCommandLineOptionsDefaults(const UsageMap &usageMap)
Sets command line options defaults.
void AddUsageExplanation(Type type, const std::string &option, const std::string &explanation)
Adds an usage explanation.
ApplicationUsage()
Default constructor.
const std::string & GetApplicationName() const
Gets the stored application name.
const std::string & GetDescription() const
Gets the description.
std::map< std::string, std::string > UsageMap
The message to command usage map.
void SetDescription(const std::string &desc)
If non-empty, the Description is typically shown by the Help Handler as text on the Help display (whi...
void AddEnvironmentalVariable(const std::string &option, const std::string &explanation, const std::string &defaultValue="")
Adds an environmental variable usage explanation.
Namespace that holds various utility classes for the engine.
Definition: SmrtPtr.h:208
void AddKeyboardMouseBinding(const std::string &prefix, int key, const std::string &explanation)
Adds a keyboard mouse binding usage.
void SetKeyboardMouseBindings(const UsageMap &usageMap)
Sets keyboard mouse bindings usage.
void SetCommandLineOptions(const UsageMap &usageMap)
Sets command line options.
void AddCommandLineOption(const std::string &option, const std::string &explanation, const std::string &defaultValue="")
Adds a command line option.
osg::ref_ptr< osg::ApplicationUsage > mAppUsage
void SetEnvironmentalVariablesDefaults(const UsageMap &usageMap)
Sets environmental variables usage default usage map.
void WriteEnvironmentSettings(std::ostream &output)
Writes out the environment settings.