VR-Forces 4.6.1 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) 2016 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 
31 struct DtInMemorySnapshot : public DtObjectDebugger<DtInMemorySnapshot>
32 {
34 
35  virtual ~DtInMemorySnapshot();
36 
37  int myId;
38  double mySimTime;
40 
41  typedef std::vector<std::string*> OOB;
43  std::string myPlans;
44  std::string myScenarioExtras;
45  std::string myScenarioScripts;
46  std::string myOrbat;
49 };
50 
52 
54 {
55 private:
59  DtSnapshotManager& operator=(const DtSnapshotManager&);
60 
61 public:
63  virtual ~DtSnapshotManager();
64 
65  virtual bool init();
66 
67  virtual void tick();
68 
71  virtual void setSimTime(double);
72 
74  virtual void enablePeriodicSnapshots(bool flag);
75  virtual bool periodicSnapshotsEnabled() const;
76 
78  virtual void setSnapshotPeriod(double period);
79  virtual double snapshotPeriod() const;
80 
82  virtual void setNumberOfSnapshotsToKeep(int);
83  virtual int numberOfSnapshotsToKeep() const;
84 
87  virtual void setPauseCleanup(bool);
88  bool pauseCleanup() const { return myPauseCleanup; }
89 
90  virtual void clear(bool allButBase = false);
91 
93  virtual bool isBaseSnapshot(DtInMemorySnapshot*) const;
94 
98  virtual DtInMemorySnapshot* takeSnapshot(bool isPeriodic = false, bool makeBase = false);
99 
102  virtual void rollbackToSimTime(double simTime);
103 
105  virtual void rollbackTo(DtInMemorySnapshot*, int scenarioRunId = 0);
106 
108  virtual void clearOutStaleSnapshots();
109 
111  virtual DtInMemorySnapshot* snapshotFor(int id) const;
112 
114  virtual void setSnapshotHeartbeatTime(double d);
115  virtual double snapshotHeartbeatTime() const;
116 
118  virtual void sendCurrentSnapshots();
119 
122  virtual bool saveSnapshot(const DtFilename& saveFolder, DtCompressedFileTransporter& tr, DtIfSaveScenario* msg,
123  const DtScenario& currentScenario, const DtSimulationAddress& requestor);
124 
126  virtual DtInMemorySnapshot* snapshotClosestToSimTime(double simTime) const;
127 
129  virtual void removeSnapshotsAfter(double simTime);
130 
132  virtual bool hasSnapshots() const;
133 
135  virtual void clearAllSnapshots();
136 
137 protected:
138  static void clearAllSnapshotsCallback(DtSimMessage*, void*);
139 
140  static void settingConsumerCallback(
141  const DtSettingsObject* settingsObject, void* usr);
142  virtual void processSettings(const DtPeriodicSnapshotSettings*);
143 
144  static void requestSnapshots(DtSimMessage*, void*);
145  virtual void processSnapshotsRequest(DtSimMessage*);
146 
147  static void rollbackToSnapshot(DtSimMessage*, void*);
148  virtual void processRollbackToSnapshot(DtSimMessage*);
149 
151  virtual void finishSavingSnapshots();
152 
153 protected:
155  {
156  public:
157  DtWriteSnapshotJob(const DtSimulationAddress& addr,
159  virtual ~DtWriteSnapshotJob();
160  virtual void run();
161 
162  DtSimulationAddress myRequestor;
166  bool mySuccess;
167 
168  protected:
169  virtual bool writeAndSendOrderOfBattleFile();
170  virtual bool writeAndSendPlanFile();
171  virtual bool writeAndSendScenarioExtrasFile();
172  virtual bool writeAndSendScenarioScriptsFile();
173  virtual bool writeAndSendOrbatFile();
174  };
175 
176 protected:
185 
186  typedef std::map<int, DtInMemorySnapshot*> Snapshots;
189 
191 
193 
195 
196  typedef std::map<int, DtVrfCallbackQueue::CallbackInterface::Ptr> SavingSnapshots;
198 
200 };

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)