diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-05 18:39:13 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-05 18:42:30 +0200 |
commit | 8546fc68782d8a82a5c50a49ba1288dcb7714bf9 (patch) | |
tree | d9dff9295664b6d4aa9bf36c087edbc821d4ed36 /CAN-binder/low-can-binding/utils | |
parent | 3d3fbfd56b476a1f36bfc9cabf5a21f981d06844 (diff) |
Don't destroy socket by default as they will always be open.
Now derivated class use constructor from base class and we don't destroy
socket when a socket object is over since it may be copied before. So closing
them is in charge of dev, well me...
Change-Id: I0440119017a3e56bb83d0194a6908dc3e2b8f745
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/utils')
6 files changed, 9 insertions, 33 deletions
diff --git a/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp b/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp index d115f000..835f7242 100644 --- a/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp +++ b/CAN-binder/low-can-binding/utils/socketcan-bcm.cpp @@ -22,15 +22,6 @@ namespace utils { - /// @brief Construct a default, invalid, socket. - socketcan_bcm_t::socketcan_bcm_t() - : socketcan_t{} - {} - - /// @brief Destruct the socket. - socketcan_bcm_t::~socketcan_bcm_t() - {} - /// @brief Connect the socket. /// @return 0 if success. int socketcan_bcm_t::connect(const struct sockaddr* addr, socklen_t len) diff --git a/CAN-binder/low-can-binding/utils/socketcan-bcm.hpp b/CAN-binder/low-can-binding/utils/socketcan-bcm.hpp index c0a1bb2e..deb30c69 100644 --- a/CAN-binder/low-can-binding/utils/socketcan-bcm.hpp +++ b/CAN-binder/low-can-binding/utils/socketcan-bcm.hpp @@ -37,10 +37,7 @@ namespace utils class socketcan_bcm_t : public socketcan_t { public: - socketcan_bcm_t(); - socketcan_bcm_t(const socketcan_bcm_t&); - socketcan_bcm_t(socketcan_bcm_t&&); - virtual ~socketcan_bcm_t(); + using socketcan_t::socketcan_t; virtual int open(std::string device_name); diff --git a/CAN-binder/low-can-binding/utils/socketcan-raw.cpp b/CAN-binder/low-can-binding/utils/socketcan-raw.cpp index 23f83322..589f6abc 100644 --- a/CAN-binder/low-can-binding/utils/socketcan-raw.cpp +++ b/CAN-binder/low-can-binding/utils/socketcan-raw.cpp @@ -22,15 +22,6 @@ namespace utils { - /// @brief Construct a default, invalid, socket. - socketcan_raw_t::socketcan_raw_t() - : socketcan_t{} - {} - - /// @brief Destruct the socket. - socketcan_raw_t::~socketcan_raw_t() - {} - /// @brief Bind the socket. /// @return 0 if success. int socketcan_raw_t::bind(const struct sockaddr* addr, socklen_t len) diff --git a/CAN-binder/low-can-binding/utils/socketcan-raw.hpp b/CAN-binder/low-can-binding/utils/socketcan-raw.hpp index 71573da4..e18ff1f2 100644 --- a/CAN-binder/low-can-binding/utils/socketcan-raw.hpp +++ b/CAN-binder/low-can-binding/utils/socketcan-raw.hpp @@ -23,11 +23,7 @@ namespace utils class socketcan_raw_t : public socketcan_t { public: - socketcan_raw_t(); - socketcan_raw_t(const socketcan_raw_t&); - socketcan_raw_t(socketcan_raw_t&&); - virtual ~socketcan_raw_t(); - + using socketcan_t::socketcan_t; virtual int open(std::string device_name); private: diff --git a/CAN-binder/low-can-binding/utils/socketcan.cpp b/CAN-binder/low-can-binding/utils/socketcan.cpp index 4d226547..f52aaa6d 100644 --- a/CAN-binder/low-can-binding/utils/socketcan.cpp +++ b/CAN-binder/low-can-binding/utils/socketcan.cpp @@ -31,6 +31,11 @@ namespace utils : socket_{INVALID_SOCKET} {} + /// @brief Construct a socket by copying an existing one. + socketcan_t::socketcan_t(const socketcan_t& s) + : socket_{s.socket_} + {} + /// @brief Construct a socket by moving an existing one. socketcan_t::socketcan_t(socketcan_t&& s) : socket_{s.socket_} @@ -38,12 +43,8 @@ namespace utils s.socket_ = INVALID_SOCKET; } - /// @brief Destruct the socket. socketcan_t::~socketcan_t() - { - if(socket_ != INVALID_SOCKET) - ::close(socket_); - } + {} const struct sockaddr_can& socketcan_t::get_tx_address() const { diff --git a/CAN-binder/low-can-binding/utils/socketcan.hpp b/CAN-binder/low-can-binding/utils/socketcan.hpp index e9116643..76b5121b 100644 --- a/CAN-binder/low-can-binding/utils/socketcan.hpp +++ b/CAN-binder/low-can-binding/utils/socketcan.hpp @@ -34,7 +34,7 @@ namespace utils { public: socketcan_t(); - socketcan_t(const socketcan_t&); + socketcan_t(const socketcan_t& s); socketcan_t(socketcan_t&&); virtual ~socketcan_t(); |