MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / registerTopic

Method registerTopic

lib/TopicHandlerService/src/TopicHandlerService.cpp:273–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273void TopicHandlerService::registerTopic(const String& deviceId, const String& entityId, const String& topic, JsonObjectConst& jsonExtra, ITopicHandler::GetTopicFunc getTopicFunc, HasChangedFunc hasChangedFunc, ITopicHandler::SetTopicFunc setTopicFunc, ITopicHandler::UploadReqFunc uploadReqFunc)
274{
275 if ((false == deviceId.isEmpty()) &&
276 (false == topic.isEmpty()))
277 {
278 bool isReadAccess = false;
279 bool isWriteAccess = false;
280
281 /* Determine the kind of accessability. */
282 if (nullptr != getTopicFunc)
283 {
284 isReadAccess = true;
285 }
286
287 if ((nullptr != setTopicFunc) ||
288 (nullptr != uploadReqFunc))
289 {
290 isWriteAccess = true;
291 }
292
293 if ((true == isReadAccess) ||
294 (true == isWriteAccess))
295 {
296 uint8_t idx = 0U;
297 uint8_t count = 0U;
298 ITopicHandler** topicHandlerList = TopicHandlers::getList(count);
299
300 /* Register topic by every known topic handler. */
301 while (count > idx)
302 {
303 ITopicHandler* handler = topicHandlerList[idx];
304
305 if (nullptr != handler)
306 {
307 handler->registerTopic(deviceId, entityId, topic, jsonExtra, getTopicFunc, setTopicFunc, uploadReqFunc);
308 }
309
310 ++idx;
311 }
312
313 /* Store every readable topic in a list for automatic publishing on topic change,
314 * except topics from plugins. They will be considered separately.
315 */
316 if ((true == isReadAccess) &&
317 (nullptr != hasChangedFunc))
318 {
319 addToTopicMetaDataList(deviceId, entityId, nullptr, topic, hasChangedFunc);
320 }
321 }
322 }
323}
324
325void TopicHandlerService::registerTopic(const String& deviceId, const String& entityId, const String& topic, const char* extraFileName, ITopicHandler::GetTopicFunc getTopicFunc, HasChangedFunc hasChangedFunc, ITopicHandler::SetTopicFunc setTopicFunc, ITopicHandler::UploadReqFunc uploadReqFunc)
326{

Callers 1

startMethod · 0.45

Calls 2

isEmptyMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected