VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vrfApp.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2018 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #pragma once
6 
7 #include <vlutil/vlString.h>
8 #include <vlutil/vlList.h>
9 #include <vlutil/vlUtil.h>
10 #include <vl/hostStructs.h>
11 #include <vlutil/vlFilename.h>
12 #include <vl/rprFomMapper.h>
13 #include <vlutil/vlTime.h>
14 #include <vl/exerciseConn.h>
15 
16 class DtCgf;
17 class DtCgfDispatcher;
18 class DtExerciseConn;
19 class DtFomMapper;
20 class DtBatchManager;
21 class DtVrfCreator;
22 class DtVrfSimOptions;
23 #ifdef WIN32
24 class DtFilePrinter;
25 class DtWindowsConsolePrinter;
26 #endif
28 
29 // class DtVrfApp:
30 //
31 // Instances of DtVrfApp are the main class for the VR-Forces simulation
32 // back-end application.
33 
34 class DtVrfApp
35 {
36 public:
37 
38  // constructor
39  DtVrfApp(int argc, char** argv);
40 
41  // destructor
42  virtual ~DtVrfApp();
43 
44  // Initialization. Must be called before any other member functions
45  // are called.
46  virtual bool init(DtVrfCreator* creator = 0);
47 
48  // Main execution loop. Calls our DtCgf's tick(). Calls DtSleep() for a
49  // given time interval (the main loop sleep interval). Polls the keyboard
50  // for input. If a 'q' key press is received, exits the application.
51  virtual void mainLoop();
52 
53  // Accessor for the DtCgf
54  virtual DtCgf* cgf();
55 
56  // Accessor for the DtExerciseConn
57  virtual DtExerciseConn* exerciseConn();
58 
59 #ifdef WIN32
60  virtual void setConsoleWindow(HWND consoleWindow);
61 #endif
62 
64  static void setUserRequestedShutdown(bool);
65  static bool userRequestedShutdown();
66 
68  static DtVrfApp* app();
69 
70 protected:
71 
72  // Process mtl file. Also reads off mtl file (optionally) added to
73  // command line by -d command
74  virtual bool processMtlFile(int argc, char** argv);
75 
76  // Creates our cgf (called from init())
77  virtual DtCgf* createCgf(const DtSimulationAddress& addr);
78 
79  // Creates our simOptions (called from init())
81 
82  // This routine will read in the simulation options from the vrfSim.mtl
83  // file by default of the supplied filename
84  virtual bool readSimOptions(const DtFilename& mtlFile);
85 
86  // This routine will process the options read from the mtl file and set
87  // them in the appropriate places in the cgf. This method is called
88  // after the cgf has been initialized
89  virtual void processCgfOptions();
90 
91  // This routine will process app level options (parameter database, port,
92  // etc). This is called before processCgfOptions and before
93  // processCommandLine such that the command line options will take
94  // precedence over the .mtl options
95  virtual void processAppOptions();
96 
97  // Gets keyboard input and sends it to console command manager.
98  // Returns false if mainloop should exit.
99  // Called during mainloop.
100  virtual bool processKeyboardInput();
101 
102  // Prints out some general tracking information to console about this build (info level)
103  virtual void printGeneralInfoToConsole();
104 
105  // Ticks subcomponents. Returns false is mainloop should exit.
106  // Called during mainloop.
107  virtual bool tick();
108 
110  virtual void initializeCgfForScenarioOrTerrain();
111 
113  virtual void initializeCgfRunState();
114 
116  virtual void exec();
117 
119 #ifdef WIN32
120  bool frontEndStillActive(HANDLE processHandle);
121 #else
122  bool frontEndStillActive();
123 #endif
124 
126  virtual bool createExerciseConnection();
127 
128 protected:
131 
132 private:
133  // copy constructor - not implemented
134  DtVrfApp(const DtVrfApp& orig);
135 
136  // assignment operator - not implemented
137  DtVrfApp& operator=(const DtVrfApp& orig);
138 
139 protected:
140 
141  // Our DIS/RPR (site id, application id) simulation address that
142  // uniquely identifies our application in an exercise.
143  DtSimulationAddress mySimAddress;
144 
145  // VR-Link exercise connection. Provides means by which all network
146  // interactions (PDUs/HLA objects and interactions) are sent/recieved.
147  DtExerciseConn* myExerciseConn;
148 
149  // Command line arguments are cached in our constructor so we can process
150  // them later in init().
151  int myArgc;
152  char** myArgv;
153 
154  // Driver for our CGF object that responds to network messages
156 
157  // Driver for CGF Object that handles execution of scenario batches.
159 
160  // Options that are read in from the vrfSim.mtl file
162 
164 
165 #ifdef WIN32
166  HWND myConsoleWindow;
167 
168  // Writes diagnostics to vrfSim.log
169  DtFilePrinter* myFilePrinter;
170 #endif
171 
172  // Publishes all diagnostics to network in comment interactions.
174 
176 
178  static DtVrfApp* theApp;
179 };
static DtVrfApp * theApp
Definition: vrfApp.h:178
bool frontEndStillActive()
Check to see (if running in combined mode) that the front end is still active.
static bool userRequestedShutdown()
virtual ~DtVrfApp()
int myArgc
Definition: vrfApp.h:151
Definition: vrfSimOptions.h:25
This class handles messages from the front-end for loading and saving scenarios, and controlling the ...
Definition: cgfDispatcher.h:38
virtual DtVrfSimOptions * createSimOptions()
DtVrfApp & operator=(const DtVrfApp &orig)
DtSimulationAddress mySimAddress
Definition: vrfApp.h:143
class DtBatchManager
Definition: batchManager.h:32
Definition: vrfApp.h:34
DtBatchManager * myBatchManager
Definition: vrfApp.h:158
virtual DtCgf * cgf()
virtual void printGeneralInfoToConsole()
static void setUserRequestedShutdown(bool)
Whether or not the user has requested a shutdown of the application.
virtual bool createExerciseConnection()
Creates the exercise connection from the given sim options.
Console printer which sends the console data to the network using the Comment PDU/Interaction.
Definition: backendConsoleNetworkPrinter.h:21
static DtVrfApp * app()
The global application.
char ** myArgv
Definition: vrfApp.h:152
virtual void initializePluginsForCommandLineArguments(DtVrfCreator *creator)
Preload plugins that want to be loaded and call special method to add command line arguments to the c...
virtual bool init(DtVrfCreator *creator=0)
virtual DtExerciseConn * exerciseConn()
DtVrfSimOptions * mySimOptions
Definition: vrfApp.h:161
virtual bool processKeyboardInput()
DtBackendConsoleNetworkPrinter * myBackendConsoleNetworkPrinter
Definition: vrfApp.h:173
virtual void exec()
Enters into main loop and ticks the applicaiton and cgf, as well as check console or other input for ...
DtVrfApp(int argc, char **argv)
DtExerciseConn * myExerciseConn
Definition: vrfApp.h:147
virtual bool tick()
virtual void initializeCgfRunState()
Given command line options, pause or run the Cgf.
Instances of DtVrfCreator are responsible for creating all of the objects needed to create and manage...
Definition: vrfCreator.h:256
virtual void processCgfOptions()
DtCgf * myCgf
Definition: vrfApp.h:163
virtual DtCgf * createCgf(const DtSimulationAddress &addr)
An instance of DtCgf is an object representing a CGF (Computer Generated Forces). ...
Definition: cgf.h:115
virtual void initializeCgfForScenarioOrTerrain()
Give command line options, initialize the Cgf for either a batch scenario, scenario or a new terrain ...
virtual void processAppOptions()
virtual void mainLoop()
virtual bool processMtlFile(int argc, char **argv)
DtCgfDispatcher * myDispatcher
Definition: vrfApp.h:155
static bool theUserRequestedShutdown
Definition: vrfApp.h:177
virtual bool readSimOptions(const DtFilename &mtlFile)
bool myWarnedFailedGetExitCode
Definition: vrfApp.h:175

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)