X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4f0b473db654af3da6cc609b6d94b5b6d9652c4c..0b7d1f86375fc32d181c2ab574eed9dadee72db6:/src/mc/mc_client.h diff --git a/src/mc/mc_client.h b/src/mc/mc_client.h index c919dc8428..8ed4907dfe 100644 --- a/src/mc/mc_client.h +++ b/src/mc/mc_client.h @@ -4,33 +4,52 @@ /* 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. */ -#ifndef MC_CLIENT_H -#define MC_CLIENT_H - -#include -#include "mc_protocol.h" +#ifndef SIMGRID_MC_CLIENT_H +#define SIMGRID_MC_CLIENT_H + +#include + +#include + +#include + +#include "src/mc/mc_protocol.h" +#include "src/mc/Channel.hpp" + +namespace simgrid { +namespace mc { + +class XBT_PUBLIC() Client { +private: + bool active_ = false; + Channel channel_; + static std::unique_ptr client_; +public: + Client(); + Client(int fd) : active_(true), channel_(fd) {} + void handleMessages(); + Channel const& getChannel() const { return channel_; } + Channel& getChannel() { return channel_; } + void mainLoop(void); + + // Singleton :/ + // TODO, remove the singleton antipattern. + static Client* initialize(); + static Client* get() + { + return client_.get(); + } +}; + +} +} SG_BEGIN_DECL() -typedef struct s_mc_client { - int active; - int fd; -} s_mc_client_t, *mc_client_t; - -extern XBT_INTERNAL mc_client_t mc_client; - -XBT_INTERNAL void MC_client_init(void); -XBT_INTERNAL void MC_client_hello(void); -XBT_INTERNAL void MC_client_handle_messages(void); -XBT_INTERNAL void MC_client_send_message(void* message, size_t size); -XBT_INTERNAL void MC_client_send_simple_message(e_mc_message_type type); - -#ifdef HAVE_MC -void MC_ignore(void* addr, size_t size); +#if HAVE_MC +void MC_ignore(void* addr, std::size_t size); #endif -void MC_client_main_loop(void); - SG_END_DECL() #endif