supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
storage
state_storage_interface.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_STORAGE_STATE_STORAGE_INTERFACE_H_
20
#define SRC_SUPLA_STORAGE_STATE_STORAGE_INTERFACE_H_
21
22
#include <stdint.h>
23
24
namespace
Supla {
25
26
class
Storage
;
27
struct
SectionPreamble
;
28
29
class
StateStorageInterface {
30
public
:
31
explicit
StateStorageInterface(Storage *storage, uint8_t sectionType);
32
virtual
~StateStorageInterface();
33
virtual
bool
loadPreambles(uint32_t storageStartingOffset, uint16_t size);
34
virtual
void
initSectionPreamble(
Supla::SectionPreamble
*preamble) = 0;
35
virtual
bool
writeSectionPreamble() = 0;
36
virtual
bool
initFromStorage() = 0;
37
virtual
void
deleteAll() = 0;
38
virtual
bool
prepareSaveState() = 0;
39
virtual
bool
prepareSizeCheck() = 0;
40
virtual
bool
prepareLoadState() = 0;
41
virtual
bool
readState(
unsigned
char
*,
int
) = 0;
42
virtual
bool
writeState(
const
unsigned
char
*,
int
) = 0;
43
virtual
bool
finalizeSaveState() = 0;
44
virtual
bool
finalizeSizeCheck() = 0;
45
virtual
bool
finalizeLoadState() = 0;
46
virtual
void
notifyUpdate();
47
48
protected
:
49
int
readStorage(
unsigned
int
address,
50
unsigned
char
*buf,
51
int
size,
52
bool
logs =
true
);
53
int
writeStorage(
unsigned
int
address,
const
unsigned
char
*buf,
int
size);
54
int
updateStorage(
unsigned
int
address,
const
unsigned
char
*buf,
int
size);
55
void
commit();
56
void
eraseSector(
unsigned
int
address,
int
size);
57
virtual
uint16_t getSizeValue(uint16_t availableSize);
58
59
Storage *storage =
nullptr
;
60
const
uint8_t sectionType;
61
};
62
}
// namespace Supla
63
64
#endif
// SRC_SUPLA_STORAGE_STATE_STORAGE_INTERFACE_H_
Supla::Storage
Definition
storage.h:38
Supla::SectionPreamble
Definition
storage.h:162
Generated by
1.17.0