-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavegrid.cpp
More file actions
51 lines (37 loc) · 1.17 KB
/
Copy pathSavegrid.cpp
File metadata and controls
51 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Savegrid.h"
SaveGridAction::SaveGridAction(ApplicationManager* pApp) : Action(pApp)
{
}
void SaveGridAction::ReadActionParameters()
{
sgrid = pManager->GetGrid();
Output* pOut = sgrid->GetOutput();
Input* pIn = sgrid->GetInput();
pOut->PrintMessage("enter file name: ");
filename= pIn->GetSrting(pOut)+".txt"; //get file name from user
pOut->ClearStatusBar();
}
void SaveGridAction::Execute()
{
ReadActionParameters();
ofstream saveout(filename,ios::out);
if (!saveout) //check if the file was opened successfully
{
sgrid->PrintErrorMessage("error : file could't be opened ! click to continue..");
return;
}
//////////////////// Recall in the required order ///////////
sgrid->SaveAll(saveout,flag);
sgrid->SaveAll(saveout, waterpits);
sgrid->SaveAll(saveout, dangerzones);
sgrid->SaveAll(saveout, belts);
sgrid->SaveAll(saveout, workshops);
sgrid->SaveAll(saveout, antennas);
sgrid->SaveAll(saveout, rotatinggears);
saveout << "The End";
saveout.close(); //close the file that was opened
sgrid->GetOutput()->PrintMessage("you have saved the grid");
}
SaveGridAction::~SaveGridAction()
{
}