~singpolyma/biboumi

ref: 1028d4d549b517c5b42bb0c30a410d1ab43c4cf3 biboumi/src/network/socket_handler.hpp -rw-r--r-- 959 bytes
1028d4d5 — Florent Le Coz Add a changelog entry for the fixed_irc_server option 8 years ago
                                                                                
8c34576e Florent Le Coz
b86547dc Florent Le Coz
8c34576e Florent Le Coz
23f32ba3 Florent Le Coz
7869ef2a Florent Le Coz
8c34576e Florent Le Coz
04d99916 Florent Le Coz
b86547dc Florent Le Coz
8c34576e Florent Le Coz
7869ef2a Florent Le Coz
8c34576e Florent Le Coz
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
#ifndef SOCKET_HANDLER_HPP
# define SOCKET_HANDLER_HPP

#include <config.h>
#include <memory>

class Poller;

typedef int socket_t;

class SocketHandler
{
public:
  explicit SocketHandler(std::shared_ptr<Poller> poller, const socket_t socket):
    poller(poller),
    socket(socket)
  {}
  virtual ~SocketHandler() {}
  virtual void on_recv() = 0;
  virtual void on_send() = 0;
  virtual void connect() = 0;
  virtual bool is_connected() const = 0;

  socket_t get_socket() const
  { return this->socket; }

protected:
  /**
   * A pointer to the poller that manages us, because we need to communicate
   * with it.
   */
  std::shared_ptr<Poller> poller;
  /**
   * The handled socket.
   */
  socket_t socket;

private:
  SocketHandler(const SocketHandler&) = delete;
  SocketHandler(SocketHandler&&) = delete;
  SocketHandler& operator=(const SocketHandler&) = delete;
  SocketHandler& operator=(SocketHandler&&) = delete;
};

#endif // SOCKET_HANDLER_HPP