Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
obsolete script: RuleBased routing was removed in v3.10
[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 <cstddef>
11
12 #include <memory>
13
14 #include <xbt/base.h>
15
16 #include <simgrid/simix.h>
17
18 #include "src/mc/mc_protocol.h"
19 #include "src/mc/Channel.hpp"
20
21 namespace simgrid {
22 namespace mc {
23
24 class XBT_PUBLIC() Client {
25 private:
26   bool active_ = false;
27   Channel channel_;
28   static std::unique_ptr<Client> client_;
29 public:
30   Client();
31   Client(int fd) : active_(true), channel_(fd) {}
32   void handleMessages();
33   Channel const& getChannel() const { return channel_; }
34   Channel& getChannel() { return channel_; }
35   void mainLoop(void);
36   void reportAssertionFailure(const char* description = nullptr);
37   void ignoreMemory(void* addr, std::size_t size);
38   void ignoreHeap(void* addr, std::size_t size);
39   void unignoreHeap(void* addr, std::size_t size);
40   void declareSymbol(const char *name, int* value);
41   void declareStack(void *stack, size_t size, smx_process_t process, ucontext_t* context);
42
43   // Singleton :/
44   // TODO, remove the singleton antipattern.
45   static Client* initialize();
46   static Client* get()
47   {
48     return client_.get();
49   }
50 };
51
52 }
53 }
54
55 SG_BEGIN_DECL()
56
57 #if HAVE_MC
58 void MC_ignore(void* addr, std::size_t size);
59 #endif
60
61 SG_END_DECL()
62
63 #endif