equal
deleted
inserted
replaced
19 * This can be done in two ways: |
19 * This can be done in two ways: |
20 * - saving the changes permanently |
20 * - saving the changes permanently |
21 * - reverting to the previous version |
21 * - reverting to the previous version |
22 * @param keep_changes do we save or revert the changes since the last ClearChanges? |
22 * @param keep_changes do we save or revert the changes since the last ClearChanges? |
23 */ |
23 */ |
24 virtual void ClearChanges(bool keep_changes) {} |
24 virtual void ClearChanges(bool keep_changes) = 0; |
|
25 |
|
26 /** |
|
27 * Stores some value at a given position. |
|
28 * @param pos the position to write at |
|
29 * @param value the value to write |
|
30 */ |
|
31 virtual void Store(uint pos, uint32 value) = 0; |
25 }; |
32 }; |
26 |
33 |
27 /** |
34 /** |
28 * Class for persistent storage of data. |
35 * Class for persistent storage of data. |
29 * On ClearChanges that data is either reverted or saved. |
36 * On ClearChanges that data is either reverted or saved. |
52 * If there is no backup of the data that backup is made and then |
59 * If there is no backup of the data that backup is made and then |
53 * we write the data. |
60 * we write the data. |
54 * @param pos the position to write at |
61 * @param pos the position to write at |
55 * @param value the value to write |
62 * @param value the value to write |
56 */ |
63 */ |
57 void Store(uint pos, TYPE value) |
64 void Store(uint pos, uint32 value) |
58 { |
65 { |
59 /* Out of the scope of the array */ |
66 /* Out of the scope of the array */ |
60 if (pos >= SIZE) return; |
67 if (pos >= SIZE) return; |
61 |
68 |
62 /* The value hasn't changed, so we pretend nothing happened. |
69 /* The value hasn't changed, so we pretend nothing happened. |
81 /** |
88 /** |
82 * Gets the value from a given position. |
89 * Gets the value from a given position. |
83 * @param pos the position to get the data from |
90 * @param pos the position to get the data from |
84 * @return the data from that position |
91 * @return the data from that position |
85 */ |
92 */ |
86 TYPE Get(uint pos) |
93 TYPE Get(uint pos) const |
87 { |
94 { |
88 /* Out of the scope of the array */ |
95 /* Out of the scope of the array */ |
89 if (pos >= SIZE) return 0; |
96 if (pos >= SIZE) return 0; |
90 |
97 |
91 return this->storage[pos]; |
98 return this->storage[pos]; |
122 /** |
129 /** |
123 * Stores some value at a given position. |
130 * Stores some value at a given position. |
124 * @param pos the position to write at |
131 * @param pos the position to write at |
125 * @param value the value to write |
132 * @param value the value to write |
126 */ |
133 */ |
127 void Store(uint pos, TYPE value) |
134 void Store(uint pos, uint32 value) |
128 { |
135 { |
129 /* Out of the scope of the array */ |
136 /* Out of the scope of the array */ |
130 if (pos >= SIZE) return; |
137 if (pos >= SIZE) return; |
131 |
138 |
132 this->storage[pos] = value; |
139 this->storage[pos] = value; |
136 /** |
143 /** |
137 * Gets the value from a given position. |
144 * Gets the value from a given position. |
138 * @param pos the position to get the data from |
145 * @param pos the position to get the data from |
139 * @return the data from that position |
146 * @return the data from that position |
140 */ |
147 */ |
141 TYPE Get(uint pos) |
148 TYPE Get(uint pos) const |
142 { |
149 { |
143 /* Out of the scope of the array */ |
150 /* Out of the scope of the array */ |
144 if (pos >= SIZE) return 0; |
151 if (pos >= SIZE) return 0; |
145 |
152 |
146 return this->storage[pos]; |
153 return this->storage[pos]; |