summaryrefslogtreecommitdiff
path: root/src/server.hh
blob: 0601ba899d26a3e1c10fc7546a9a6be35c80fbbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef SERVER_HH
#define SERVER_HH

#include "bt.hh"
#include "cfg.hh"
#include "http.hh"
#include "logger.hh"
#include "looper.hh"

#include <memory>
#include <string_view>

namespace server {

class Api : public bt::Manager::Delegate {
 public:
  virtual ~Api() = default;

  [[nodiscard]]
  virtual bt::Adapter* adapter() const = 0;

 protected:
  Api() = default;
};

class Signaler {
 public:
  virtual ~Signaler() = default;

  virtual void send(std::string_view signal) = 0;
  virtual std::unique_ptr<http::Response> handle(
      http::Request const& request) = 0;

 protected:
  Signaler() = default;
};

std::unique_ptr<Signaler> create_signaler(logger::Logger& logger,
                                          cfg::Config const& cfg,
                                          looper::Looper& looper);

std::unique_ptr<Api> create_bt_delegate(logger::Logger& logger,
                                        Signaler& signaler);

std::unique_ptr<http::Server::Delegate> create_http_delegate(
    Api& api, Signaler& signaler);

}  // namespace server

#endif  // SERVER_HH