X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2807fde4fd1f59c230d69a934634c5dfb77905f2..49e9f443f655fd07cc8ed1e4ad6ce329ded0fdc3:/src/mc/remote/Channel.hpp diff --git a/src/mc/remote/Channel.hpp b/src/mc/remote/Channel.hpp index 4553718330..da1f649ae1 100644 --- a/src/mc/remote/Channel.hpp +++ b/src/mc/remote/Channel.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2015-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -7,29 +6,22 @@ #ifndef SIMGRID_MC_CHANNEL_HPP #define SIMGRID_MC_CHANNEL_HPP -#include +#include "src/mc/remote/mc_protocol.h" #include -#include "src/mc/remote/mc_protocol.h" - -namespace simgrid { -namespace mc { +namespace simgrid::mc { -/** A channel for exchanging messages between model-checker and model-checked +/** A channel for exchanging messages between model-checker and model-checked app * * This abstracts away the way the messages are transferred. Currently, they * are sent over a (connected) `SOCK_SEQPACKET` socket. */ class Channel { int socket_ = -1; - template static constexpr bool messageType() - { - return std::is_class::value && std::is_trivial::value; - } + template static constexpr bool messageType() { return std::is_class_v && std::is_trivial_v; } public: - Channel() = default; explicit Channel(int sock) : socket_(sock) {} ~Channel(); @@ -37,38 +29,28 @@ public: Channel(Channel const&) = delete; Channel& operator=(Channel const&) = delete; - // Move: - Channel(Channel&& that) : socket_(that.socket_) { that.socket_ = -1; } - Channel& operator=(Channel&& that) - { - this->socket_ = that.socket_; - that.socket_ = -1; - return *this; - } - // Send int send(const void* message, size_t size) const; - int send(e_mc_message_type type) const + int send(MessageType type) const { s_mc_message_t message = {type}; return this->send(&message, sizeof(message)); } /** @brief Send a message; returns 0 on success or errno on failure */ - template typename std::enable_if(), int>::type send(M const& m) const + template typename std::enable_if_t(), int> send(M const& m) const { return this->send(&m, sizeof(M)); } // Receive - ssize_t receive(void* message, size_t size, bool block = true) const; - template typename std::enable_if(), ssize_t>::type receive(M& m) const + ssize_t receive(void* message, size_t size) const; + template typename std::enable_if_t(), ssize_t> receive(M& m) const { return this->receive(&m, sizeof(M)); } - int getSocket() const { return socket_; } + int get_socket() const { return socket_; } }; -} -} +} // namespace simgrid::mc #endif