diff options
Diffstat (limited to 'libtransport')
9 files changed, 27 insertions, 73 deletions
diff --git a/libtransport/includes/hicn/transport/core/connector.h b/libtransport/includes/hicn/transport/core/connector.h index eaf95b2ec..be191fb4a 100644 --- a/libtransport/includes/hicn/transport/core/connector.h +++ b/libtransport/includes/hicn/transport/core/connector.h @@ -73,29 +73,26 @@ class Connector : public std::enable_shared_from_this<Connector> { typename OnReconnect> Connector(ReceiveCallback &&receive_callback, SentCallback &&packet_sent, OnClose &&close_callback, OnReconnect &&on_reconnect) - : receive_callback_(std::forward<ReceiveCallback &&>(receive_callback)), - sent_callback_(std::forward<SentCallback &&>(packet_sent)), - on_close_callback_(std::forward<OnClose &&>(close_callback)), - on_reconnect_callback_(std::forward<OnReconnect &&>(on_reconnect)), - state_(State::CLOSED), - connector_id_(invalid_connector), - connection_reattempts_(0) {} + : receive_callback_(std::forward<ReceiveCallback>(receive_callback)), + sent_callback_(std::forward<SentCallback>(packet_sent)), + on_close_callback_(std::forward<OnClose>(close_callback)), + on_reconnect_callback_(std::forward<OnReconnect>(on_reconnect)) {} virtual ~Connector(){}; template <typename ReceiveCallback> void setReceiveCallback(ReceiveCallback &&callback) { - receive_callback_ = std::forward<ReceiveCallback &&>(callback); + receive_callback_ = std::forward<ReceiveCallback>(callback); } template <typename SentCallback> void setSentCallback(SentCallback &&callback) { - sent_callback_ = std::forward<SentCallback &&>(callback); + sent_callback_ = std::forward<SentCallback>(callback); } template <typename OnClose> void setOnCloseCallback(OnClose &&callback) { - on_close_callback_ = std::forward<OnClose &&>(callback); + on_close_callback_ = std::forward<OnClose>(callback); } template <typename OnReconnect> @@ -137,24 +134,24 @@ class Connector : public std::enable_shared_from_this<Connector> { Id getConnectorId() { return connector_id_; } - void setConnectorName(std::string connector_name) { + void setConnectorName(const std::string &connector_name) { connector_name_ = connector_name; } - std::string getConnectorName() { return connector_name_; } + std::string getConnectorName() const { return connector_name_; } template <typename EP> void setLocalEndpoint(EP &&endpoint) { local_endpoint_ = std::forward<EP>(endpoint); } - Endpoint getLocalEndpoint() { return local_endpoint_; } + Endpoint getLocalEndpoint() const { return local_endpoint_; } - Endpoint getRemoteEndpoint() { return remote_endpoint_; } + Endpoint getRemoteEndpoint() const { return remote_endpoint_; } void setRole(Role r) { role_ = r; } - Role getRole() { return role_; } + Role getRole() const { return role_; } static utils::MemBuf::Ptr getPacketFromBuffer(uint8_t *buffer, std::size_t size) { @@ -213,8 +210,8 @@ class Connector : public std::enable_shared_from_this<Connector> { OnReconnectCallback on_reconnect_callback_; // Connector state - std::atomic<State> state_; - Id connector_id_; + std::atomic<State> state_ = State::CLOSED; + Id connector_id_ = invalid_connector; // Endpoints Endpoint local_endpoint_; @@ -230,7 +227,7 @@ class Connector : public std::enable_shared_from_this<Connector> { AtomicConnectorStats stats_; // Connection attempts - std::uint32_t connection_reattempts_; + std::uint32_t connection_reattempts_ = 0; }; } // namespace core diff --git a/libtransport/includes/hicn/transport/core/endpoint.h b/libtransport/includes/hicn/transport/core/endpoint.h index e1fa193d7..2278a1759 100644 --- a/libtransport/includes/hicn/transport/core/endpoint.h +++ b/libtransport/includes/hicn/transport/core/endpoint.h @@ -62,8 +62,8 @@ class Endpoint { #if 0 template <typename Ip, typename Port> Endpoint(Ip &&ip_address, Port &&port) - : address_(std::forward<Ip &&>(ip_address)), - port_(std::forward<Port &&>(port)) {} + : address_(std::forward<Ip>(ip_address)), + port_(std::forward<Port>(port)) {} #endif asio::ip::address getAddress() { return address_; } diff --git a/libtransport/includes/hicn/transport/core/interest.h b/libtransport/includes/hicn/transport/core/interest.h index 428829697..59da5b91f 100644 --- a/libtransport/includes/hicn/transport/core/interest.h +++ b/libtransport/includes/hicn/transport/core/interest.h @@ -88,7 +88,7 @@ class Interest uint32_t getLifetime() const override; - bool hasManifest(); + bool hasManifest() const; void appendSuffix(std::uint32_t suffix); diff --git a/libtransport/includes/hicn/transport/interfaces/publication_options.h b/libtransport/includes/hicn/transport/interfaces/publication_options.h index 03a0763f5..f4f409d00 100644 --- a/libtransport/includes/hicn/transport/interfaces/publication_options.h +++ b/libtransport/includes/hicn/transport/interfaces/publication_options.h @@ -25,7 +25,7 @@ class PublicationOptions { public: template <typename T> PublicationOptions(T&& name, uint32_t lifetime) - : name_(std::forward<T&&>(name)), + : name_(std::forward<T>(name)), content_lifetime_milliseconds_(lifetime) {} TRANSPORT_ALWAYS_INLINE const core::Name& getName() const { return name_; } diff --git a/libtransport/includes/hicn/transport/utils/CMakeLists.txt b/libtransport/includes/hicn/transport/utils/CMakeLists.txt index bbd149e09..1dba94451 100644 --- a/libtransport/includes/hicn/transport/utils/CMakeLists.txt +++ b/libtransport/includes/hicn/transport/utils/CMakeLists.txt @@ -32,7 +32,6 @@ list(APPEND HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/string_utils.h ${CMAKE_CURRENT_SOURCE_DIR}/file.h ${CMAKE_CURRENT_SOURCE_DIR}/shared_ptr_utils.h - ${CMAKE_CURRENT_SOURCE_DIR}/move_wrapper.h ${CMAKE_CURRENT_SOURCE_DIR}/noncopyable.h ${CMAKE_CURRENT_SOURCE_DIR}/singleton.h ) diff --git a/libtransport/includes/hicn/transport/utils/move_wrapper.h b/libtransport/includes/hicn/transport/utils/move_wrapper.h deleted file mode 100644 index 73389948d..000000000 --- a/libtransport/includes/hicn/transport/utils/move_wrapper.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 Cisco and/or its affiliates. - * - * 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 <type_traits> - -namespace utils { - -template <typename F> -struct MoveWrapper : F { - MoveWrapper(F&& f) : F(std::move(f)) {} - ~MoveWrapper() = default; - - MoveWrapper(MoveWrapper&&) = default; - MoveWrapper& operator=(MoveWrapper&&) = default; - - MoveWrapper(const MoveWrapper&); - MoveWrapper& operator=(const MoveWrapper&); -}; - -template <typename T> -auto moveHandler(T&& t) -> MoveWrapper<typename std::decay<T>::type> { - return std::move(t); -} -} // namespace utils
\ No newline at end of file diff --git a/libtransport/src/core/interest.cc b/libtransport/src/core/interest.cc index 10e1a6dfa..6348a8d3e 100644 --- a/libtransport/src/core/interest.cc +++ b/libtransport/src/core/interest.cc @@ -76,14 +76,13 @@ Interest &Interest::operator=(const Interest &other) { return (Interest &)Packet::operator=(other); } -Interest::~Interest() {} +Interest::~Interest() = default; const Name &Interest::getName() const { - if (!name_) { - if (hicn_interest_get_name( - &pkbuf_, (hicn_name_t *)&name_.getConstStructReference()) < 0) { - throw errors::MalformedPacketException(); - } + if (!name_ && + hicn_interest_get_name( + &pkbuf_, (hicn_name_t *)&name_.getConstStructReference()) < 0) { + throw errors::MalformedPacketException(); } return name_; @@ -149,7 +148,7 @@ void Interest::resetForHash() { } } -bool Interest::hasManifest() { +bool Interest::hasManifest() const { return (getPayloadType() == PayloadType::MANIFEST); } @@ -174,8 +173,7 @@ void Interest::encodeSuffixes() { memset(int_manifest_header->request_bitmap, 0xFFFFFFFF, BITMAP_SIZE * sizeof(hicn_uword)); - uint32_t *suffix = (uint32_t *)(int_manifest_header + 1); - for (auto it = suffix_set_.begin(); it != suffix_set_.end(); it++, suffix++) { + for (auto it = suffix_set_.begin(); it != suffix_set_.end(); it++) { interest_manifest_add_suffix(int_manifest_header, *it); } diff --git a/libtransport/src/core/local_connector.h b/libtransport/src/core/local_connector.h index 963f455e6..bf64b71d6 100644 --- a/libtransport/src/core/local_connector.h +++ b/libtransport/src/core/local_connector.h @@ -20,7 +20,6 @@ #include <hicn/transport/core/connector.h> #include <hicn/transport/core/global_object_pool.h> #include <hicn/transport/errors/not_implemented_exception.h> -#include <hicn/transport/utils/move_wrapper.h> #include <hicn/transport/utils/shared_ptr_utils.h> #include <io_modules/forwarder/errors.h> diff --git a/libtransport/src/core/portal.h b/libtransport/src/core/portal.h index 7a6ab9d0e..c4ba096b9 100644 --- a/libtransport/src/core/portal.h +++ b/libtransport/src/core/portal.h @@ -56,7 +56,7 @@ class HandlerMemory { HandlerMemory(const HandlerMemory &) = delete; HandlerMemory &operator=(const HandlerMemory &) = delete; - void *allocate(std::size_t size) { + void *allocate(std::size_t /* size */) { return utils::FixedBlockAllocator<128, 8192>::getInstance().allocateBlock(); } |