roo_prefs
API Documentation for roo_prefs
Loading...
Searching...
No Matches
roo_prefs Namespace Reference

Similar to Pref<T>, but does not immediately store written data in persistent storage. Instead, writes with a delay, which depends on whether the data stabilized or keeps changing. More...

Namespaces

namespace  internal
 Implementation details follow.
 

Data Structures

class  Collection
 Collection corresponds to a preferences namespace. Use it to group related preferences. More...
 
class  LazyWritePref
 
class  Pref
 Persistent preference of a specific type. The preference will store its value in the preferences collection provided in the constructor, under the specified key (which needs to remain constant). The value is read lazily (on first access.) You can provide default value to be used if the collection does not contain the specified key. The value is cached in memory - subsequent reads will return the cached value. Writes always write to the persistent storage (and also, update the cache.) Read and write are performed within implicitly created transactions. If you have multiple properties that you want to read/write at the same time, you can read them under an explicit transaction: More...
 
class  PreferencesStore
 Low-level wrapper around the underlying preferences storage. More...
 
class  Transaction
 Ref-counted RAII for managing access to Preference namespaces. Allows orchestrating access to the Store. More...
 

Typedefs

using Store = PreferencesStore
 
using LazyBool = LazyWritePref< bool >
 
using LazyUint8 = LazyWritePref< uint8_t >
 
using LazyInt8 = LazyWritePref< int8_t >
 
using LazyUint16 = LazyWritePref< uint16_t >
 
using LazyInt16 = LazyWritePref< int16_t >
 
using LazyUint32 = LazyWritePref< uint32_t >
 
using LazyInt32 = LazyWritePref< int32_t >
 
using LazyUint64 = LazyWritePref< uint64_t >
 
using LazyInt64 = LazyWritePref< int64_t >
 
using LazyFloat = LazyWritePref< float >
 
using LazyDouble = LazyWritePref< double >
 
using Bool = Pref< bool >
 
using Uint8 = Pref< uint8_t >
 
using Int8 = Pref< int8_t >
 
using Uint16 = Pref< uint16_t >
 
using Int16 = Pref< int16_t >
 
using Uint32 = Pref< uint32_t >
 
using Int32 = Pref< int32_t >
 
using Uint64 = Pref< uint64_t >
 
using Int64 = Pref< int64_t >
 
using Float = Pref< float >
 
using Double = Pref< double >
 
using String = Pref< std::string >
 

Enumerations

enum class  ReadResult { kOk , kNotFound , kWrongType , kError }
 Result of reading a value from storage. More...
 
enum class  WriteResult { kOk , kError }
 Result of writing a value to storage. More...
 
enum class  ClearResult { kOk , kError }
 Result of clearing a value from storage. More...
 

Functions

const char * ReadResultToString (ReadResult result)
 
const char * WriteResultToString (WriteResult result)
 
const char * ClearResultToString (ClearResult result)
 
roo_logging::Stream & operator<< (roo_logging::Stream &os, ReadResult result)
 
roo_logging::Stream & operator<< (roo_logging::Stream &os, WriteResult result)
 
roo_logging::Stream & operator<< (roo_logging::Stream &os, ClearResult result)
 

Variables

constexpr ReadResult READ_OK = ReadResult::kOk
 
constexpr ReadResult READ_NOT_FOUND = ReadResult::kNotFound
 
constexpr ReadResult READ_WRONG_TYPE = ReadResult::kWrongType
 
constexpr ReadResult READ_ERROR = ReadResult::kError
 
constexpr WriteResult WRITE_OK = WriteResult::kOk
 
constexpr WriteResult WRITE_ERROR = WriteResult::kError
 
constexpr ClearResult CLEAR_OK = ClearResult::kOk
 
constexpr ClearResult CLEAR_ERROR = ClearResult::kError
 

Detailed Description

Similar to Pref<T>, but does not immediately store written data in persistent storage. Instead, writes with a delay, which depends on whether the data stabilized or keeps changing.

Depends on the "dejwk/roo_scheduler" library.

Typedef Documentation

◆ Bool

using roo_prefs::Bool = typedef Pref<bool>

Definition at line 75 of file pref.h.

◆ Double

using roo_prefs::Double = typedef Pref<double>

Definition at line 85 of file pref.h.

◆ Float

using roo_prefs::Float = typedef Pref<float>

Definition at line 84 of file pref.h.

◆ Int16

using roo_prefs::Int16 = typedef Pref<int16_t>

Definition at line 79 of file pref.h.

◆ Int32

using roo_prefs::Int32 = typedef Pref<int32_t>

Definition at line 81 of file pref.h.

◆ Int64

using roo_prefs::Int64 = typedef Pref<int64_t>

Definition at line 83 of file pref.h.

◆ Int8

using roo_prefs::Int8 = typedef Pref<int8_t>

Definition at line 77 of file pref.h.

◆ LazyBool

using roo_prefs::LazyBool = typedef LazyWritePref<bool>

Definition at line 48 of file lazy_write_pref.h.

◆ LazyDouble

using roo_prefs::LazyDouble = typedef LazyWritePref<double>

Definition at line 58 of file lazy_write_pref.h.

◆ LazyFloat

using roo_prefs::LazyFloat = typedef LazyWritePref<float>

Definition at line 57 of file lazy_write_pref.h.

◆ LazyInt16

using roo_prefs::LazyInt16 = typedef LazyWritePref<int16_t>

Definition at line 52 of file lazy_write_pref.h.

◆ LazyInt32

using roo_prefs::LazyInt32 = typedef LazyWritePref<int32_t>

Definition at line 54 of file lazy_write_pref.h.

◆ LazyInt64

using roo_prefs::LazyInt64 = typedef LazyWritePref<int64_t>

Definition at line 56 of file lazy_write_pref.h.

◆ LazyInt8

using roo_prefs::LazyInt8 = typedef LazyWritePref<int8_t>

Definition at line 50 of file lazy_write_pref.h.

◆ LazyUint16

using roo_prefs::LazyUint16 = typedef LazyWritePref<uint16_t>

Definition at line 51 of file lazy_write_pref.h.

◆ LazyUint32

using roo_prefs::LazyUint32 = typedef LazyWritePref<uint32_t>

Definition at line 53 of file lazy_write_pref.h.

◆ LazyUint64

using roo_prefs::LazyUint64 = typedef LazyWritePref<uint64_t>

Definition at line 55 of file lazy_write_pref.h.

◆ LazyUint8

using roo_prefs::LazyUint8 = typedef LazyWritePref<uint8_t>

Definition at line 49 of file lazy_write_pref.h.

◆ Store

Definition at line 10 of file collection.h.

◆ String

using roo_prefs::String = typedef Pref<std::string>

Definition at line 87 of file pref.h.

◆ Uint16

using roo_prefs::Uint16 = typedef Pref<uint16_t>

Definition at line 78 of file pref.h.

◆ Uint32

using roo_prefs::Uint32 = typedef Pref<uint32_t>

Definition at line 80 of file pref.h.

◆ Uint64

using roo_prefs::Uint64 = typedef Pref<uint64_t>

Definition at line 82 of file pref.h.

◆ Uint8

using roo_prefs::Uint8 = typedef Pref<uint8_t>

Definition at line 76 of file pref.h.

Enumeration Type Documentation

◆ ClearResult

enum class roo_prefs::ClearResult
strong

Result of clearing a value from storage.

Enumerator
kOk 
kError 

Definition at line 14 of file status.h.

◆ ReadResult

enum class roo_prefs::ReadResult
strong

Result of reading a value from storage.

Enumerator
kOk 
kNotFound 
kWrongType 
kError 

Definition at line 8 of file status.h.

◆ WriteResult

enum class roo_prefs::WriteResult
strong

Result of writing a value to storage.

Enumerator
kOk 
kError 

Definition at line 11 of file status.h.

Function Documentation

◆ ClearResultToString()

const char * roo_prefs::ClearResultToString ( ClearResult  result)

Definition at line 29 of file status.cpp.

References kError, and kOk.

Referenced by operator<<().

◆ operator<<() [1/3]

roo_logging::Stream & roo_prefs::operator<< ( roo_logging::Stream &  os,
ClearResult  result 
)

Definition at line 47 of file status.cpp.

References ClearResultToString().

◆ operator<<() [2/3]

roo_logging::Stream & roo_prefs::operator<< ( roo_logging::Stream &  os,
ReadResult  result 
)

Definition at line 39 of file status.cpp.

References ReadResultToString().

◆ operator<<() [3/3]

roo_logging::Stream & roo_prefs::operator<< ( roo_logging::Stream &  os,
WriteResult  result 
)

Definition at line 43 of file status.cpp.

References WriteResultToString().

◆ ReadResultToString()

const char * roo_prefs::ReadResultToString ( ReadResult  result)

Definition at line 5 of file status.cpp.

References kError, kNotFound, kOk, and kWrongType.

Referenced by operator<<().

◆ WriteResultToString()

const char * roo_prefs::WriteResultToString ( WriteResult  result)

Definition at line 19 of file status.cpp.

References kError, and kOk.

Referenced by operator<<().

Variable Documentation

◆ CLEAR_ERROR

constexpr ClearResult roo_prefs::CLEAR_ERROR = ClearResult::kError
constexpr
Deprecated:
Use ClearResult::kError instead.

Definition at line 41 of file status.h.

◆ CLEAR_OK

constexpr ClearResult roo_prefs::CLEAR_OK = ClearResult::kOk
constexpr
Deprecated:
Use ClearResult::kOk instead.

Definition at line 39 of file status.h.

◆ READ_ERROR

constexpr ReadResult roo_prefs::READ_ERROR = ReadResult::kError
constexpr
Deprecated:
Use ReadResult::kError instead.

Definition at line 31 of file status.h.

◆ READ_NOT_FOUND

constexpr ReadResult roo_prefs::READ_NOT_FOUND = ReadResult::kNotFound
constexpr
Deprecated:
Use ReadResult::kNotFound instead.

Definition at line 27 of file status.h.

◆ READ_OK

constexpr ReadResult roo_prefs::READ_OK = ReadResult::kOk
constexpr
Deprecated:
Use ReadResult::kOk instead.

Definition at line 25 of file status.h.

◆ READ_WRONG_TYPE

constexpr ReadResult roo_prefs::READ_WRONG_TYPE = ReadResult::kWrongType
constexpr
Deprecated:
Use ReadResult::kWrongType instead.

Definition at line 29 of file status.h.

◆ WRITE_ERROR

constexpr WriteResult roo_prefs::WRITE_ERROR = WriteResult::kError
constexpr
Deprecated:
Use WriteResult::kError instead.

Definition at line 36 of file status.h.

◆ WRITE_OK

constexpr WriteResult roo_prefs::WRITE_OK = WriteResult::kOk
constexpr
Deprecated:
Use WriteResult::kOk instead.

Definition at line 34 of file status.h.