VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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;
47 };
48 
50 
52 {
53 private:
57  DtSnapshotManager& operator=(const DtSnapshotManager&);
58 
59 public:
61  virtual ~DtSnapshotManager();
62 
63  virtual bool init();
64 
65  virtual void tick();
66 
69  virtual void setSimTime(double);
70 
72  virtual void enablePeriodicSnapshots(bool flag);
73  virtual bool periodicSnapshotsEnabled() const;
74 
76  virtual void setSnapshotPeriod(double period);
77  virtual double snapshotPeriod() const;
78 
80  virtual void setNumberOfSnapshotsToKeep(int);
81  virtual int numberOfSnapshotsToKeep() const;
82 
85  virtual void setPauseCleanup(bool);
86  bool pauseCleanup() const { return myPauseCleanup; }
87 
88  virtual void clear(bool allButBase = false);
89 
93  virtual DtInMemorySnapshot* takeSnapshot(bool isPeriodic = false, bool makeBase = false);
94 
96  virtual void clearOutStaleSnapshots();
97 
99  virtual DtInMemorySnapshot* snapshotFor(int id) const;
100 
102  virtual void setSnapshotHeartbeatTime(double d);
103  virtual double snapshotHeartbeatTime() const;
104 
106  virtual void sendCurrentSnapshots();
107 
110  virtual bool saveSnapshot(const DtFilename& saveFolder, DtCompressedFileTransporter& tr, DtIfSaveScenario* msg,
111  const DtScenario& currentScenario, const DtSimulationAddress& requestor);
112 
114  virtual DtInMemorySnapshot* snapshotClosestToSimTime(double simTime) const;
115 
117  virtual void removeSnapshotsAfter(double simTime);
118 
120  virtual bool hasSnapshots() const;
121 
123  virtual void clearAllSnapshots();
124 
125 protected:
126  static void clearAllSnapshotsCallback(DtSimMessage*, void*);
127 
128  static void settingConsumerCallback(
129  const DtSettingsObject* settingsObject, void* usr);
130  virtual void processSettings(const DtPeriodicSnapshotSettings*);
131 
132  static void requestSnapshots(DtSimMessage*, void*);
133  virtual void processSnapshotsRequest(DtSimMessage*);
134 
135  static void rollbackToSnapshot(DtSimMessage*, void*);
136  virtual void processRollbackToSnapshot(DtSimMessage*);
137 
139  virtual bool rollbackTo(DtInMemorySnapshot*, int scenarioRunId = 0);
140 
142  virtual void finishSavingSnapshots();
143 
144 protected:
146  {
147  public:
148  DtWriteSnapshotJob(const DtSimulationAddress& addr,
150  virtual ~DtWriteSnapshotJob();
151  virtual void run();
152 
153  DtSimulationAddress myRequestor;
157  bool mySuccess;
158 
159  protected:
160  virtual bool writeAndSendOrderOfBattleFile();
161  virtual bool writeAndSendPlanFile();
162  virtual bool writeAndSendScenarioExtrasFile();
163  virtual bool writeAndSendScenarioScriptsFile();
164  };
165 
166 protected:
175 
176  typedef std::map<int, DtInMemorySnapshot*> Snapshots;
179 
181 
183 
185 
186  typedef std::map<int, DtVrfCallbackQueue::CallbackInterface::Ptr> SavingSnapshots;
188 
190 };

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)