Zigbee Protocol Controller 1.6.0
StoreAccessor< search_key_t, data_t > Class Template Reference

Template class for accessing entities using the attribute store API. More...

#include <zigpc_datastore_accessor.hpp>

Public Member Functions

 StoreAccessor (attribute_store_type_t node_type, std::string label)
 
virtual ~StoreAccessor ()=default
 
std::string get_label (void) const
 
attribute_store_type_t get_node_type (void) const
 
attribute_store_node_t find (attribute_store_node_t parent, search_key_t key)
 Find an entity based based on the key. More...
 
size_t child_count (attribute_store_node_t parent, search_key_t key, attribute_store_type_t child_type)
 Retrive the count of child entities by type. More...
 
sl_status_t find_by_index (attribute_store_node_t parent, size_t index, search_key_t *key)
 Find the search key of the child entity based on the index. More...
 
sl_status_t create (attribute_store_node_t parent, search_key_t key)
 Create a new entity based on the search key. More...
 
sl_status_t read (attribute_store_node_t parent, search_key_t key, data_t *const data)
 Read information of the entity. More...
 
sl_status_t write (attribute_store_node_t parent, search_key_t key, const data_t *data)
 Write information to the entity. More...
 
sl_status_t remove (attribute_store_node_t parent, search_key_t key)
 Remove the entity from the store. More...
 
sl_status_t remove_children (attribute_store_node_t parent, search_key_t key)
 Remove all child entities from the store. More...
 
virtual std::string to_str (attribute_store_node_t parent, search_key_t key)
 Get string representation of entity in byte buffer representation. More...
 

Private Attributes

attribute_store_type_t node_type
 
std::string label
 

Detailed Description

template<typename search_key_t, typename data_t>
class StoreAccessor< search_key_t, data_t >

Template class for accessing entities using the attribute store API.

NOTE: The serach_key_t for every entity type uses the desired field of an attribute store node while the data_t is stored using the reported field of an attribute store node. Having the search_key_t contained in the desired field allows the component to search for attribute store nodes by the desired key value.

Template Parameters
search_key_tkey type to be stored in the attribute store node's desired field and used for searching.
data_tdata to be stored in the attribute store node's reported field.

Constructor & Destructor Documentation

◆ StoreAccessor()

template<typename search_key_t , typename data_t >
StoreAccessor< search_key_t, data_t >::StoreAccessor ( attribute_store_type_t  node_type,
std::string  label 
)
inlineexplicit

◆ ~StoreAccessor()

template<typename search_key_t , typename data_t >
virtual StoreAccessor< search_key_t, data_t >::~StoreAccessor ( )
virtualdefault

Member Function Documentation

◆ child_count()

template<typename search_key_t , typename data_t >
size_t StoreAccessor< search_key_t, data_t >::child_count ( attribute_store_node_t  parent,
search_key_t  key,
attribute_store_type_t  child_type 
)
inline

Retrive the count of child entities by type.

Parameters
parentParent node ID to look under.
keySearch key to find entity node under parent.
typeChild node type to find under entity.
Returns
size_t 0 if no children are found, else the child count.

◆ create()

template<typename search_key_t , typename data_t >
sl_status_t StoreAccessor< search_key_t, data_t >::create ( attribute_store_node_t  parent,
search_key_t  key 
)
inline

Create a new entity based on the search key.

Parameters
parent
key
Returns
sl_status_t SL_STATUS_OK if creation process succeeded, SL_STATUS_ALREADY_EXISTS if the entity already exists, or SL_STATUS_FAIL if the create process failed.

◆ find()

template<typename search_key_t , typename data_t >
attribute_store_node_t StoreAccessor< search_key_t, data_t >::find ( attribute_store_node_t  parent,
search_key_t  key 
)
inline

Find an entity based based on the key.

Parameters
parent
key
Returns
attribute_store_node_t ATTRIBUTE_STORE_INVALID_NODE if not found, else the attribute node ID is returned.

◆ find_by_index()

template<typename search_key_t , typename data_t >
sl_status_t StoreAccessor< search_key_t, data_t >::find_by_index ( attribute_store_node_t  parent,
size_t  index,
search_key_t *  key 
)
inline

Find the search key of the child entity based on the index.

Parameters
parent
index
key
Returns
sl_status_t SL_STATUS_OK if found and search key is populated, SL_STATUS_NOT_FOUND if the entity is not found, or SL_STATUS_FAIL if reading search key failed.

◆ get_label()

template<typename search_key_t , typename data_t >
std::string StoreAccessor< search_key_t, data_t >::get_label ( void  ) const
inline

◆ get_node_type()

template<typename search_key_t , typename data_t >
attribute_store_type_t StoreAccessor< search_key_t, data_t >::get_node_type ( void  ) const
inline

◆ read()

template<typename search_key_t , typename data_t >
sl_status_t StoreAccessor< search_key_t, data_t >::read ( attribute_store_node_t  parent,
search_key_t  key,
data_t *const  data 
)
inline

Read information of the entity.

Parameters
parent
key
data
Returns
sl_status_t SL_STATUS_OK if entity is read successfully, SL_STATUS_NULL_POINTER if invalid data parameter to populate is provided, SL_STATUS_NOT_FOUND if the entity is not found, or SL_STATUS_FAIL if the read process failed.

◆ remove()

template<typename search_key_t , typename data_t >
sl_status_t StoreAccessor< search_key_t, data_t >::remove ( attribute_store_node_t  parent,
search_key_t  key 
)
inline

Remove the entity from the store.

Parameters
parent
key
Returns
sl_status_t SL_STATUS_OK if entity is deleted successfully, SL_STATUS_NOT_FOUND if the entity is not found, or SL_STATUS_FAIL if the delete process failed.

◆ remove_children()

template<typename search_key_t , typename data_t >
sl_status_t StoreAccessor< search_key_t, data_t >::remove_children ( attribute_store_node_t  parent,
search_key_t  key 
)
inline

Remove all child entities from the store.

Parameters
parent
key
Returns
sl_status_t SL_STATUS_OK if child entities are deleted successfully, SL_STATUS_NOT_FOUND if the entity is not found, or SL_STATUS_FAIL if the delete process failed.

◆ to_str()

template<typename search_key_t , typename data_t >
virtual std::string StoreAccessor< search_key_t, data_t >::to_str ( attribute_store_node_t  parent,
search_key_t  key 
)
inlinevirtual

Get string representation of entity in byte buffer representation.

NOTE: Can be overriden.

Parameters
parent
key
Returns
std::string

Reimplemented in NetworkAccessor, ClusterAccessor, EndpointAccessor, DeviceAccessor, and GroupAccessor.

◆ write()

template<typename search_key_t , typename data_t >
sl_status_t StoreAccessor< search_key_t, data_t >::write ( attribute_store_node_t  parent,
search_key_t  key,
const data_t *  data 
)
inline

Write information to the entity.

Parameters
parent
key
data
Returns
sl_status_t SL_STATUS_OK if entity is written successfully, SL_STATUS_NULL_POINTER if invalid data parameter to write is provided, SL_STATUS_NOT_FOUND if the entity is not found, or SL_STATUS_FAIL if the write process failed.

Member Data Documentation

◆ label

template<typename search_key_t , typename data_t >
std::string StoreAccessor< search_key_t, data_t >::label
private

Entity label to use in logs

◆ node_type

template<typename search_key_t , typename data_t >
attribute_store_type_t StoreAccessor< search_key_t, data_t >::node_type
private

Entity type to be used


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