-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathApplicationManager.h
97 lines (73 loc) · 2.47 KB
/
ApplicationManager.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pragma once
#include "Utilities\Defs.h"
#include "GUI\Input.h"
#include "GUI\Output.h"
#include "Components\Component.h"
#include "Components\Gate.h"
#include "Components\Connection.h"
#include "Components\Switch.h"
#include "Components\LED.h"
#include "Actions\Action.h"
#include <vector>
#include <stack>
/*
Main class that manages everything in the application
*/
class ApplicationManager
{
private:
int mCompCount; // Actual number of components
Component** mCompList; // List of all components
Component* mCopiedComp; // Pointer to the last copied/cut component
stack<Action*> mUndoStack; // Stack holding the done actions
stack<Action*> mRedoStack; // Stack holding the un-done actions
Input* pIn; // Pointer to the Input class
Output* pOut; // Pointer to the Output class
public:
/* Constructor */
ApplicationManager();
/* Sets the last copied/cut component */
void SetCopiedComp(Component* pComp);
/* Returns the last copied/cut component */
Component* GetCopiedComp() const;
/* Returns a pointer to Input object */
Input* GetInput();
/* Returns a pointer to Output object */
Output* GetOutput();
/* Reads the required action from the user and returns the corresponding action type */
ActionType GetUserAction();
/* Creates an action and executes it */
void ExecuteAction(ActionType& actType);
/* Redraws all the drawing window */
void UpdateInterface();
/* Adds a new component to the list of components */
void AddComponent(Component* pComp);
/* Returns the number of the existing components */
int GetExistingComponentsCount() const;
/* Counts and returns the number of selected components */
int CountSelectedComponents() const;
/* Sets a selection value to all components */
void SetSelectionOfComponents(bool s);
/* Returns a vector of all selected components */
vector<Component*> GetSelectedComponents();
/* Returns a vector of all selected gates */
vector<Gate*> GetSelectedGates();
/* Returns a vector of all connections */
vector<Connection*> GetConnections();
/* Returns a vector of all switches */
vector<Switch*> GetSwitches();
/* Returns a vector of all leds */
vector<LED*> GetLeds();
/* Undoes the last action */
void Undo();
/* Redoes the last action */
void Redo();
/* Saves the current circuit */
void Save(ofstream& file);
/* Loads the circuit from the file */
void Load(ifstream& file);
/* Releases all the memory used by the components */
void ReleaseMemory();
/* Destructor */
~ApplicationManager();
};