Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
ersa::services::StorageService Class Referenceabstract

#include <storage_service.h>

Inheritance diagram for ersa::services::StorageService:
Inheritance graph
[legend]

Public Member Functions

virtual ~StorageService ()=default
 
virtual Result< void > init ()=0
 
virtual bool setString (std::string_view key, std::string_view value)=0
 
virtual std::string getString (std::string_view key, std::string_view defaultValue="")=0
 
virtual bool setInt (std::string_view key, int32_t value)=0
 
virtual int32_t getInt (std::string_view key, int32_t defaultValue=0)=0
 
virtual bool setBool (std::string_view key, bool value)=0
 
virtual bool getBool (std::string_view key, bool defaultValue=false)=0
 
virtual bool setBytes (std::string_view key, const void *data, size_t size)=0
 
virtual size_t getBytesLength (std::string_view key)=0
 
virtual size_t getBytes (std::string_view key, void *data, size_t size)=0
 
virtual bool remove (std::string_view key)=0
 
virtual void clear ()=0
 

Static Public Member Functions

static StorageService & instance ()
 Return the installed process-wide storage service.
 
static void setInstance (StorageService *instance)
 Install the process-wide storage backend.
 

Detailed Description

Typed persistent key/value contract used by settings and app state.

The interface avoids exposing NVS, filesystems, or host test storage details. Values are stored by key and implementations decide the physical medium; callers must inspect write results when persistence matters and use defaults when keys are absent, which supports first-boot and schema migration paths.

Constructor & Destructor Documentation

◆ ~StorageService()

virtual ersa::services::StorageService::~StorageService ( )
virtualdefault

Member Function Documentation

◆ clear()

virtual void ersa::services::StorageService::clear ( )
pure virtual

Clear this service's namespace; use carefully because it removes all keys.

Implemented in ersa::services::MemoryStorageService.

◆ getBool()

virtual bool ersa::services::StorageService::getBool ( std::string_view  key,
bool  defaultValue = false 
)
pure virtual

Read a boolean setting or return defaultValue when the key is absent.

Implemented in ersa::services::MemoryStorageService.

◆ getBytes()

virtual size_t ersa::services::StorageService::getBytes ( std::string_view  key,
void *  data,
size_t  size 
)
pure virtual

Copy a stored record when its size matches; return bytes copied or zero.

Implemented in ersa::services::MemoryStorageService.

◆ getBytesLength()

virtual size_t ersa::services::StorageService::getBytesLength ( std::string_view  key)
pure virtual

Return the exact stored record size, or zero when the key is absent.

Implemented in ersa::services::MemoryStorageService.

◆ getInt()

virtual int32_t ersa::services::StorageService::getInt ( std::string_view  key,
int32_t  defaultValue = 0 
)
pure virtual

Read a signed integer or return defaultValue for an absent key.

Implemented in ersa::services::MemoryStorageService.

◆ getString()

virtual std::string ersa::services::StorageService::getString ( std::string_view  key,
std::string_view  defaultValue = "" 
)
pure virtual

Return the stored value or a copy of defaultValue when key is absent.

Implemented in ersa::services::MemoryStorageService.

◆ init()

virtual Result< void > ersa::services::StorageService::init ( )
pure virtual

Mount/open the backend and prepare its namespace for reads and writes.

Implemented in ersa::services::MemoryStorageService.

◆ instance()

StorageService & ersa::services::StorageService::instance ( )
static

Return the installed process-wide storage service.

◆ remove()

virtual bool ersa::services::StorageService::remove ( std::string_view  key)
pure virtual

Remove one key; false means no removal was made or the backend failed.

Implemented in ersa::services::MemoryStorageService.

◆ setBool()

virtual bool ersa::services::StorageService::setBool ( std::string_view  key,
bool  value 
)
pure virtual

Store a boolean setting; false indicates that persistence failed.

Implemented in ersa::services::MemoryStorageService.

◆ setBytes()

virtual bool ersa::services::StorageService::setBytes ( std::string_view  key,
const void *  data,
size_t  size 
)
pure virtual

Store an opaque byte record for bounded caches and versioned snapshots.

Implemented in ersa::services::MemoryStorageService.

◆ setInstance()

void ersa::services::StorageService::setInstance ( StorageService *  instance)
static

Install the process-wide storage backend.

◆ setInt()

virtual bool ersa::services::StorageService::setInt ( std::string_view  key,
int32_t  value 
)
pure virtual

Store a signed integer using the backend's typed representation.

Implemented in ersa::services::MemoryStorageService.

◆ setString()

virtual bool ersa::services::StorageService::setString ( std::string_view  key,
std::string_view  value 
)
pure virtual

Store a string; false reports backend failure or exhausted storage.

Implemented in ersa::services::MemoryStorageService.


The documentation for this class was generated from the following files: