Line data Source code
1 : // Copyright (c) 2013-2022 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // https://snapwebsites.org/project/eventdispatcher
4 : // contact@m2osw.com
5 : //
6 : // This program is free software; you can redistribute it and/or modify
7 : // it under the terms of the GNU General Public License as published by
8 : // the Free Software Foundation; either version 2 of the License, or
9 : // (at your option) any later version.
10 : //
11 : // This program is distributed in the hope that it will be useful,
12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License along
17 : // with this program; if not, write to the Free Software Foundation, Inc.,
18 : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 :
20 : // self
21 : //
22 : #include "cppprocess/io.h"
23 :
24 : #include <snapdev/has_member_function.h>
25 :
26 :
27 : // snapdev include
28 : //
29 : #include <snapdev/not_used.h>
30 :
31 :
32 : // last include
33 : //
34 : #include <snapdev/poison.h>
35 :
36 :
37 :
38 :
39 : namespace cppprocess
40 : {
41 :
42 :
43 9 : io::io(io_flags_t flags)
44 9 : : f_flags(flags)
45 : {
46 9 : }
47 :
48 :
49 9 : io::~io()
50 : {
51 9 : }
52 :
53 :
54 11 : io_flags_t io::get_flags() const
55 : {
56 11 : return f_flags;
57 : }
58 :
59 :
60 0 : io::done_callbacks_t::callback_id_t io::add_process_done_callback(process_io_done_t done)
61 : {
62 0 : return f_process_done.add_callback(done);
63 : }
64 :
65 :
66 0 : bool io::remove_process_done_callback(done_callbacks_t::callback_id_t id)
67 : {
68 0 : return f_process_done.remove_callback(id);
69 : }
70 :
71 :
72 0 : void io::process_starting()
73 : {
74 0 : }
75 :
76 :
77 7 : bool io::process_done(done_reason_t reason)
78 : {
79 : //std::cerr << "PROCESS done, reason = " << static_cast<int>(reason)
80 : //<< " -- number of process done: " << f_process_done.size()
81 : //<< "\n";
82 :
83 : // WARNING: we use `this` (instead of make_shared_from_this()) because
84 : // the pipe_connection derives from connection which already
85 : // derives from make_shared_from_this_enabled and having two
86 : // of such fails badly; also if the user needs to keep a
87 : // shared pointer, he can do so in his own class or in
88 : // the std::bind() directly.
89 : //
90 7 : return f_process_done.call(this, reason);
91 : }
92 :
93 :
94 0 : int io::get_fd()
95 : {
96 0 : return -1;
97 : }
98 :
99 :
100 0 : int io::get_other_fd()
101 : {
102 0 : return -1;
103 : }
104 :
105 :
106 0 : void io::close_both()
107 : {
108 0 : }
109 :
110 :
111 0 : void io::close_other()
112 : {
113 0 : }
114 :
115 :
116 :
117 6 : } // namespace cppprocess
118 : // vim: ts=4 sw=4 et
|