Use initializer 90/243190/2 accepted/tizen/unified/20200907.023458 submit/tizen/20200904.033548
authorYu <jiung.yu@samsung.com>
Fri, 4 Sep 2020 00:42:47 +0000 (09:42 +0900)
committerYu <jiung.yu@samsung.com>
Fri, 4 Sep 2020 00:45:53 +0000 (09:45 +0900)
Change-Id: I5a2fbb5f82d57128f9fc55fdd8ec639e253f93b7
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
include/Node.h
packaging/uwb-manager.spec
src/LocationManager.cpp
src/UwbDbusIfaceAdapter.cpp
src/UwbPosition.cpp
tests/uwb-manager-gtest.cpp

index 8baa2fd5b3543feadaea791fe6e3ab3862b31a31..000c92f0d3aa8495d97cb8f26517d052735b634f 100644 (file)
@@ -39,29 +39,17 @@ public:
                _is_remote(false), _is_calculated(false), _tech(TECH_UNKNOWN),
                _last_update(std::chrono::steady_clock::now()) {};
 
-       Node(unsigned long long distance, int pan_id, unsigned long long node_id,
-                       int x, int y, int z, bool is_remote, bool is_calculated, int tech) :
-               _distance(distance), _pan_id(pan_id), _node_id(node_id),
-               _x(x), _y(y), _z(z), _is_remote(is_remote), _is_calculated(is_calculated),
-               _tech(tech), _last_update(std::chrono::steady_clock::now()) {};
-
        Node(uwb_hpi_node_s *node) :
                _distance(node->distance), _pan_id(node->pan_id), _node_id(node->node_id),
                _x(node->x), _y(node->y), _z(node->z), _is_remote(node->is_remote),
                _is_calculated(false), _tech(TECH_UWB),
                _last_update(std::chrono::steady_clock::now()){};
-       Node(const Node *node) {
-               _distance = node->_distance;
-               _pan_id = node->_pan_id;
-               _node_id = node->_node_id;
-               _x = node->_x;
-               _y = node->_y;
-               _z = node->_z;
-               _is_remote = node->_is_remote;
-               _is_calculated = node->_is_calculated;
-               _tech = node->_tech;
-               _last_update = node->_last_update;
-       }
+
+       Node(Node *node) :
+               _distance(node->_distance), _pan_id(node->_pan_id), _node_id(node->_node_id),
+               _x(node->_x), _y(node->_y), _z(node->_z), _is_remote(node->_is_remote),
+               _is_calculated(node->_is_calculated), _tech(node->_tech),
+               _last_update(node->_last_update){};
 
        //~Node(){UWB_LOGI("%llu removed", _node_id);}
        Node(const Node &node) = default;
index fd697d783d51004dc25464bebb7e8b638d2bb30e..9664937b7d50541ec1fb75323675309459aeabc5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       uwb-manager
 Summary:    This is the daemon managing UWB related functionalities
-Version:    0.0.3
+Version:    0.0.4
 Release:    1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
index e9f98abe661d7311a6094b0f3d74421384f79dac..5d51634ba62fee857ffa2f32c48aa5f6453548a5 100644 (file)
@@ -344,7 +344,7 @@ void LocationManager::updateUwbNodes(void)
 
        p_node->setLastUpdate(std::chrono::steady_clock::now());
        this->_node_map[p_node->getNodeId()] =
-                       std::unique_ptr<Node>((Node *)new Node(p_node));
+                       std::unique_ptr<Node>((Node *)new Node{p_node});
 
        if (added) {
                if (this->_node_added_cb)
index 984afbb690b08825bc3256abb7607891af0afaf4..09b09e846408691b17d851bedd328579d8e99658 100644 (file)
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <utility>
 
 #include <uwb-log-def.h>
 #include <uwb-error-def.h>
@@ -499,36 +500,27 @@ static gboolean __handle_send_message_to(
        return TRUE;
 }
 
-typedef gboolean (*method_handler)(
-               UwbGdbuslibManager *gdbus_manager,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data);
+static std::pair<std::string, void *> handlers[] = {
+               std::make_pair(std::string{"handle-test"}, (void *)__handle_test),
+               std::make_pair(std::string{"handle-reset"}, (void *)__handle_reset),
+               std::make_pair(std::string{"handle-factory-reset"}, (void *)__handle_factory_reset),
 
-static struct {
-       const char *method_name;
-       //trick
-       void * handler;
-} handlers[] = {
-               {"handle-test", (void *)__handle_test},
-               {"handle-reset", (void *)__handle_reset},
-               {"handle-factory-reset", (void *)__handle_factory_reset},
+               std::make_pair(std::string{"handle-enable-network"}, (void *)__handle_enable_network),
+               std::make_pair(std::string{"handle-disable-network"}, (void *)__handle_disable_network),
 
-               {"handle-enable-network", (void *)__handle_enable_network},
-               {"handle-disable-network", (void *)__handle_disable_network},
+               std::make_pair(std::string{"handle-start-location-engine"}, (void *)__handle_start_location_engine),
+               std::make_pair(std::string{"handle-stop-location-engine"}, (void *)__handle_stop_location_engine),
 
-               {"handle-start-location-engine", (void *)__handle_start_location_engine},
-               {"handle-stop-location-engine", (void *)__handle_stop_location_engine},
+               std::make_pair(std::string{"handle-get-own-node"}, (void *)__handle_get_own_node),
+               std::make_pair(std::string{"handle-get-network-info"}, (void *)__handle_get_network_info),
 
-               {"handle-get-own-node", (void *)__handle_get_own_node},
-               {"handle-get-network-info", (void *)__handle_get_network_info},
+               std::make_pair(std::string{"handle-set-configurations"}, (void *)__handle_set_configurations),
+               std::make_pair(std::string{"handle-get-configurations"}, (void *)__handle_get_configurations),
 
-               {"handle-set-configurations", (void *)__handle_set_configurations},
-               {"handle-get-configurations", (void *)__handle_get_configurations},
+               std::make_pair(std::string{"handle-set-position"}, (void *)__handle_set_position),
 
-               {"handle-set-position", (void *)__handle_set_position},
-
-               {"handle-send-message", (void *)__handle_send_message},
-               {"handle-send-message-to", (void *)__handle_send_message_to}
+               std::make_pair(std::string{"handle-send-message"}, (void *)__handle_send_message),
+               std::make_pair(std::string{"handle-send-message-to"}, (void *)__handle_send_message_to)
 };
 
 void UwbDbusIfaceAdapter::init(GDBusConnection *connection,
@@ -540,8 +532,8 @@ void UwbDbusIfaceAdapter::init(GDBusConnection *connection,
        for (const auto &handler : handlers)
                g_signal_connect(
                                manager_skeleton,
-                               handler.method_name,
-                               G_CALLBACK(handler.handler),
+                               handler.first.c_str(),
+                               G_CALLBACK(handler.second),
                                gpointer(this));
 
        /* Set connection to 'manager' */
index 443aeda18c33e4777f8bfb2a8345820b74883272..e2b97b6efbc6235b5b8349b1c1b1989b4eac22c8 100644 (file)
@@ -33,7 +33,7 @@ int UwbPosition::updateUwbOwnNode()
        if (res != 0 || !own_node)
                return -1;
 
-       this->setOwnNode(Node(own_node));
+       this->setOwnNode(Node{own_node});
        free(own_node);
 
        return 0;
index e36938ec1da6b3fe5b30c7c1e8af26e2a4ae3788..9498b1bb4c2fd5091a9b437fcdbfda5d3252ba21 100644 (file)
@@ -733,8 +733,8 @@ TEST_F(UwbMqttMessageTest, create_location_uwb_mqtt_message_Positive)
        int test_x = 0x98ad;
        int test_y = 0x8234;
        int test_z = 0x2389;
-       UwbManagerNamespace::Node uwb_node(test_pan_id, test_node_id,
-                       test_x, test_y, test_z);
+       UwbManagerNamespace::Node uwb_node{test_pan_id, test_node_id,
+                       test_x, test_y, test_z};
        UwbManagerNamespace::UwbMqttMessage mqtt_msg(uwb_node);
 
        ASSERT_EQ(true, (std::string("/TIZEN/UWB/BROADCAST/") + std::to_string(test_node_id)) == mqtt_msg.getTopic());