An object can contain other objects, properties and arrays. More...

#include <Object.h>

Inheritance diagram for ConfigDB::Object:
Collaboration diagram for ConfigDB::Object:

Public Types

using UpdateCallback = Delegate< void(Store &store)>
 Callback invoked by asynchronous updater. More...
 

Public Member Functions

 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
 
bool exportToStream (const Format &format, Print &output) const
 
bool exportToFile (const Format &format, const String &filename) const
 
Status importFromStream (const Format &format, Stream &source)
 
Status importFromFile (const Format &format, const String &filename)
 
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...
 

Public Attributes

uint16_t streamPos {}
 

Protected Member Functions

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

const PropertyInfopropinfoPtr
 
Objectparent {}
 
uint16_t dataRef {}
 

Detailed Description

An object can contain other objects, properties and arrays.

Note
This class is the base for concrete Object, Array and ObjectArray classes

Member Typedef Documentation

◆ UpdateCallback

Callback invoked by asynchronous updater.

Parameters
storeUpdatable store instance
Note
The OuterObjectTemplate::update method template handles this callback so that the caller receives the appropriate Updater object.

Constructor & Destructor Documentation

◆ Object() [1/8]

ConfigDB::Object::Object ( )
inline

◆ Object() [2/8]

ConfigDB::Object::Object ( const Object other)
inline

◆ Object() [3/8]

ConfigDB::Object::Object ( Object &&  )
delete

◆ Object() [4/8]

ConfigDB::Object::Object ( const PropertyInfo propinfo)
inlineexplicit

◆ Object() [5/8]

ConfigDB::Object::Object ( Object parent,
const PropertyInfo prop,
uint16_t  dataRef 
)
inline

◆ Object() [6/8]

ConfigDB::Object::Object ( const Object parent,
const PropertyInfo prop,
uint16_t  dataRef 
)
inline

◆ Object() [7/8]

ConfigDB::Object::Object ( Object parent,
unsigned  propIndex,
uint16_t  dataRef = 0 
)
inline

◆ Object() [8/8]

ConfigDB::Object::Object ( const Object parent,
unsigned  propIndex,
uint16_t  dataRef = 0 
)
inline

Member Function Documentation

◆ clear()

void ConfigDB::Object::clear ( )

Reset contents to defaults (except arrays, which are cleared)

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

◆ clearDirty()

void ConfigDB::Object::clearDirty ( )

Clear store dirty flag so changes don't get committed.

Note
Store must be reloaded to roll back any changes

◆ commit()

bool ConfigDB::Object::commit ( )

Commit changes to the store.

◆ disposeArrays()

void ConfigDB::Object::disposeArrays ( )
protected

◆ exportToFile()

bool ConfigDB::Object::exportToFile ( const Format format,
const String filename 
) const

◆ exportToStream()

bool ConfigDB::Object::exportToStream ( const Format format,
Print output 
) const
inline

◆ findObject()

Object ConfigDB::Object::findObject ( const char *  name,
size_t  length 
)

Find child object by name.

Note
For Union objects this also sets the tag on successful match, which clears the Object to its default value.

◆ findProperty()

Property ConfigDB::Object::findProperty ( const char *  name,
size_t  length 
)

Find property by name.

◆ findStringId()

int ConfigDB::Object::findStringId ( const char *  value,
uint16_t  valueLength 
) const
protected

◆ getDatabase() [1/2]

Database& ConfigDB::Object::getDatabase ( )

◆ getDatabase() [2/2]

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

◆ getDataPtr() [1/2]

void* ConfigDB::Object::getDataPtr ( )
protected

◆ getDataPtr() [2/2]

const void* ConfigDB::Object::getDataPtr ( ) const
protected

◆ getName()

String ConfigDB::Object::getName ( ) const

◆ getObject() [1/2]

Object ConfigDB::Object::getObject ( unsigned  index)

Get child object by index.

◆ getObject() [2/2]

const Object ConfigDB::Object::getObject ( unsigned  index) const
inline

◆ getObjectCount()

unsigned ConfigDB::Object::getObjectCount ( ) const

Get number of child objects.

Note
ObjectArray overrides this to return number of items in the array

◆ getPath()

String ConfigDB::Object::getPath ( ) const

◆ getProperty() [1/2]

Property ConfigDB::Object::getProperty ( unsigned  index)

Get properties.

Note
Array types override this to return array elements

◆ getProperty() [2/2]

PropertyConst ConfigDB::Object::getProperty ( unsigned  index) const

◆ getPropertyCount()

unsigned ConfigDB::Object::getPropertyCount ( ) const

Get number of properties.

Note
Array types override this to return the number of items in the array.

◆ getPropertyData() [1/2]

PropertyData* ConfigDB::Object::getPropertyData ( unsigned  index)
inline

◆ getPropertyData() [2/2]

const PropertyData* ConfigDB::Object::getPropertyData ( unsigned  index) const
inline

◆ getPropertyString() [1/2]

String ConfigDB::Object::getPropertyString ( unsigned  index) const
protected

◆ getPropertyString() [2/2]

String ConfigDB::Object::getPropertyString ( unsigned  index,
StringId  id 
) const
protected

◆ getStore() [1/2]

Store& ConfigDB::Object::getStore ( )

◆ getStore() [2/2]

const Store& ConfigDB::Object::getStore ( ) const
inline

◆ getStringId() [1/3]

StringId ConfigDB::Object::getStringId ( const PropertyInfo prop,
const char *  value,
uint16_t  valueLength 
)
protected

◆ getStringId() [2/3]

StringId ConfigDB::Object::getStringId ( const PropertyInfo prop,
const String value 
)
inlineprotected

◆ getStringId() [3/3]

template<typename T >
StringId ConfigDB::Object::getStringId ( const PropertyInfo prop,
const T &  value 
)
inlineprotected

◆ importFromFile()

Status ConfigDB::Object::importFromFile ( const Format format,
const String filename 
)

◆ importFromStream()

Status ConfigDB::Object::importFromStream ( const Format format,
Stream source 
)
inline

◆ initArrays()

void ConfigDB::Object::initArrays ( )
protected

◆ isArray()

bool ConfigDB::Object::isArray ( ) const
inline

◆ isStore()

bool ConfigDB::Object::isStore ( ) const
inline

Determine if this object is a store (not just a reference to it)

◆ isWriteable()

bool ConfigDB::Object::isWriteable ( ) const
protected

◆ loadArrayDefaults()

void ConfigDB::Object::loadArrayDefaults ( )

Clear and load all contained arrays with defaults from schema.

◆ lockStore()

StoreUpdateRef ConfigDB::Object::lockStore ( StoreRef store)
protected

◆ openStore()

StoreRef ConfigDB::Object::openStore ( Database db,
unsigned  storeIndex 
)
protected

◆ openStoreForUpdate()

StoreUpdateRef ConfigDB::Object::openStoreForUpdate ( Database db,
unsigned  storeIndex 
)
protected

◆ operator bool()

ConfigDB::Object::operator bool ( ) const
inlineexplicit

◆ operator=()

Object& ConfigDB::Object::operator= ( const Object other)

◆ printTo()

size_t ConfigDB::Object::printTo ( Print p) const

◆ propinfo()

const PropertyInfo& ConfigDB::Object::propinfo ( ) const
inline

◆ queueUpdate()

void ConfigDB::Object::queueUpdate ( UpdateCallback  callback)

Called from OuterObjectTemplate::update to queue an update.

◆ resetToDefaults()

void ConfigDB::Object::resetToDefaults ( )

Does a 'clear' followed by 'loadArrayDefaults'.

◆ setPropertyValue() [1/2]

void ConfigDB::Object::setPropertyValue ( unsigned  index,
const String value 
)
protected

◆ setPropertyValue() [2/2]

void ConfigDB::Object::setPropertyValue ( unsigned  index,
const void *  value 
)
protected

◆ typeinfo()

const ObjectInfo& ConfigDB::Object::typeinfo ( ) const
inline

◆ typeIs()

bool ConfigDB::Object::typeIs ( ObjectType  type) const
inline

◆ writeCheck()

bool ConfigDB::Object::writeCheck ( ) const
protected

Member Data Documentation

◆ dataRef

uint16_t ConfigDB::Object::dataRef {}
protected

◆ parent

Object* ConfigDB::Object::parent {}
protected

◆ propinfoPtr

const PropertyInfo* ConfigDB::Object::propinfoPtr
protected

◆ streamPos

uint16_t ConfigDB::Object::streamPos {}

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