-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathSnapshots.h
156 lines (121 loc) · 4.96 KB
/
Snapshots.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <vector>
#include <memory>
#include "CalcManager/CalculatorManager.h"
namespace CalculatorApp::ViewModel::Snapshot
{
public
interface struct ICalcManagerIExprCommand
{
};
public
ref struct UnaryCommand sealed : public ICalcManagerIExprCommand
{
property Windows::Foundation::Collections::IVectorView<int> ^ Commands {
Windows::Foundation::Collections::IVectorView<int> ^ get();
void set(Windows::Foundation::Collections::IVectorView<int> ^ commands);
};
UnaryCommand();
internal :;
explicit UnaryCommand(std::vector<int> cmds);
std::vector<int> m_cmds;
};
public
ref struct BinaryCommand sealed : public ICalcManagerIExprCommand
{
property int Command;
BinaryCommand();
internal :;
explicit BinaryCommand(int cmd);
};
public
ref struct OperandCommand sealed : public ICalcManagerIExprCommand
{
property bool IsNegative;
property bool IsDecimalPresent;
property bool IsSciFmt;
property Windows::Foundation::Collections::IVectorView<int> ^ Commands {
Windows::Foundation::Collections::IVectorView<int> ^ get();
void set(Windows::Foundation::Collections::IVectorView<int> ^ commands);
};
OperandCommand();
internal :;
explicit OperandCommand(bool isNegative, bool isDecimal, bool isSciFmt, std::vector<int> cmds);
std::vector<int> m_cmds;
};
public
ref struct Parentheses sealed : public ICalcManagerIExprCommand
{
property int Command;
Parentheses();
internal :;
explicit Parentheses(int cmd);
};
public
ref struct CalcManagerToken sealed
{
property Platform::String ^ OpCodeName; // mandatory
property int CommandIndex;
CalcManagerToken();
internal :;
explicit CalcManagerToken(Platform::String ^ opCodeName, int cmdIndex);
};
public
ref struct CalcManagerHistoryItem sealed
{
property Windows::Foundation::Collections::IVector<CalcManagerToken ^> ^ Tokens; // mandatory
property Windows::Foundation::Collections::IVector<ICalcManagerIExprCommand ^> ^ Commands; // mandatory
property Platform::String ^ Expression; // mandatory
property Platform::String ^ Result; // mandatory
CalcManagerHistoryItem();
internal :;
explicit CalcManagerHistoryItem(const CalculationManager::HISTORYITEM& item);
};
public
ref struct CalcManagerSnapshot sealed
{
property Windows::Foundation::Collections::IVector<CalcManagerHistoryItem ^> ^ HistoryItems; // optional
CalcManagerSnapshot();
internal :;
explicit CalcManagerSnapshot(const CalculationManager::CalculatorManager& calcMgr);
};
public
ref struct PrimaryDisplaySnapshot sealed
{
property Platform::String ^ DisplayValue; // mandatory
property bool IsError;
PrimaryDisplaySnapshot();
internal :;
explicit PrimaryDisplaySnapshot(Platform::String ^ display, bool isError);
};
public
ref struct ExpressionDisplaySnapshot sealed
{
property Windows::Foundation::Collections::IVector<CalcManagerToken ^> ^ Tokens;
property Windows::Foundation::Collections::IVector<ICalcManagerIExprCommand ^> ^ Commands;
ExpressionDisplaySnapshot();
internal :;
using CalcHistoryToken = std::pair<std::wstring, int>;
explicit ExpressionDisplaySnapshot(const std::vector<CalcHistoryToken>& tokens, const std::vector<std::shared_ptr<IExpressionCommand>>& commands);
};
public
ref struct StandardCalculatorSnapshot sealed
{
property CalcManagerSnapshot ^ CalcManager; // mandatory
property PrimaryDisplaySnapshot ^ PrimaryDisplay; // mandatory
property ExpressionDisplaySnapshot ^ ExpressionDisplay; // optional
property Windows::Foundation::Collections::IVector<ICalcManagerIExprCommand ^> ^ DisplayCommands; // mandatory
StandardCalculatorSnapshot();
};
public
ref struct ApplicationSnapshot sealed
{
property int Mode;
property StandardCalculatorSnapshot ^ StandardCalculator; // optional
};
ICalcManagerIExprCommand ^ CreateExprCommand(const IExpressionCommand* exprCmd);
std::vector<std::shared_ptr<IExpressionCommand>> ToUnderlying(Windows::Foundation::Collections::IVector<ICalcManagerIExprCommand ^> ^ commands);
std::vector<std::shared_ptr<CalculationManager::HISTORYITEM>> ToUnderlying(Windows::Foundation::Collections::IVector<CalcManagerHistoryItem ^> ^ items);
} // namespace CalculatorApp::ViewModel