COSA
An Object-Oriented Platform for Arduino Programming
|
#include <Registry.hh>
Classes | |
class | Action |
struct | action_t |
struct | blob_t |
struct | item_list_t |
struct | item_t |
class | Iterator |
Public Types | |
enum | type_t { ITEM = 0, ITEM_LIST = 1, ACTION = 2, BLOB = 3, APPL = 4 } |
enum | storage_t { IN_PROGMEM = 0, IN_SRAM = 1, IN_EEMEM = 2 } |
typedef const item_t * | item_P |
typedef const item_P * | item_vec_P |
typedef const item_list_t * | item_list_P |
typedef const action_t * | action_P |
typedef const blob_t * | blob_P |
Public Member Functions | |
int | get_value (blob_P blob, void *buf, size_t len) |
template<class T > | |
bool | get_value (blob_P blob, T *value) |
int | set_value (blob_P blob, const void *buf, size_t len) |
template<class T > | |
bool | set_value (blob_P blob, const T *value) |
Registry (item_list_P root, EEPROM::Device *eeprom=NULL) | |
item_P | lookup (const uint8_t *path=NULL, size_t count=0) |
void | print (IOStream &outs, const uint8_t *path, size_t count) |
int | apply (const uint8_t *path, size_t count, void *buf, size_t len) |
Static Public Member Functions | |
static type_t | get_type (item_P item) |
static str_P | get_name (item_P item) |
static storage_t | get_storage (item_P item) |
static bool | is_readonly (item_P item) |
static item_list_P | to_list (item_P item) |
static int | get_length (item_list_P list) |
static action_P | to_action (item_P item) |
static int | run (action_P action, void *buf, size_t size) |
static blob_P | to_blob (item_P item) |
Static Public Attributes | |
static const uint8_t | STORAGE_MASK = 0x7f |
static const uint8_t | READONLY = 0x80 |
static const size_t | PATH_MAX = 8 |
Cosa Configuration Registry. Allow path (x0.x1..xn) access to registry items. Supports actions and binary objects in tree structure. The binary object is a mapping from program memory to data stored in SRAM, PROGMEM or EEMEM. The low level access is type-less. Applications may add run-time data-types by extending the item type system. Any type tag larger than BLOB may be used.
Definition at line 36 of file Registry.hh.
typedef const action_t* Registry::action_P |
Pointer to action item in program memory.
Definition at line 226 of file Registry.hh.
typedef const blob_t* Registry::blob_P |
Pointer to blob registry item in program memory.
Definition at line 264 of file Registry.hh.
typedef const item_list_t* Registry::item_list_P |
Pointer to item list in program memory.
Definition at line 133 of file Registry.hh.
typedef const item_t* Registry::item_P |
Pointer to item in program memory.
Definition at line 74 of file Registry.hh.
typedef const item_P* Registry::item_vec_P |
Pointer to vector of item pointers in program memory.
Definition at line 77 of file Registry.hh.
enum Registry::storage_t |
Storage type tags.
Enumerator | |
---|---|
IN_PROGMEM |
In program memory. |
IN_SRAM |
In data memory. |
IN_EEMEM |
In eeprom. |
Definition at line 52 of file Registry.hh.
enum Registry::type_t |
Registry item type tags.
Enumerator | |
---|---|
ITEM |
Item descriptor. |
ITEM_LIST |
List of items. |
ACTION |
Action function. |
BLOB |
General binary object. |
APPL |
Application binary object. |
Definition at line 41 of file Registry.hh.
|
inline |
Construct registery root object.
[in] | root | item list. |
[in] | eeprom | device driver (default internal EEPROM). |
Definition at line 340 of file Registry.hh.
|
inline |
Lookup registry item for given path and if the item is an action call the run() member function with the given argument block. Return error code(-1) if the path is not valid otherwise return value from run().
[in] | path | registry index sequence. |
[in] | count | number of bytes in path. |
[in,out] | buf | pointer to argument/result block. |
[in] | len | of argument block. |
Definition at line 367 of file Registry.hh.
|
inlinestatic |
Return number of items in item vector or negative error code.
[in] | list | pointer to item list in program memory. |
Definition at line 153 of file Registry.hh.
Return pointer to name string given pointer to item in program memory.
[in] | item | pointer to item in program memory. |
Definition at line 95 of file Registry.hh.
Return item storage type given pointer to item in program memory.
[in] | item | pointer to item in program memory. |
Definition at line 106 of file Registry.hh.
Return item type given pointer to item in program memory.
[in] | item | pointer to item in program memory. |
Definition at line 84 of file Registry.hh.
int Registry::get_value | ( | blob_P | blob, |
void * | buf, | ||
size_t | len | ||
) |
Copy blob value into given buffer with given maximum size (len). Return number of bytes copied into buffer or negative error code (EINVAL if illegal parameter, ENOBUFS if the buffer is too small for the stored data, ENXIO if storage is not recognized).
[in] | blob | pointer to blob in program memory. |
[out] | buf | pointer to buffer for value. |
[in] | len | number of bytes maximum in buffer. |
Definition at line 97 of file Registry.cpp.
|
inline |
Template function to copy blob value into given value storage of given type. Returns true(1) if successful otherwise false(0).
[in] | T | type of variable to copy. |
[in] | blob | pointer to blob in program memory. |
[out] | value | buffer. |
Definition at line 299 of file Registry.hh.
|
inlinestatic |
Return true if the item storage is readonly otherwise false.
[in] | item | pointer to item in program memory. |
Definition at line 117 of file Registry.hh.
Registry::item_P Registry::lookup | ( | const uint8_t * | path = NULL , |
size_t | count = 0 |
||
) |
Lookup registry item for given path. Returns pointer to item if found otherwise NULL. Default parameters will give root item.
[in] | path | registry index sequence (Default NULL). |
[in] | count | number of bytes in path (Default 0). |
Definition at line 24 of file Registry.cpp.
void Registry::print | ( | IOStream & | outs, |
const uint8_t * | path, | ||
size_t | count | ||
) |
Definition at line 54 of file Registry.cpp.
|
static |
Run the action item with the given argument block and given number of bytes. Return number of bytes in buffer (return value) or negative error code (EINVAL if illegal parameter, ENXIO if no object defined).
[in] | action | item. |
[in,out] | buf | argument/result buffer. |
[in] | size | number of bytes argument. |
Definition at line 82 of file Registry.cpp.
int Registry::set_value | ( | blob_P | blob, |
const void * | buf, | ||
size_t | len | ||
) |
Copy value in given buffer of given maximum size (len) to blob. Return number of bytes copied from buffer or negative error code (EINVAL if illegal parameter, EACCES if the blob is readonly, ENOBUFS if the buffer is too small for the stored data, ENXIO if storage is not recognized). The storage type must be SRAM or EEMEM.
[in] | blob | pointer to blob in program memory. |
[in] | buf | pointer to buffer with new value. |
[in] | len | number of bytes maximum in buffer. |
Definition at line 124 of file Registry.cpp.
|
inline |
Template function to copy given value of given type to blob. Return true(1) if successful otherwise false(0). The storage type must be SRAM or EEMEM.
[in] | T | value type. |
[in] | blob | pointer to blob in program memory. |
[in] | value | value to set. |
Definition at line 327 of file Registry.hh.
Type check given item pointer and convert to an action pointer. Returns a pointer to action item in program memory if successful otherwise NULL. This function provides run-time type checking.
[in] | item | pointer to item in program memory. |
Definition at line 235 of file Registry.hh.
Type check given item pointer and convert to a blob pointer. Returns pointer to blob registry item in program memory if successful otherwise NULL. This function provides run-time type checking.
[in] | item | pointer to item in program memory. |
Definition at line 274 of file Registry.hh.
|
inlinestatic |
Type check given item pointer and convert it to an item list. Return pointer to item list in program memory if successful otherwise NULL. This function provides run-time type checking.
[in] | item | pointer to item in program memory. |
Definition at line 142 of file Registry.hh.
|
static |
Max length of a path.
Definition at line 333 of file Registry.hh.
|
static |
Mask readonly bit of item attributes.
Definition at line 62 of file Registry.hh.
|
static |
Mask storage bits of item attributes.
Definition at line 59 of file Registry.hh.