VR-Forces Developer's Guide
 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 {
36  DtInMemorySnapshot() : myId(0), mySimTime(0), myIsPeriodic(false) {};
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;
51 };
52 
53 using DtInMemorySnapshotPtr = std::shared_ptr<DtInMemorySnapshot>;
54 
56 
58 {
59 private:
63  DtSnapshotManager& operator=(const DtSnapshotManager&);
64 
65 public:
67  virtual ~DtSnapshotManager();
68 
69  virtual bool init();
70 
71  virtual void tick();
72 
75  virtual void setSimTime(double);
76 
78  virtual void enablePeriodicSnapshots(bool flag);
79  virtual bool periodicSnapshotsEnabled() const;
80 
82  virtual void setSnapshotPeriod(double period);
83  virtual double snapshotPeriod() const;
84 
86  virtual void setNumberOfSnapshotsToKeep(int);
87  virtual int numberOfSnapshotsToKeep() const;
88 
91  virtual void setPauseCleanup(bool);
92  bool pauseCleanup() const { return myPauseCleanup; }
93 
94  virtual void clear(bool allButBase = false);
95 
97  virtual bool isBaseSnapshot(DtInMemorySnapshotPtr) const;
98 
102  virtual DtInMemorySnapshotPtr takeSnapshot(bool isPeriodic = false, bool makeBase = false);
103 
106  virtual void rollbackToSimTime(double simTime);
107 
109  virtual void rollbackTo(DtInMemorySnapshotPtr, int scenarioRunId = 0);
110 
112  virtual void clearOutStaleSnapshots();
113 
115  virtual DtInMemorySnapshotPtr snapshotFor(int id) const;
116 
118  virtual void setSnapshotHeartbeatTime(double d);
119  virtual double snapshotHeartbeatTime() const;
120 
122  virtual void sendCurrentSnapshots();
123 
126  virtual bool saveSnapshot(const DtFilename& saveFolder, DtCompressedFileTransporter& tr, DtIfSaveScenario* msg,
127  const DtScenario& currentScenario, const DtSimulationAddress& requestor);
128 
130  virtual DtInMemorySnapshotPtr snapshotClosestToSimTime(double simTime) const;
131 
133  virtual void removeSnapshotsAfter(double simTime);
134 
136  virtual bool hasSnapshots() const;
137 
139  virtual void clearAllSnapshots();
140 
142 protected:
143  static void clearAllSnapshotsCallback(DtSimMessage*, void*);
144 
145  static void settingConsumerCallback(
146  const DtSettingsObject* settingsObject, void* usr);
147  virtual void processSettings(const DtPeriodicSnapshotSettings*);
148 
149  static void requestSnapshots(DtSimMessage*, void*);
150  virtual void processSnapshotsRequest(DtSimMessage*);
151 
152  static void rollbackToSnapshot(DtSimMessage*, void*);
153  virtual void processRollbackToSnapshot(DtSimMessage*);
154 
156  virtual void finishSavingSnapshots();
157 
158 protected:
160  {
161  public:
162  DtWriteSnapshotJob(const DtSimulationAddress& addr,
164  virtual ~DtWriteSnapshotJob() override;
165  virtual void run() override;
166 
167  DtSimulationAddress myRequestor;
171  bool mySuccess;
172 
173  protected:
174  virtual bool writeAndSendOrderOfBattleFile();
175  virtual bool writeAndSendPlanFile();
176  virtual bool writeAndSendScenarioExtrasFile();
177  virtual bool writeAndSendScenarioScriptsFile();
178  virtual bool writeAndSendOrbatFile();
179  };
180 
181 protected:
190 
191  typedef std::map<int, DtInMemorySnapshotPtr> Snapshots;
194 
196 
198 
200 
201  typedef std::map<int, DtVrfCallbackQueue::CallbackInterface::Ptr> SavingSnapshots;
203 
205 };
std::map< int, DtInMemorySnapshotPtr > Snapshots
Definition: snapshotManager.h:191
DtScenario myScenarioInformation
Definition: snapshotManager.h:50
std::string myOrbat
Definition: snapshotManager.h:49
DtVrfCallbackQueue * myFileWriterJobQueue
Definition: snapshotManager.h:204
double mySnapshotHeartbeatTime
Definition: snapshotManager.h:186
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:189
double mySnapshotPeriod
Definition: snapshotManager.h:184
class DtIfSaveScenario:
Definition: ifSaveScenario.h:23
double myLastSnapshotHeartbeat
Definition: snapshotManager.h:185
Snapshots mySnapshots
Definition: snapshotManager.h:192
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:31
Default on in debug, off in release.
Definition: objectCounter.h:27
bool mySuccess
Definition: snapshotManager.h:171
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:29
Contains the DtUUID class declaration.
OOB myOob
Definition: snapshotManager.h:45
Definition: settingsObject.h:27
int myNumberOfSnapshotsToKeep
Definition: snapshotManager.h:188
int myId
Definition: snapshotManager.h:40
bool mySnapshotsModified
Definition: snapshotManager.h:195
double myLastTimePeriodicSnapshoted
Definition: snapshotManager.h:187
std::vector< std::string * > OOB
Definition: snapshotManager.h:44
DtIfSnapshotsResponse myCurrentSnapshots
Definition: snapshotManager.h:197
API for writing callbacks.
Definition: vrfCallbackQueue.h:55
bool myPauseCleanup
Definition: snapshotManager.h:199
std::string myScenarioExtras
Definition: snapshotManager.h:47
std::shared_ptr< DtInMemorySnapshot > DtInMemorySnapshotPtr
Definition: snapshotManager.h:53
DtCompressedFileTransporter & myTransporter
Definition: snapshotManager.h:170
class DtIfSnapshotsResponse:
Definition: ifSnapshotsResponse.h:25
std::string myScenarioScripts
Definition: snapshotManager.h:48
File: simMsg.h.
Definition: simMessage.h:35
Definition: snapshotManager.h:159
SavingSnapshots myCheckpointing
Definition: snapshotManager.h:202
Definition: compressedFileTransporter.h:24
DtCgf * myCgf
Definition: snapshotManager.h:182
std::map< int, DtVrfCallbackQueue::CallbackInterface::Ptr > SavingSnapshots
Definition: snapshotManager.h:201
double mySimTime
Definition: snapshotManager.h:41
DtInMemorySnapshot()
Definition: snapshotManager.h:36
bool pauseCleanup() const
Definition: snapshotManager.h:92
DtIfSaveScenario mySaveMessage
Definition: snapshotManager.h:168
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtSimulationAddress myRequestor
Definition: snapshotManager.h:167
bool myIsPeriodic
Definition: snapshotManager.h:42
DtInMemorySnapshotPtr mySnapshot
Definition: snapshotManager.h:169
Definition: snapshotManager.h:57
bool myPeriodicSnapshotsEnabled
Definition: snapshotManager.h:183
The top level class of a VR-Forces Simulation Engine, representing a Computer Generated Forces instan...
Definition: cgf.h:156
#define DT_DLL_vrfcgf
This file is used to determine how to build.
Definition: vrfcgfDefines.h:25
Snapshots myPeriodicSnapshots
Definition: snapshotManager.h:193
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 Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)