core-avr-database¶
Database¶
-
class
Database
¶ Entry point for adding data to + updating fixed size files.
Public Functions
-
~Database
()¶ Destructor.
-
float
numRecords
()¶ Total number of stored records.
- Return
- Total number of records stored.
-
bool
load
(AvrStream *stream, const int offset)¶ Loads header into memory. This is for Databases that already exist.
- Return
- True if the file was successfully loaded.
- Parameters
stream
: The stream to read/write from.offset
: The byte offset this file starts at.
-
bool
init
(AvrStream *stream, const int offset, const short contentSize, const char valuesPerRecord, const char *uri)¶ Writes header to disk. This is for new Databases.
- Return
- True if the file was successfully written.
- Parameters
stream
: The stream to write to.offset
: The byte offset this file starts at.contentSize
: The size, in bytes, of the file.valuesPerRecord
: The number of values per record.uri
: The uri of the resource.
-
bool
flush
()¶ Flushes any changes to the stream, in case the Database decides to cache.
- Return
- { description_of_the_return_value }
-
bool
add
(const float *value)¶ Adds a set of values to the file. These values are added with a timestamp.
- Return
- Returns true iff the add was successful.
- Parameters
value
: The floats to add to the file.
-
int
dump
(char *buffer, const int recordDffset, const int recordCount)¶ Dumps database data to a buffer. Format is described in more detail in the core-avr-sensor documentation.
This method may modify the buffer and still fail.
- Return
- Returns the number of records copied.
- Parameters
buffer
: Buffer to copy records into.recordOffset
: The starting index of records.recordCount
: The number of records to copy into the buffer.
Public Members
-
DatabaseHeader
header
¶ Header information.
-
Database Manager¶
-
class
DatabaseManager
¶ The DatabaseManager class exposes a fixed-size file manipulation API, based on URI.
Public Functions
-
DatabaseManager
(AvrClock *clock, AvrStream *stream)¶ Constructor.
- Parameters
clock
: The clock implementation to use.stream
: The stream to read/write data with.
-
~DatabaseManager
()¶ Destructor.
-
bool
load
(DatabaseManagerConfig config)¶ Attempts to load existing filesystem.
- Return
- Returns true if everything is good to go.
-
bool
init
(DatabaseManagerConfig config)¶ Initializes a new filesystem.
- Return
- Returns true if everything is good to go.
-
Database *
create
(const char *uri, const int size, const char valuesPerRecord)¶ Creates a Database of a specific size, linked to a URI.
-
Database *
get
(const char *uri)¶ Retrieves a file by uri.
- Return
- If the Database was found, the file. Otherwise, nullptr.
- Parameters
uri
: The uri to retrieve the file with.
-
bool
set
(Database *file)¶ Writes the file. This is the equivalent to calling Database::flush().
- Return
- Returns true if the Database was successfully saved.
- Parameters
file
: The file to write to disk.
-
AvrClock¶
-
class
AvrClock
¶ Abstraction for clock.
Subclassed by ArduinoClock, StandardClock