#include <Database.h>
Public Member Functions | |
| Database (const DatabaseInfo &typeinfo, const String &path) | |
| Database instance. More... | |
| virtual | ~Database () |
| String | getName () const |
| String | getPath () const |
| StoreRef | openStore (unsigned index) |
| Open a store instance, load it and return a shared pointer. More... | |
| StoreUpdateRef | openStoreForUpdate (unsigned index) |
| void | checkStoreRef (const StoreRef &ref) |
| Called from StoreRef destructor so database can manage caches. More... | |
| void | queueUpdate (Store &store, Object::UpdateCallback &&callback) |
| Queue an asynchronous update. More... | |
| void | checkUpdateQueue (Store &store) |
| Called by Store on completion of update so any queued updates can be started. More... | |
| bool | save (Store &store) const |
| Called from Store::commit. More... | |
| StoreUpdateRef | lockStore (StoreRef &store) |
| Lock a store for writing (called by Object) More... | |
| virtual const Format & | getFormat (const Store &store) const |
| Get the storage format to use for a store. More... | |
| virtual bool | handleFormatError (FormatError err, const Object &object, const String &arg) |
| Called during import. More... | |
| std::unique_ptr< ExportStream > | createExportStream (const Format &format, const String &path=nullptr, const ExportOptions &options={}) |
| Create a read-only stream for serializing the database. More... | |
| size_t | exportToStream (const Format &format, Print &output, const ExportOptions &options={}) |
| Serialize the database to a stream. More... | |
| bool | exportToFile (const Format &format, const String &filename, const ExportOptions &options={}) |
| Serialize the database to a single file. More... | |
| Status | importFromStream (const Format &format, Stream &source) |
| De-serialize the entire database from a stream. More... | |
| Status | importFromFile (const Format &format, const String &filename) |
| De-serialize the entire database from a file. More... | |
| std::unique_ptr< ImportStream > | createImportStream (const Format &format) |
| Create a write-only stream for de-serializing the database. More... | |
Public Attributes | |
| const DatabaseInfo & | typeinfo |
Constructor & Destructor Documentation
◆ Database()
|
inline |
Database instance.
- Parameters
-
path Path to root directory where all data is stored
◆ ~Database()
|
virtual |
Member Function Documentation
◆ checkStoreRef()
| void ConfigDB::Database::checkStoreRef | ( | const StoreRef & | ref | ) |
Called from StoreRef destructor so database can manage caches.
- Parameters
-
ref The store reference being destroyed
◆ checkUpdateQueue()
| void ConfigDB::Database::checkUpdateQueue | ( | Store & | store | ) |
Called by Store on completion of update so any queued updates can be started.
- Parameters
-
store The store which has just finished updating
- Note
- The next queued update (if any) is popped from the queue and scheduled for handling via the task queue.
◆ createExportStream()
| std::unique_ptr<ExportStream> ConfigDB::Database::createExportStream | ( | const Format & | format, |
| const String & | path = nullptr, |
||
| const ExportOptions & | options = {} |
||
| ) |
Create a read-only stream for serializing the database.
- Parameters
-
format Formatter used to generate output path JSONPath-like expression to restrict output to specific store or object options Options for customising output
◆ createImportStream()
|
inline |
Create a write-only stream for de-serializing the database.
- Parameters
-
format Formatter used to process incoming data from the stream
◆ exportToFile()
| bool ConfigDB::Database::exportToFile | ( | const Format & | format, |
| const String & | filename, | ||
| const ExportOptions & | options = {} |
||
| ) |
Serialize the database to a single file.
- Parameters
-
format Formatter used to generate output filename Where to write output. Non-existent directories are created automatically. options Options for customising output
◆ exportToStream()
|
inline |
Serialize the database to a stream.
- Parameters
-
format Formatter used to generate output output Where to write output options Options for customising output
◆ getFormat()
Get the storage format to use for a store.
◆ getName()
|
inline |
◆ getPath()
|
inline |
◆ handleFormatError()
|
virtual |
Called during import.
- Parameters
-
object The object to which this error relates arg String parameter which failed validation err The specific error type
- Return values
-
bool Return true to continue processing, false to stop
Default behaviour is to report errors but continue processing.
◆ importFromFile()
De-serialize the entire database from a file.
- Parameters
-
format Formatter used to read the source data filename File containing source data
◆ importFromStream()
De-serialize the entire database from a stream.
- Parameters
-
format Formatter used to read the source data source The source data
◆ lockStore()
| StoreUpdateRef ConfigDB::Database::lockStore | ( | StoreRef & | store | ) |
Lock a store for writing (called by Object)
- Parameters
-
store Store reference to be locked. If possible, will be locked-in place otherwise it will be copied and updated.
- Return values
-
StoreUpdateRef Invalid if locking fails
◆ openStore()
Open a store instance, load it and return a shared pointer.
◆ openStoreForUpdate()
| StoreUpdateRef ConfigDB::Database::openStoreForUpdate | ( | unsigned | index | ) |
◆ queueUpdate()
| void ConfigDB::Database::queueUpdate | ( | Store & | store, |
| Object::UpdateCallback && | callback | ||
| ) |
Queue an asynchronous update.
- Parameters
-
store The store to update callback Callback which will be invoked when store is available for updates
◆ save()
| bool ConfigDB::Database::save | ( | Store & | store | ) | const |
Called from Store::commit.
Member Data Documentation
◆ typeinfo
| const DatabaseInfo& ConfigDB::Database::typeinfo |
The documentation for this class was generated from the following file:
1.9.1