ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Shared_Attribute_Callback< MaxAttributes > Class Template Reference

Shared attribute update callback wrapper, contains the needed configuration settings to create the request that should be sent to the server. Documentation about the specific use of shared attribute update in ThingsBoard can be found here https://thingsboard.io/docs/reference/mqtt-api/#subscribe-to-attribute-updates-from-the-server. More...

#include <Shared_Attribute_Callback.h>

Inheritance diagram for Shared_Attribute_Callback< MaxAttributes >:
[legend]
Collaboration diagram for Shared_Attribute_Callback< MaxAttributes >:
[legend]

Public Member Functions

 Shared_Attribute_Callback ()=default
 Constructs empty callback, will result in never being called. Internals are simply default constructed as nullptr. More...
 
template<typename... Args>
 Shared_Attribute_Callback (function callback, Args const &... args)
 Constructs callback, will be called upon shared attribute update arrival, where atleast one of the given multiple shared attributes subscribed was updated by the cloud. More...
 
 ~Shared_Attribute_Callback () override=default
 
CString_Container const & Get_Attributes () const
 Gets all the subscribed shared attributes that will result in the callback method being called if any of those attributes values is changed by the cloud. More...
 
template<typename... Args>
void Set_Attributes (Args const &... args)
 Sets all the subscribed shared attributes that will result in the callback method being called if any of those attributes values is changed by the cloud. More...
 
- Public Member Functions inherited from Callback< void, JsonObjectConst const & >
 Callback ()=default
 Constructs empty callback, will result in never being called. Internals are simply default constructed as nullptr. More...
 
 Callback (function callback)
 Constructor. More...
 
virtual ~Callback ()=default
 Virtual default destructor, created to ensure that if a pointer to this class is used and deleted, we will also call the derived base class destructor. More...
 
void Call_Callback (argument_types const &... arguments) const
 Calls the callback that was subscribed, when this class instance was initally created. More...
 
void Set_Callback (function callback)
 Sets the callback method that will be called upon data arrival with the given data that was received. If nullptr is passed the callback will never be called and instead return with a defaulted instance of the requested return variable. More...
 

Additional Inherited Members

- Public Types inherited from Callback< void, JsonObjectConst const & >
using function = std::function< void(argument_types... arguments)>
 Callback signature. More...
 

Detailed Description

template<size_t MaxAttributes = DEFAULT_ATTRIBUTES_AMOUNT>
class Shared_Attribute_Callback< MaxAttributes >

Shared attribute update callback wrapper, contains the needed configuration settings to create the request that should be sent to the server. Documentation about the specific use of shared attribute update in ThingsBoard can be found here https://thingsboard.io/docs/reference/mqtt-api/#subscribe-to-attribute-updates-from-the-server.

Template Parameters
MaxAttributesMaximum amount of attributes that will ever be requested with this instance of the class, allows to use an array on the stack in the background. Be aware though the size set in this template and the size passed to the ThingsBoard MaxAttributes template need to be the same or the value in this class lower, if not some of the requested keys may be lost, default = DEFAULT_ATTRIBUTES_AMOUNT (1)

Constructor & Destructor Documentation

◆ Shared_Attribute_Callback() [1/2]

template<size_t MaxAttributes = DEFAULT_ATTRIBUTES_AMOUNT>
Shared_Attribute_Callback< MaxAttributes >::Shared_Attribute_Callback ( )
default

Constructs empty callback, will result in never being called. Internals are simply default constructed as nullptr.

◆ Shared_Attribute_Callback() [2/2]

template<size_t MaxAttributes = DEFAULT_ATTRIBUTES_AMOUNT>
template<typename... Args>
Shared_Attribute_Callback< MaxAttributes >::Shared_Attribute_Callback ( function  callback,
Args const &...  args 
)
inline

Constructs callback, will be called upon shared attribute update arrival, where atleast one of the given multiple shared attributes subscribed was updated by the cloud.

Note
If the update does not include any of the given shared attributes the callback is not called.
Directly forwards the given arguments to the overloaded Container constructor, meaning all combinatons of arguments that would initalize an std::vector can be used to call this constructor. See possible std::vector constructors here https://en.cppreference.com/w/cpp/container/vector/vector, for the possible passable parameters. The possibilites mainly consist out of the fill constructor, where a number n and a value is given and then the value is copied into that many elements, alternatively if no value is given the default constructed value is copied n times instead, or the range constructor where we can pass an interator to the start and to the end of the data container (last element + 1) to copy every element in between thoose iterators, in the same order as in the original data container. The last option is a copy constructor where we pass another container and all the values of that container will be copied into our buffer
Template Parameters
...ArgsHolds the multiple arguments that will simply be forwarded to the container constructor and therefore allow to use every overloaded constructor without having to explicitly implement them
Parameters
callbackcallback method that will be called upon data arrival with the given data that was received. If nullptr is passed the callback will never be called and instead return with a defaulted instance of the requested return variable
...argsAttributes to suscribe, that will be forwarded into the overloaded Container constructor see https://en.cppreference.com/w/cpp/container/vector/vector for more information

◆ ~Shared_Attribute_Callback()

template<size_t MaxAttributes = DEFAULT_ATTRIBUTES_AMOUNT>
Shared_Attribute_Callback< MaxAttributes >::~Shared_Attribute_Callback ( )
overridedefault

Member Function Documentation

◆ Get_Attributes()

template<size_t MaxAttributes = DEFAULT_ATTRIBUTES_AMOUNT>
CString_Container const & Shared_Attribute_Callback< MaxAttributes >::Get_Attributes ( ) const
inline

Gets all the subscribed shared attributes that will result in the callback method being called if any of those attributes values is changed by the cloud.

Returns
Subscribed shared attributes

◆ Set_Attributes()

template<size_t MaxAttributes = DEFAULT_ATTRIBUTES_AMOUNT>
template<typename... Args>
void Shared_Attribute_Callback< MaxAttributes >::Set_Attributes ( Args const &...  args)
inline

Sets all the subscribed shared attributes that will result in the callback method being called if any of those attributes values is changed by the cloud.

Note
Directly forwards the given arguments to the overloaded Container constructor, meaning all combinatons of arguments that would initalize an std::vector can be used to call this constructor. See possible std::vector constructors here https://en.cppreference.com/w/cpp/container/vector/vector, for the possible passable parameters. The possibilites mainly consist out of the fill constructor, where a number n and a value is given and then the value is copied into that many elements, alternatively if no value is given the default constructed value is copied n times instead, or the range constructor where we can pass an interator to the start and to the end of the data container (last element + 1) to copy every element in between thoose iterators, in the same order as in the original data container. The last option is a copy constructor where we pass another container and all the values of that container will be copied into our buffer
Template Parameters
...ArgsHolds the multiple arguments that will simply be forwarded to the Container assign method and therefore allow to use every overloaded Container assign without having to implement them
Parameters
...argsAttributes to subscribe, that will be forwarded into the overloaded Container assign method see https://en.cppreference.com/w/cpp/container/vector/assign for more information

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