Line data Source code
1 : // Copyright (c) 2012-2019 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // This program is free software; you can redistribute it and/or modify
4 : // it under the terms of the GNU General Public License as published by
5 : // the Free Software Foundation; either version 2 of the License, or
6 : // (at your option) any later version.
7 : //
8 : // This program is distributed in the hope that it will be useful,
9 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 : // GNU General Public License for more details.
12 : //
13 : // You should have received a copy of the GNU General Public License
14 : // along with this program; if not, write to the Free Software
15 : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 : #pragma once
17 :
18 : // self
19 : //
20 : #include "eventdispatcher/connection.h"
21 : //#include "eventdispatcher/udp_client_server.h"
22 : //#include "eventdispatcher/utils.h"
23 : //
24 : //
25 : //// cppthread lib
26 : ////
27 : //#include "cppthread/thread.h"
28 : //
29 : //
30 : //// snapdev lib
31 : ////
32 : //#include "snapdev/not_used.h"
33 : //
34 : //
35 : //// C lib
36 : ////
37 : //#include <signal.h>
38 : //#include <sys/signalfd.h>
39 :
40 :
41 :
42 : namespace ed
43 : {
44 :
45 :
46 :
47 0 : class fd_connection
48 : : public connection
49 : {
50 : public:
51 : typedef std::shared_ptr<fd_connection> pointer_t;
52 :
53 : enum class mode_t
54 : {
55 : FD_MODE_READ,
56 : FD_MODE_WRITE,
57 : FD_MODE_RW
58 : };
59 :
60 : fd_connection(int fd, mode_t mode);
61 :
62 : void close();
63 : void mark_closed();
64 :
65 : // snap_connection implementation
66 : virtual bool is_reader() const override;
67 : virtual bool is_writer() const override;
68 : virtual int get_socket() const override;
69 :
70 : // new callbacks
71 : virtual ssize_t read(void * buf, size_t count);
72 : virtual ssize_t write(void const * buf, size_t count);
73 :
74 : private:
75 : int f_fd = -1;
76 : mode_t f_mode = mode_t::FD_MODE_RW;
77 : };
78 :
79 :
80 :
81 : } // namespace ed
82 : // vim: ts=4 sw=4 et
|