VR-Forces 5.0.1 Developer's Guide
 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 <vlutil/vlTime.h>
13 
14 class DtCgf;
15 class DtCgfDispatcher;
17 class DtVrfCreator;
18 class DtVrfSimOptions;
19 #ifdef WIN32
20 class DtFilePrinter;
21 class DtWindowsConsolePrinter;
22 #endif
25 
26 // class DtVrfApp:
27 //
28 // Instances of DtVrfApp are the main class for the VR-Forces simulation
29 // back-end application.
30 
31 class DtVrfApp
32 {
33 public:
34 
35  // constructor
36  DtVrfApp(int argc, char** argv);
37 
38  // destructor
39  virtual ~DtVrfApp();
40 
41  // Initialization. Must be called before any other member functions
42  // are called.
43  virtual bool init(DtVrfCreator* creator = 0);
44 
45  // Main execution loop. Calls our DtCgf's tick(). Calls DtSleep() for a
46  // given time interval (the main loop sleep interval). Polls the keyboard
47  // for input. If a 'q' key press is received, exits the application.
48  virtual void mainLoop();
49 
50  // Accessor for the DtCgf
51  virtual DtCgf* cgf();
52 
53 #ifdef WIN32
54  virtual void setConsoleWindow(HWND consoleWindow);
55 #endif
56 
58  static void setUserRequestedShutdown(bool);
59  static bool userRequestedShutdown();
60 
62  static DtVrfApp* app();
63 
64 protected:
65 
66  // Process mtl file. Also reads off mtl file (optionally) added to
67  // command line by -d command
68  virtual bool processMtlFile(int argc, char** argv);
69 
70  // Creates our cgf (called from init())
71  virtual DtCgf* createCgf(const DtSimulationAddress& addr);
72 
73  // Creates our simOptions (called from init())
74  virtual DtVrfSimOptions* createSimOptions();
75 
76  // This routine will read in the simulation options from the vrfSim.mtl
77  // file by default of the supplied filename
78  virtual bool readSimOptions(const DtFilename& mtlFile);
79 
80  // This routine will process the options read from the mtl file and set
81  // them in the appropriate places in the cgf. This method is called
82  // after the cgf has been initialized
83  virtual void processCgfOptions();
84 
85  // This routine will process app level options (parameter database, port,
86  // etc). This is called before processCgfOptions and before
87  // processCommandLine such that the command line options will take
88  // precedence over the .mtl options
89  virtual void processAppOptions();
90 
91  // Gets keyboard input and sends it to console command manager.
92  // Returns false if mainloop should exit.
93  // Called during mainloop.
94  virtual bool processKeyboardInput();
95 
96  // Prints out some general tracking information to console about this build (info level)
97  virtual void printGeneralInfoToConsole();
98 
99  // Ticks subcomponents. Returns false is mainloop should exit.
100  // Called during mainloop.
101  virtual bool tick();
102 
104  virtual void initializeCgfForScenarioOrTerrain();
105 
107  virtual void initializeCgfRunState();
108 
110  virtual void exec();
111 
113 #ifdef WIN32
114  bool frontEndStillActive(HANDLE processHandle);
115 #else
116  bool frontEndStillActive();
117 #endif
118 
119 protected:
122 
123 private:
124  // copy constructor - not implemented
125  DtVrfApp(const DtVrfApp& orig);
126 
127  // assignment operator - not implemented
128  DtVrfApp& operator=(const DtVrfApp& orig);
129 
130 protected:
131 
132  // Our DIS/RPR (site id, application id) simulation address that
133  // uniquely identifies our application in an exercise.
134  DtSimulationAddress mySimAddress;
135 
136  // Command line arguments are cached in our constructor so we can process
137  // them later in init().
138  int myArgc;
139  char** myArgv;
140 
141  // Driver for our CGF object that responds to network messages
143 
144  // Driver for CGF Object that handles execution of scenario batches.
146 
147  // Options that are read in from the vrfSim.mtl file
148  DtVrfSimOptions* mySimOptions;
149 
150  DtCgf* myCgf;
151 
152 #ifdef WIN32
153  HWND myConsoleWindow;
154 
155  // Writes diagnostics to vrfSim.log
156  DtFilePrinter* myFilePrinter;
157 #endif
158 
159  // Publishes all diagnostics to network in comment interactions.
161 
163 
164  static bool theUserRequestedShutdown;
165  static DtVrfApp* theApp;
166 
168 };
bool frontEndStillActive()
Check to see (if running in combined mode) that the front end is still active.
DtCgfDispatcher * myDispatcher
Definition: vrfApp.h:169
Batch mode allows you to run one or more scenarios multiple times, for a specified amount of time...
Definition: remoteBatchManager.h:30
static bool userRequestedShutdown()
virtual ~DtVrfApp()
int myArgc
Definition: vrfApp.h:165
This class handles messages from the front-end for loading and saving scenarios, and controlling the ...
Definition: cgfDispatcher.h:42
DtVrfApp & operator=(const DtVrfApp &orig)
DtSimulationAddress mySimAddress
Definition: vrfApp.h:155
DtCommunicationManager * myCommunicationManager
Definition: vrfApp.h:194
Definition: vrfApp.h:42
DtRemoteBatchManager * myBatchManager
Definition: vrfApp.h:172
virtual DtCgf * cgf()
virtual void printGeneralInfoToConsole()
static void setUserRequestedShutdown(bool)
Whether or not the user has requested a shutdown of the application.
DtBackendConsoleNetworkPrinter * myBackendConsoleNetworkPrinter
Definition: vrfApp.h:187
Console printer which sends the console data to the network using the Comment PDU/Interaction.
Definition: backendConsoleNetworkPrinter.h:21
static DtVrfApp * theApp
Definition: vrfApp.h:192
static DtVrfApp * app()
The global application.
char ** myArgv
Definition: vrfApp.h:166
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)
The DtCommunicationManager class is a convenience class that will create both the DtNetworkInterfaceM...
Definition: communicationManager.h:51
DtVrfSimOptions * mySimOptions
Definition: vrfApp.h:148
virtual bool processKeyboardInput()
DtCgf * myCgf
Definition: vrfApp.h:177
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)
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:274
virtual void processCgfOptions()
virtual DtCgf * createCgf(const DtSimulationAddress &addr)
virtual makVrf::DtVrfSimOptions * createSimOptions()
The top level class of a VR-Forces Simulation Engine, representing a Computer Generated Forces instan...
Definition: cgf.h:143
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)
static bool theUserRequestedShutdown
Definition: vrfApp.h:191
virtual bool readSimOptions(const DtFilename &mtlFile)
bool myWarnedFailedGetExitCode
Definition: vrfApp.h:189

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)