VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
snapshotManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #pragma once
6 
7 #ifdef WIN32
8 #include <winsock2.h>
9 #endif
10 
11 #include "vrfcgf/vrfcgfDefines.h"
13 #include "vrfutil/rwUUID.h"
14 #include <vrfutil/objectCounter.h>
16 #include "vrfutil/scenario.h"
17 #include "vrfmsgs/ifSaveScenario.h"
18 #include <vlpi/simulationAddress.h>
19 #include <sstream>
20 #include <vector>
21 
22 #include <boost/unordered_map.hpp>
23 
24 class DtCgf;
26 class DtSimMessage;
27 class DtVrfCallbackQueue;
29 
32 #ifdef DtObjectDebugger_Enable
33  : public DtObjectDebugger<DtInMemorySnapshot>
34 #endif
35 {
37 
38  virtual ~DtInMemorySnapshot();
39 
40  int myId;
41  double mySimTime;
43 
44  typedef std::vector<std::string*> OOB;
46  std::string myPlans;
47  std::string myScenarioExtras;
48  std::string myScenarioScripts;
49  std::string myOrbat;
52 };
53 
55 
57 {
58 private:
62  DtSnapshotManager& operator=(const DtSnapshotManager&);
63 
64 public:
66  virtual ~DtSnapshotManager();
67 
68  virtual bool init();
69 
70  virtual void tick();
71 
74  virtual void setSimTime(double);
75 
77  virtual void enablePeriodicSnapshots(bool flag);
78  virtual bool periodicSnapshotsEnabled() const;
79 
81  virtual void setSnapshotPeriod(double period);
82  virtual double snapshotPeriod() const;
83 
85  virtual void setNumberOfSnapshotsToKeep(int);
86  virtual int numberOfSnapshotsToKeep() const;
87 
90  virtual void setPauseCleanup(bool);
91  bool pauseCleanup() const { return myPauseCleanup; }
92 
93  virtual void clear(bool allButBase = false);
94 
96  virtual bool isBaseSnapshot(DtInMemorySnapshot*) const;
97 
101  virtual DtInMemorySnapshot* takeSnapshot(bool isPeriodic = false, bool makeBase = false);
102 
105  virtual void rollbackToSimTime(double simTime);
106 
108  virtual void rollbackTo(DtInMemorySnapshot*, int scenarioRunId = 0);
109 
111  virtual void clearOutStaleSnapshots();
112 
114  virtual DtInMemorySnapshot* snapshotFor(int id) const;
115 
117  virtual void setSnapshotHeartbeatTime(double d);
118  virtual double snapshotHeartbeatTime() const;
119 
121  virtual void sendCurrentSnapshots();
122 
125  virtual bool saveSnapshot(const DtFilename& saveFolder, DtCompressedFileTransporter& tr, DtIfSaveScenario* msg,
126  const DtScenario& currentScenario, const DtSimulationAddress& requestor);
127 
129  virtual DtInMemorySnapshot* snapshotClosestToSimTime(double simTime) const;
130 
132  virtual void removeSnapshotsAfter(double simTime);
133 
135  virtual bool hasSnapshots() const;
136 
138  virtual void clearAllSnapshots();
139 
141 protected:
142  static void clearAllSnapshotsCallback(DtSimMessage*, void*);
143 
144  static void settingConsumerCallback(
145  const DtSettingsObject* settingsObject, void* usr);
146  virtual void processSettings(const DtPeriodicSnapshotSettings*);
147 
148  static void requestSnapshots(DtSimMessage*, void*);
149  virtual void processSnapshotsRequest(DtSimMessage*);
150 
151  static void rollbackToSnapshot(DtSimMessage*, void*);
152  virtual void processRollbackToSnapshot(DtSimMessage*);
153 
155  virtual void finishSavingSnapshots();
156 
157 protected:
159  {
160  public:
161  DtWriteSnapshotJob(const DtSimulationAddress& addr,
163  virtual ~DtWriteSnapshotJob();
164  virtual void run();
165 
166  DtSimulationAddress myRequestor;
170  bool mySuccess;
171 
172  protected:
173  virtual bool writeAndSendOrderOfBattleFile();
174  virtual bool writeAndSendPlanFile();
175  virtual bool writeAndSendScenarioExtrasFile();
176  virtual bool writeAndSendScenarioScriptsFile();
177  virtual bool writeAndSendOrbatFile();
178  };
179 
180 protected:
189 
190  typedef std::map<int, DtInMemorySnapshot*> Snapshots;
193 
195 
197 
199 
200  typedef std::map<int, DtVrfCallbackQueue::CallbackInterface::Ptr> SavingSnapshots;
202 
204 };
DtScenario myScenarioInformation
Definition: snapshotManager.h:50
std::string myOrbat
Definition: snapshotManager.h:49
DtVrfCallbackQueue * myFileWriterJobQueue
Definition: snapshotManager.h:203
double mySnapshotHeartbeatTime
Definition: snapshotManager.h:185
std::string myPlans
Definition: snapshotManager.h:46
Structure holds a complete single-backend snapshot state in memory.
Definition: snapshotManager.h:31
Definition: scenario.h:52
int myNextSnapshotId
Definition: snapshotManager.h:188
double mySnapshotPeriod
Definition: snapshotManager.h:183
class DtIfSaveScenario:
Definition: ifSaveScenario.h:23
double myLastSnapshotHeartbeat
Definition: snapshotManager.h:184
Snapshots mySnapshots
Definition: snapshotManager.h:191
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:265
Default on in debug, off in release.
Definition: objectCounter.h:31
bool mySuccess
Definition: snapshotManager.h:170
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:32
OOB myOob
Definition: snapshotManager.h:45
Definition: settingsObject.h:27
int myNumberOfSnapshotsToKeep
Definition: snapshotManager.h:187
int myId
Definition: snapshotManager.h:40
bool mySnapshotsModified
Definition: snapshotManager.h:194
double myLastTimePeriodicSnapshoted
Definition: snapshotManager.h:186
std::vector< std::string * > OOB
Definition: snapshotManager.h:44
DtIfSnapshotsResponse myCurrentSnapshots
Definition: snapshotManager.h:196
API for writing callbacks.
Definition: vrfCallbackQueue.h:58
bool myPauseCleanup
Definition: snapshotManager.h:198
std::string myScenarioExtras
Definition: snapshotManager.h:47
DtInMemorySnapshot * mySnapshot
Definition: snapshotManager.h:168
DtCompressedFileTransporter & myTransporter
Definition: snapshotManager.h:169
class DtIfSnapshotsResponse:
Definition: ifSnapshotsResponse.h:25
std::string myScenarioScripts
Definition: snapshotManager.h:48
File: simMsg.h.
Definition: simMessage.h:35
Definition: snapshotManager.h:158
SavingSnapshots myCheckpointing
Definition: snapshotManager.h:201
Definition: compressedFileTransporter.h:24
std::map< int, DtInMemorySnapshot * > Snapshots
Definition: snapshotManager.h:190
DtCgf * myCgf
Definition: snapshotManager.h:181
std::map< int, DtVrfCallbackQueue::CallbackInterface::Ptr > SavingSnapshots
Definition: snapshotManager.h:200
double mySimTime
Definition: snapshotManager.h:41
DtInMemorySnapshot()
Definition: snapshotManager.h:36
bool pauseCleanup() const
Definition: snapshotManager.h:91
int myNumberOfLuaScripts
Definition: snapshotManager.h:51
DtIfSaveScenario mySaveMessage
Definition: snapshotManager.h:167
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtSimulationAddress myRequestor
Definition: snapshotManager.h:166
bool myIsPeriodic
Definition: snapshotManager.h:42
Definition: snapshotManager.h:56
bool myPeriodicSnapshotsEnabled
Definition: snapshotManager.h:182
virtual ~DtInMemorySnapshot()
An instance of DtCgf is an object representing a CGF (Computer Generated Forces). ...
Definition: cgf.h:115
#define DT_DLL_vrfcgf
This file is used to determine how to build.
Definition: vrfcgfDefines.h:25
Snapshots myPeriodicSnapshots
Definition: snapshotManager.h:192
Periodic snapshot settings are used to keep track of whether or not periodic snapshots are enabled an...
Definition: periodicSnapshotSettings.h:28

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)