Async 1.7.0
AsyncPty.h
Go to the documentation of this file.
1
27#ifndef ASYNC_PTY_INCLUDED
28#define ASYNC_PTY_INCLUDED
29
30
31/****************************************************************************
32 *
33 * System Includes
34 *
35 ****************************************************************************/
36
37#include <unistd.h>
38#include <sigc++/sigc++.h>
39
40#include <string>
41
42
43/****************************************************************************
44 *
45 * Project Includes
46 *
47 ****************************************************************************/
48
49#include <AsyncTimer.h>
50
51
52/****************************************************************************
53 *
54 * Local Includes
55 *
56 ****************************************************************************/
57
58
59
60/****************************************************************************
61 *
62 * Forward declarations
63 *
64 ****************************************************************************/
65
66
67
68/****************************************************************************
69 *
70 * Namespace
71 *
72 ****************************************************************************/
73
74namespace Async
75{
76
77
78/****************************************************************************
79 *
80 * Forward declarations of classes inside of the declared namespace
81 *
82 ****************************************************************************/
83
84class FdWatch;
85
86
87/****************************************************************************
88 *
89 * Defines & typedefs
90 *
91 ****************************************************************************/
92
93
94
95/****************************************************************************
96 *
97 * Exported Global Variables
98 *
99 ****************************************************************************/
100
101
102
103/****************************************************************************
104 *
105 * Class definitions
106 *
107 ****************************************************************************/
108
124class Pty : public sigc::trackable
125{
126 public:
130 Pty(const std::string &slave_link="");
131
135 ~Pty(void);
136
137 void setLineBuffered(bool line_buffered)
138 {
139 m_is_line_buffered = line_buffered;
140 m_line_buffer.clear();
141 }
142
150 bool open(void);
151
158 void close(void);
159
167 bool reopen(void);
168
181 ssize_t write(const void *buf, size_t count);
182
187 bool isOpen(void) const { return master >= 0; }
188
194 sigc::signal<void, const void*, size_t> dataReceived;
195
196 protected:
197
198 private:
199 static const int POLLHUP_CHECK_INTERVAL = 100;
200
201 std::string slave_link;
202 int master;
203 Async::FdWatch *watch;
204 Async::Timer pollhup_timer;
205 bool m_is_line_buffered = false;
206 std::string m_line_buffer;
207
208 Pty(const Pty&);
209 Pty& operator=(const Pty&);
210
211 void charactersReceived(void);
212 short pollMaster(void);
213 void checkIfSlaveEndOpen(void);
214
215}; /* class Pty */
216
217
218} /* namespace */
219
220#endif /* ASYNC_PTY_INCLUDED */
221
222
223
224/*
225 * This file has not been truncated
226 */
Contains a single shot or periodic timer that emits a signal on timeout.
A class for watching file descriptors.
A wrapper class for using a PTY.
Definition AsyncPty.h:125
void setLineBuffered(bool line_buffered)
Definition AsyncPty.h:137
bool isOpen(void) const
Check if the PTY is open or not.
Definition AsyncPty.h:187
void close(void)
Close the PTY if it's open.
bool open(void)
Open the PTY.
ssize_t write(const void *buf, size_t count)
Write data to the PTY.
bool reopen(void)
Reopen the PTY.
Pty(const std::string &slave_link="")
Default constructor.
~Pty(void)
Destructor.
sigc::signal< void, const void *, size_t > dataReceived
Signal that is emitted when data has been received.
Definition AsyncPty.h:194
A class that produces timer events.
Definition AsyncTimer.h:117
Namespace for the asynchronous programming classes.