Manages access to an object store, typically one file. More...

#include <Store.h>

Inheritance diagram for ConfigDB::Store:
Collaboration diagram for ConfigDB::Store:

Public Member Functions

 Store (Database &db)
 This is an empty Store instance Object chain is built via references so need a valid Store instance which can be identifyed as empty. We don't update the instance count here since it will never contain anything. More...
 
 Store (Database &db, const PropertyInfo &propinfo)
 Storage instance. More...
 
 Store (const Store &store)
 Copy constructor. More...
 
 Store (Store &&)=delete
 
 ~Store ()
 
String getFileName () const
 
String getFilePath () const
 
DatabasegetDatabase () const
 
uint8_t * getRootData ()
 
const uint8_t * getRootData () const
 
void clear ()
 Reset store contents to defaults. More...
 
String getValueString (const PropertyInfo &info, const void *data) const
 
bool parseString (const PropertyInfo &prop, PropertyData &dst, const PropertyData *defaultData, const char *value, uint16_t valueLength)
 
const StringPoolgetStringPool () const
 
const ArrayPoolgetArrayPool () const
 
bool isLocked () const
 
bool writeCheck () const
 
bool exportToFile (const Format &format, const ExportOptions &options={}) const
 
Status importFromFile (const Format &format)
 
bool isDirty () const
 
bool commit ()
 
bool exportToFile (const Format &format, const String &filename, const ExportOptions &options={}) const
 Export object to an output stream. More...
 
Status importFromFile (const Format &format, const String &filename)
 Import content to this object. More...
 
- Public Member Functions inherited from ConfigDB::Object
 Object ()
 
 Object (const Object &other)
 
 Object (Object &&)=delete
 
Objectoperator= (const Object &other)
 
 Object (const PropertyInfo &propinfo)
 
 Object (Object &parent, const PropertyInfo &prop, uint16_t dataRef)
 
 Object (const Object &parent, const PropertyInfo &prop, uint16_t dataRef)
 
 Object (Object &parent, unsigned propIndex, uint16_t dataRef=0)
 
 Object (const Object &parent, unsigned propIndex, uint16_t dataRef=0)
 
 operator bool () const
 
bool typeIs (ObjectType type) const
 
bool isArray () const
 
bool isStore () const
 Determine if this object is a store (not just a reference to it) More...
 
StoregetStore ()
 
const StoregetStore () const
 
DatabasegetDatabase ()
 
const DatabasegetDatabase () const
 
unsigned getObjectCount () const
 Get number of child objects. More...
 
Object getObject (unsigned index)
 Get child object by index. More...
 
const Object getObject (unsigned index) const
 
Object findObject (const char *name, size_t length)
 Find child object by name. More...
 
unsigned getPropertyCount () const
 Get number of properties. More...
 
Property getProperty (unsigned index)
 Get properties. More...
 
PropertyConst getProperty (unsigned index) const
 
Property findProperty (const char *name, size_t length)
 Find property by name. More...
 
void clear ()
 Reset contents to defaults (except arrays, which are cleared) More...
 
void loadArrayDefaults ()
 Clear and load all contained arrays with defaults from schema. More...
 
void resetToDefaults ()
 Does a 'clear' followed by 'loadArrayDefaults'. More...
 
bool commit ()
 Commit changes to the store. More...
 
void clearDirty ()
 Clear store dirty flag so changes don't get committed. More...
 
String getName () const
 
String getPath () const
 
size_t printTo (Print &p) const
 Support standard streaming output of this object's content in prettified JSON. More...
 
bool exportToStream (const Format &format, Print &output, const ExportOptions &options={}) const
 Export object to an output stream. More...
 
bool exportToFile (const Format &format, const String &filename, const ExportOptions &options={}) const
 Export object to an output stream. More...
 
Status importFromStream (const Format &format, Stream &source)
 Import content to this object. More...
 
Status importFromFile (const Format &format, const String &filename)
 Import content to this object. More...
 
const PropertyInfopropinfo () const
 
const ObjectInfotypeinfo () const
 
PropertyDatagetPropertyData (unsigned index)
 
const PropertyDatagetPropertyData (unsigned index) const
 
void queueUpdate (UpdateCallback callback)
 Called from OuterObjectTemplate::update to queue an update. More...
 

Static Public Member Functions

static uint8_t getInstanceCount ()
 Get number of valid (non-empty) Store instances in existence. More...
 
static StoreUpdateRef lock (StoreRef &store)
 

Protected Member Functions

void checkRef (const StoreRef &ref)
 
void queueUpdate (Object::UpdateCallback &&callback)
 
void clearDirty ()
 
void incUpdate ()
 
void decUpdate ()
 
- Protected Member Functions inherited from ConfigDB::Object
StoreRef openStore (Database &db, unsigned storeIndex)
 
StoreUpdateRef openStoreForUpdate (Database &db, unsigned storeIndex)
 
void disposeArrays ()
 
void initArrays ()
 
bool isWriteable () const
 
StoreUpdateRef lockStore (StoreRef &store)
 
bool writeCheck () const
 
void * getDataPtr ()
 
const void * getDataPtr () const
 
String getPropertyString (unsigned index, StringId id) const
 
String getPropertyString (unsigned index) const
 
StringId getStringId (const PropertyInfo &prop, const char *value, uint16_t valueLength)
 
StringId getStringId (const PropertyInfo &prop, const String &value)
 
template<typename T >
StringId getStringId (const PropertyInfo &prop, const T &value)
 
int findStringId (const char *value, uint16_t valueLength) const
 
void setPropertyValue (unsigned index, const void *value)
 
void setPropertyValue (unsigned index, const String &value)
 

Protected Attributes

ArrayPool arrayPool
 
StringPool stringPool
 
- Protected Attributes inherited from ConfigDB::Object
const PropertyInfopropinfoPtr
 
Objectparent {}
 
uint16_t dataRef {}
 

Friends

class Object
 
class ArrayBase
 
class Database
 
class StoreRef
 
class StoreUpdateRef
 

Additional Inherited Members

- Public Types inherited from ConfigDB::Object
using UpdateCallback = Delegate< void(Store &store)>
 Callback invoked by asynchronous updater. More...
 
- Public Attributes inherited from ConfigDB::Object
uint16_t streamPos {}
 

Detailed Description

Manages access to an object store, typically one file.

Constructor & Destructor Documentation

◆ Store() [1/4]

ConfigDB::Store::Store ( Database db)
inline

This is an empty Store instance Object chain is built via references so need a valid Store instance which can be identifyed as empty. We don't update the instance count here since it will never contain anything.

◆ Store() [2/4]

ConfigDB::Store::Store ( Database db,
const PropertyInfo propinfo 
)

Storage instance.

Parameters
dbDatabase which manages this store
typeinfoStore type information

◆ Store() [3/4]

ConfigDB::Store::Store ( const Store store)
explicit

Copy constructor.

◆ Store() [4/4]

ConfigDB::Store::Store ( Store &&  )
delete

◆ ~Store()

ConfigDB::Store::~Store ( )

Member Function Documentation

◆ checkRef()

void ConfigDB::Store::checkRef ( const StoreRef ref)
protected

◆ clear()

void ConfigDB::Store::clear ( )

Reset store contents to defaults.

Note
Use caution! All reference objects will be invalidated by this call

◆ clearDirty()

void ConfigDB::Store::clearDirty ( )
inlineprotected

◆ commit()

bool ConfigDB::Store::commit ( )

◆ decUpdate()

void ConfigDB::Store::decUpdate ( )
protected

◆ exportToFile() [1/2]

bool ConfigDB::Store::exportToFile ( const Format format,
const ExportOptions options = {} 
) const
inline

◆ exportToFile() [2/2]

bool ConfigDB::Object::exportToFile

Export object to an output stream.

Parameters
formatFormatter used to generate output
filenameWhere to write output. Non-existent directories are created automatically.
optionsOptions for customising output

◆ getArrayPool()

const ArrayPool& ConfigDB::Store::getArrayPool ( ) const
inline

◆ getDatabase()

Database& ConfigDB::Store::getDatabase ( ) const
inline

◆ getFileName()

String ConfigDB::Store::getFileName ( ) const
inline

◆ getFilePath()

String ConfigDB::Store::getFilePath ( ) const

◆ getInstanceCount()

static uint8_t ConfigDB::Store::getInstanceCount ( )
inlinestatic

Get number of valid (non-empty) Store instances in existence.

◆ getRootData() [1/2]

uint8_t* ConfigDB::Store::getRootData ( )
inline

◆ getRootData() [2/2]

const uint8_t* ConfigDB::Store::getRootData ( ) const
inline

◆ getStringPool()

const StringPool& ConfigDB::Store::getStringPool ( ) const
inline

◆ getValueString()

String ConfigDB::Store::getValueString ( const PropertyInfo info,
const void *  data 
) const

◆ importFromFile() [1/2]

Status ConfigDB::Store::importFromFile ( const Format format)
inline

◆ importFromFile() [2/2]

Status ConfigDB::Object::importFromFile

Import content to this object.

Parameters
formatFormatter used to read the source data
filenameFile containing source data, not including the name of the object itself

◆ incUpdate()

void ConfigDB::Store::incUpdate ( )
protected

◆ isDirty()

bool ConfigDB::Store::isDirty ( ) const
inline

◆ isLocked()

bool ConfigDB::Store::isLocked ( ) const
inline

◆ lock()

static StoreUpdateRef ConfigDB::Store::lock ( StoreRef store)
static

◆ parseString()

bool ConfigDB::Store::parseString ( const PropertyInfo prop,
PropertyData dst,
const PropertyData defaultData,
const char *  value,
uint16_t  valueLength 
)

◆ queueUpdate()

void ConfigDB::Store::queueUpdate ( Object::UpdateCallback &&  callback)
protected

◆ writeCheck()

bool ConfigDB::Store::writeCheck ( ) const

Friends And Related Function Documentation

◆ ArrayBase

friend class ArrayBase
friend

◆ Database

friend class Database
friend

◆ Object

friend class Object
friend

◆ StoreRef

friend class StoreRef
friend

◆ StoreUpdateRef

friend class StoreUpdateRef
friend

Member Data Documentation

◆ arrayPool

ArrayPool ConfigDB::Store::arrayPool
protected

◆ stringPool

StringPool ConfigDB::Store::stringPool
protected

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