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

Method strToAccess

lib/TopicHandlerService/src/TopicHandlerService.cpp:385–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383 *****************************************************************************/
384
385void TopicHandlerService::strToAccess(IPluginMaintenance* plugin, const String& strAccess, ITopicHandler::GetTopicFunc& getTopicFunc, ITopicHandler::SetTopicFunc& setTopicFunc, ITopicHandler::UploadReqFunc& uploadReqFunc) const
386{
387 if (nullptr != plugin)
388 {
389 bool isReadAccess = false;
390 bool isWriteAccess = false;
391
392 if (true == strAccess.equalsIgnoreCase("rw"))
393 {
394 /* Read/Write access */
395 isReadAccess = true;
396 isWriteAccess = true;
397 }
398 else if (true == strAccess.equalsIgnoreCase("w"))
399 {
400 /* Write only access */
401 isWriteAccess = true;
402 }
403 else
404 {
405 /* Read only access */
406 isReadAccess = true;
407 }
408
409 if (true == isReadAccess)
410 {
411 getTopicFunc = [plugin](const String& topic, JsonObject& value) -> bool {
412 LOG_DEBUG("Get %s of plugin %u.", topic.c_str(), plugin->getUID());
413 return plugin->getTopic(topic, value);
414 };
415 }
416
417 if (true == isWriteAccess)
418 {
419 setTopicFunc = [plugin](const String& topic, const JsonObjectConst& value) -> bool {
420 LOG_DEBUG("Set %s of plugin %u.", topic.c_str(), plugin->getUID());
421 return plugin->setTopic(topic, value);
422 };
423
424 uploadReqFunc = [plugin](const String& topic, const String& srcFilename, String& dstFilename) -> bool {
425 return plugin->isUploadAccepted(topic, srcFilename, dstFilename);
426 };
427 }
428 }
429}
430
431void TopicHandlerService::addToTopicMetaDataList(const String& deviceId, const String& entityId, IPluginMaintenance* plugin, const String& topic, HasChangedFunc hasChangedFunc)
432{

Callers

nothing calls this directly

Calls 6

equalsIgnoreCaseMethod · 0.80
c_strMethod · 0.80
getUIDMethod · 0.80
getTopicMethod · 0.45
setTopicMethod · 0.45
isUploadAcceptedMethod · 0.45

Tested by

no test coverage detected