Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b4f95caa901140375231d487f37c92f6f233b8b9
[simgrid.git] / src / mc / Client.hpp
1 /* Copyright (c) 2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_CLIENT_H
8 #define SIMGRID_MC_CLIENT_H
9
10 #include "src/internal_config.h"
11
12 #include <cstddef>
13 #include <memory>
14
15 #include <xbt/base.h>
16
17 #include <simgrid/simix.h>
18
19 #include "src/mc/mc_protocol.h"
20 #include "src/mc/Channel.hpp"
21
22 namespace simgrid {
23 namespace mc {
24
25 class XBT_PUBLIC() Client {
26 private:
27   bool active_ = false;
28   Channel channel_;
29   static std::unique_ptr<Client> client_;
30 public:
31   Client();
32   Client(int fd) : active_(true), channel_(fd) {}
33   void handleMessages();
34   Channel const& getChannel() const { return channel_; }
35   Channel& getChannel() { return channel_; }
36   void mainLoop(void);
37   void reportAssertionFailure(const char* description = nullptr);
38   void ignoreMemory(void* addr, std::size_t size);
39   void ignoreHeap(void* addr, std::size_t size);
40   void unignoreHeap(void* addr, std::size_t size);
41   void declareSymbol(const char *name, int* value);
42 #if HAVE_UCONTEXT_H
43   void declareStack(void *stack, size_t size, smx_process_t process, ucontext_t* context);
44 #endif
45
46   // Singleton :/
47   // TODO, remove the singleton antipattern.
48   static Client* initialize();
49   static Client* get()
50   {
51     return client_.get();
52   }
53 };
54
55 }
56 }
57
58 SG_BEGIN_DECL()
59
60 #if HAVE_MC
61 void MC_ignore(void* addr, std::size_t size);
62 #endif
63
64 SG_END_DECL()
65
66 #endif