ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
Shared_Attribute_Callback.h
Go to the documentation of this file.
1#ifndef Shared_Attribute_Callback_h
2#define Shared_Attribute_Callback_h
3
4// Local includes.
5#include "Callback.h"
6#if !THINGSBOARD_ENABLE_DYNAMIC
7#include "Constants.h"
8#endif // !THINGSBOARD_ENABLE_DYNAMIC
9
10
14#if !THINGSBOARD_ENABLE_DYNAMIC
18template <size_t MaxAttributes = DEFAULT_ATTRIBUTES_AMOUNT>
19#endif // !THINGSBOARD_ENABLE_DYNAMIC
20class Shared_Attribute_Callback : public Callback<void, JsonObjectConst const &> {
21#if THINGSBOARD_ENABLE_DYNAMIC
23#else
25#endif // THINGSBOARD_ENABLE_DYNAMIC
26
27 public:
30
45 template<typename... Args>
46 Shared_Attribute_Callback(function callback, Args const &... args)
47 : Callback(callback)
48 , m_attributes(args...)
49 {
50 // Nothing to do
51 }
52
53 ~Shared_Attribute_Callback() override = default;
54
58 return m_attributes;
59 }
60
72 template<typename... Args>
73 void Set_Attributes(Args const &... args) {
74 m_attributes.assign(args...);
75 }
76
77 private:
78 CString_Container m_attributes = {}; // Shared attribute we want to subscribe to receive a message if they change
79};
80
81#endif // Shared_Attribute_Callback
General purpose safe callback wrapper. Expects either c-style or c++ style function pointer,...
Definition: Callback.h:30
std::function< void(argument_types... arguments)> function
Callback signature.
Definition: Callback.h:34
Custom std::array or std::vector implementation that contains a partial vector-like interface impleme...
Definition: Container.h:29
void assign(InputIterator const &first, InputIterator const &last)
Copies all elements from the given start to exclusively the given end iterator into the underlying da...
Definition: Container.h:129
Shared attribute update callback wrapper, contains the needed configuration settings to create the re...
Definition: Shared_Attribute_Callback.h:20
void Set_Attributes(Args const &... args)
Sets all the subscribed shared attributes that will result in the callback method being called if any...
Definition: Shared_Attribute_Callback.h:73
Shared_Attribute_Callback()=default
Constructs empty callback, will result in never being called. Internals are simply default constructe...
Shared_Attribute_Callback(function callback, Args const &... args)
Constructs callback, will be called upon shared attribute update arrival, where atleast one of the gi...
Definition: Shared_Attribute_Callback.h:46
CString_Container const & Get_Attributes() const
Gets all the subscribed shared attributes that will result in the callback method being called if any...
Definition: Shared_Attribute_Callback.h:57
~Shared_Attribute_Callback() override=default