VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmdHelpVisitor.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * file: HelpVisitor.h
5  *
6  * Copyright (c) 2003, Michael E. Smoot .
7  * All rights reverved.
8  *
9  * See the file COPYING in the top directory of this distribution for
10  * more information.
11  *
12  * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18  * DEALINGS IN THE SOFTWARE.
19  *
20  *****************************************************************************/
21 
22 #ifndef DtCmdLine_HELP_VISITOR_H
23 #define DtCmdLine_HELP_VISITOR_H
24 
28 
29 #include "cmdLineInterface.h"
30 #include "cmdLineOutput.h"
31 #include "cmdVisitor.h"
32 
33 #include <vlutil/vlPrint.h>
35 #include <vlutil/vlKeyboard.h>
36 
37 #ifdef DtUSE_UTILITIES_NAMESPACE
38 namespace DtUSE_UTILITIES_NAMESPACE
39 {
40 #endif
41 
42 namespace DtCmdLine {
43 
48  class HelpVisitor: public Visitor
50  {
51  protected:
52 
57 
62 
64 
65  public:
66 
73 #ifdef _WIN32
74  bool pressAnyKey = true)
75 #else
76  bool pressAnyKey = false)
77 #endif
78  : Visitor(), _cmd( cmd ), _out( out ), myPressAnyKey(pressAnyKey) { }
79 
80  virtual ~HelpVisitor() { }
85  void visit();
86 
87 
88 
89  };
90 
91  inline void HelpVisitor::visit()
92  {
93  (*_out)->usage(*_cmd);
94 
95  int oldNotifyLevel = DtNotifyLevel;
96  DtNotifyLevel = 3;
97 
98 
99  if (myPressAnyKey)
100  {
101  DtInfo << "Press any key to continue" << std::endl;
102 
103  while (DtPollBlockingInputChar() == '\0')
104  {
105  DtSleep(0.1);
106  }
107  }
108 
109  DtNotifyLevel = oldNotifyLevel;
110 
111  exit(0);
112  }
113 
114 }
115 
116 #ifdef DtUSE_UTILITIES_NAMESPACE
117 }
118 #endif
119 
120 #endif
A base class that defines the interface for visitors.
Definition: cmdVisitor.h:41
This file declares the class DtCmdLine::CmdLineOutput.
CmdLineInterface * _cmd
The CmdLine the output will be generated for.
Definition: cmdHelpVisitor.h:56
char DtPollBlockingInputChar(void)
Polls standard input for a single character.
This file declares the class DtCmdLine::CmdLineInterface.
Functions in vlPrint.h provide an error and print facility for vrlink.
HelpVisitor(CmdLineInterface *cmd, CmdLineOutput **out, bool pressAnyKey=false)
Constructor.
Definition: cmdHelpVisitor.h:72
virtual ~HelpVisitor()
Definition: cmdHelpVisitor.h:80
void DtSleep(DtTime sleep_period)
Puts the process to sleep for the specified number of seconds.
int DtNotifyLevel
DtNotifyLevel is used to control the level of diagnostics output by VR-Link.
bool myPressAnyKey
Definition: cmdHelpVisitor.h:63
This file declares the class DtCmdLine::Visitor.
DtOutputStream DtInfo
DtInfo is an global instance of a DtOutputStream.
The base class that manages the command line definition and passes along the parsing to the appropria...
Definition: cmdLineInterface.h:52
CmdLineOutput ** _out
The output object.
Definition: cmdHelpVisitor.h:61
This file contains declarations of classes and functions which aid in keyboard input.
ProcControl.h provides operating system independent methods to control processes. ...
The interface that any output object must implement.
Definition: cmdLineOutput.h:51

Document ID: Generated on Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)