VR-Forces Development_Version 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"
15 #include "vrfutil/scenario.h"
16 #include "vrfmsgs/ifSaveScenario.h"
17 #include <vlpi/simulationAddress.h>
18 #include <sstream>
19 #include <vector>
20 
21 #include <boost/unordered_map.hpp>
22 
23 class DtCgf;
25 class DtSimMessage;
26 class DtVrfCallbackQueue;
28 
31 {
33 
34  virtual ~DtInMemorySnapshot();
35 
36  int myId;
37  double mySimTime;
39 
40  typedef std::vector<std::string*> OOB;
42  std::string myPlans;
43  std::string myScenarioExtras;
44  std::string myScenarioScripts;
46 };
47 
49 {
50 private:
54  DtSnapshotManager& operator=(const DtSnapshotManager&);
55 
56 public:
58  virtual ~DtSnapshotManager();
59 
60  virtual bool init();
61 
62  virtual void tick();
63 
66  virtual void setSimTime(double);
67 
69  virtual void enablePeriodicSnapshots(bool flag);
70  virtual bool periodicSnapshotsEnabled() const;
71 
73  virtual void setSnapshotPeriod(double period);
74  virtual double snapshotPeriod() const;
75 
77  virtual void setNumberOfSnapshotsToKeep(int);
78  virtual int numberOfSnapshotsToKeep() const;
79 
82  virtual void setPauseCleanup(bool);
83  bool pauseCleanup() const { return myPauseCleanup; }
84 
85  virtual void clear(bool allButBase = false);
86 
90  virtual DtInMemorySnapshot* takeSnapshot(bool isPeriodic = false, bool makeBase = false);
91 
93  virtual void clearOutStaleSnapshots();
94 
96  virtual DtInMemorySnapshot* snapshotFor(int id) const;
97 
99  virtual void setSnapshotHeartbeatTime(double d);
100  virtual double snapshotHeartbeatTime() const;
101 
103  virtual void sendCurrentSnapshots();
104 
107  virtual bool saveSnapshot(const DtFilename& saveFolder, DtCompressedFileTransporter& tr, DtIfSaveScenario* msg,
108  const DtScenario& currentScenario, const DtSimulationAddress& requestor);
109 
111  virtual DtInMemorySnapshot* snapshotClosestToSimTime(double simTime) const;
112 
114  virtual void removeSnapshotsAfter(double simTime);
115 
117  virtual bool hasSnapshots() const;
118 
120  virtual void clearAllSnapshots();
121 
122 protected:
123  static void clearAllSnapshotsCallback(DtSimMessage*, void*);
124 
125  static void settingConsumerCallback(
126  const DtSettingsObject* settingsObject, void* usr);
127  virtual void processSettings(const DtPeriodicSnapshotSettings*);
128 
129  static void requestSnapshots(DtSimMessage*, void*);
130  virtual void processSnapshotsRequest(DtSimMessage*);
131 
132  static void rollbackToSnapshot(DtSimMessage*, void*);
133  virtual void processRollbackToSnapshot(DtSimMessage*);
134 
136  virtual bool rollbackTo(DtInMemorySnapshot*);
137 
139  virtual void finishSavingSnapshots();
140 
141 protected:
143  {
144  public:
145  DtWriteSnapshotJob(const DtSimulationAddress& addr,
147  virtual ~DtWriteSnapshotJob();
148  virtual void run();
149 
150  DtSimulationAddress myRequestor;
154  bool mySuccess;
155 
156  protected:
157  virtual bool writeAndSendOrderOfBattleFile();
158  virtual bool writeAndSendPlanFile();
159  virtual bool writeAndSendScenarioExtrasFile();
160  virtual bool writeAndSendScenarioScriptsFile();
161  };
162 
163 protected:
172 
173  typedef std::map<int, DtInMemorySnapshot*> Snapshots;
176 
178 
180 
182 
183  typedef std::map<int, DtVrfCallbackQueue::CallbackInterface::Ptr> SavingSnapshots;
185 
187 };

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)