Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Declare functions "const" (round #2).
[simgrid.git] / src / mc / remote / AppSide.hpp
1 /* mc::remote::AppSide: the Application-side of the channel                 */
2
3 /* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef SIMGRID_MC_CLIENT_H
9 #define SIMGRID_MC_CLIENT_H
10
11 #include "src/mc/remote/Channel.hpp"
12
13 #include <memory>
14
15 namespace simgrid {
16 namespace mc {
17
18 /** Model-checked-side of the communication protocol
19  *
20  *  Send messages to the model-checker and handles message from it.
21  */
22 class XBT_PUBLIC AppSide {
23 private:
24   Channel channel_;
25   static std::unique_ptr<AppSide> instance_;
26
27 public:
28   AppSide();
29   explicit AppSide(int fd) : channel_(fd) {}
30   void handle_messages() const;
31
32 private:
33   void handle_deadlock_check(const s_mc_message_t* msg) const;
34   void handle_continue(const s_mc_message_t* msg) const;
35   void handle_simcall(const s_mc_message_simcall_handle_t* message) const;
36   void handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const;
37
38 public:
39   Channel const& get_channel() const { return channel_; }
40   Channel& get_channel() { return channel_; }
41   XBT_ATTRIB_NORETURN void main_loop();
42   void report_assertion_failure() const;
43   void ignore_memory(void* addr, std::size_t size) const;
44   void ignore_heap(void* addr, std::size_t size) const;
45   void unignore_heap(void* addr, std::size_t size) const;
46   void declare_symbol(const char* name, int* value) const;
47 #if HAVE_UCONTEXT_H
48   void declare_stack(void* stack, size_t size, ucontext_t* context) const;
49 #endif
50
51   // Singleton :/
52   // TODO, remove the singleton antipattern.
53   static AppSide* initialize();
54   static AppSide* get() { return instance_.get(); }
55 };
56 } // namespace mc
57 } // namespace simgrid
58
59 #endif