From: Youngjae Shin Date: Thu, 18 Aug 2022 05:51:47 +0000 (+0900) Subject: add AittUtil for separating CompareTopic() X-Git-Tag: accepted/tizen/unified/20220921.091818~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69790688cc382fcadb92545af4cbab3bb6d1f66f;p=platform%2Fcore%2Fml%2Faitt.git add AittUtil for separating CompareTopic() --- diff --git a/common/AittUtil.cc b/common/AittUtil.cc new file mode 100644 index 0000000..c26dd47 --- /dev/null +++ b/common/AittUtil.cc @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "AittUtil.h" + +#include + +#include "AittException.h" +#include "aitt_internal.h" + +bool aitt::AittUtil::CompareTopic(const std::string& left, const std::string& right) +{ + bool result = false; + int ret = mosquitto_topic_matches_sub(left.c_str(), right.c_str(), &result); + if (ret != MOSQ_ERR_SUCCESS) { + ERR("mosquitto_topic_matches_sub(%s, %s) Fail(%s)", left.c_str(), right.c_str(), + mosquitto_strerror(ret)); + throw AittException(AittException::MQTT_ERR); + } + return result; +} diff --git a/common/AittUtil.h b/common/AittUtil.h new file mode 100644 index 0000000..4859fd6 --- /dev/null +++ b/common/AittUtil.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +namespace aitt { + +class AittUtil { + public: + AittUtil() = default; + ~AittUtil() = default; + + static bool CompareTopic(const std::string &left, const std::string &right); +}; + +} // namespace aitt diff --git a/modules/tcp/Module.cc b/modules/tcp/Module.cc index bc50d7d..b9b6774 100644 --- a/modules/tcp/Module.cc +++ b/modules/tcp/Module.cc @@ -15,7 +15,7 @@ */ #include "Module.h" -#include +#include #include #include @@ -77,7 +77,7 @@ void Module::Publish(const std::string &topic, const void *data, const size_t da for (PublishMap::iterator it = publishTable.begin(); it != publishTable.end(); ++it) { // NOTE: // Find entries that have matched with the given topic - if (!aitt::MQ::CompareTopic(it->first, topic)) + if (!aitt::AittUtil::CompareTopic(it->first, topic)) continue; // NOTE: