]> git.tdb.fi Git - libs/core.git/blob - source/io/pipe.h
Implement controls for file descriptor inheritance
[libs/core.git] / source / io / pipe.h
1 #ifndef MSP_IO_PIPE_H_
2 #define MSP_IO_PIPE_H_
3
4 #include "eventobject.h"
5 #include "eventreader.h"
6 #include "handle.h"
7
8 namespace Msp {
9 namespace IO {
10
11 class Pipe: public EventObject
12 {
13 private:
14         Handle read_handle;
15         Handle write_handle;
16         EventReader reader;
17
18 public:
19         Pipe();
20 private:
21         void platform_init();
22 public:
23         ~Pipe();
24
25         void set_mode(Mode);
26         virtual void set_block(bool);
27         virtual void set_inherit(bool);
28
29 protected:
30         virtual unsigned do_write(const char *, unsigned);
31         virtual unsigned do_read(char *, unsigned);
32
33 public:
34         virtual const Handle &get_handle(Mode);
35         virtual const Handle &get_event_handle() { return reader.get_event(); }
36 };
37
38 } // namespace IO
39 } // namespace Msp
40
41 #endif