Skip to content

Commit b671199

Browse files
committed
redundant code removing
1 parent 86f1b9d commit b671199

2 files changed

Lines changed: 11 additions & 26 deletions

File tree

modules/mqtt_streaming_module/include/mqtt_streaming_module/mqtt_publisher_fb_impl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ class MqttPublisherFbImpl final : public FunctionBlock
112112
void validateInputPorts();
113113
void updateTopics();
114114
void updateSchema();
115-
template <typename retT, typename intfT>
116-
retT readProperty(const std::string& propertyName, const retT defaultValue);
117115
void runReaderThread();
118116
void readerLoop();
119117
void sendMessages(const MqttData& data);

modules/mqtt_streaming_module/src/mqtt_publisher_fb_impl.cpp

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <mqtt_streaming_module/mqtt_publisher_fb_impl.h>
66
#include <opendaq/binary_data_packet_factory.h>
77
#include <opendaq/event_packet_params.h>
8+
#include <mqtt_streaming_module/property_helper.h>
89

910
BEGIN_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE
1011

@@ -450,15 +451,16 @@ void MqttPublisherFbImpl::initProperties(const PropertyObjectPtr& config)
450451

451452
void MqttPublisherFbImpl::readProperties()
452453
{
453-
int tmpMode = readProperty<int, IInteger>(PROPERTY_NAME_PUB_MODE, 0);
454-
int tmpTopicMode = readProperty<int, IInteger>(PROPERTY_NAME_PUB_TOPIC_MODE, 0);
454+
using namespace property_helper;
455+
int tmpMode = readProperty<int, IInteger>(objPtr, PROPERTY_NAME_PUB_MODE, 0);
456+
int tmpTopicMode = readProperty<int, IInteger>(objPtr, PROPERTY_NAME_PUB_TOPIC_MODE, 0);
455457

456-
config.groupValues = readProperty<bool, IBoolean>(PROPERTY_NAME_PUB_GROUP_VALUES, false);
457-
int tmpValueFieldName = (readProperty<int, IInteger>(PROPERTY_NAME_PUB_VALUE_FIELD_NAME, 0));
458-
config.groupValuesPackSize = readProperty<size_t, IInteger>(PROPERTY_NAME_PUB_GROUP_VALUES_PACK_SIZE, DEFAULT_PUB_PACK_SIZE);
459-
config.qos = readProperty<int, IInteger>(PROPERTY_NAME_PUB_QOS, DEFAULT_PUB_QOS);
460-
config.periodMs = readProperty<int, IInteger>(PROPERTY_NAME_PUB_READ_PERIOD, DEFAULT_PUB_READ_PERIOD);
461-
config.topicName = readProperty<std::string, IString>(PROPERTY_NAME_PUB_TOPIC_NAME, globalId.toStdString());
458+
config.groupValues = readProperty<bool, IBoolean>(objPtr, PROPERTY_NAME_PUB_GROUP_VALUES, false);
459+
int tmpValueFieldName = (readProperty<int, IInteger>(objPtr, PROPERTY_NAME_PUB_VALUE_FIELD_NAME, 0));
460+
config.groupValuesPackSize = readProperty<size_t, IInteger>(objPtr, PROPERTY_NAME_PUB_GROUP_VALUES_PACK_SIZE, DEFAULT_PUB_PACK_SIZE);
461+
config.qos = readProperty<int, IInteger>(objPtr, PROPERTY_NAME_PUB_QOS, DEFAULT_PUB_QOS);
462+
config.periodMs = readProperty<int, IInteger>(objPtr, PROPERTY_NAME_PUB_READ_PERIOD, DEFAULT_PUB_READ_PERIOD);
463+
config.topicName = readProperty<std::string, IString>(objPtr, PROPERTY_NAME_PUB_TOPIC_NAME, globalId.toStdString());
462464

463465
settingErrors.clear();
464466
hasSettingError = false;
@@ -485,7 +487,7 @@ void MqttPublisherFbImpl::readProperties()
485487
settingErrors.push_back("Mode has invalid value.");
486488
}
487489

488-
config.enablePreview = (config.mode != PublisherMode::Raw) && readProperty<bool, IBoolean>(PROPERTY_NAME_PUB_PREVIEW_SIGNAL, false);
490+
config.enablePreview = (config.mode != PublisherMode::Raw) && readProperty<bool, IBoolean>(objPtr, PROPERTY_NAME_PUB_PREVIEW_SIGNAL, false);
489491

490492
if (tmpTopicMode < static_cast<int>(TopicMode::_count) && tmpTopicMode >= 0)
491493
{
@@ -528,21 +530,6 @@ void MqttPublisherFbImpl::readProperties()
528530
}
529531
}
530532

531-
template <typename retT, typename intfT>
532-
retT MqttPublisherFbImpl::readProperty(const std::string& propertyName, const retT defaultValue)
533-
{
534-
retT returnValue{};
535-
if (objPtr.hasProperty(propertyName))
536-
{
537-
auto property = objPtr.getPropertyValue(propertyName).asPtrOrNull<intfT>();
538-
if (property.assigned())
539-
{
540-
returnValue = property.getValue(defaultValue);
541-
}
542-
}
543-
return returnValue;
544-
}
545-
546533
void MqttPublisherFbImpl::runReaderThread()
547534
{
548535
LOGP_D("Using separate thread for rendering")

0 commit comments

Comments
 (0)