Async 1.5.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
144 bool open(void);
145
152 void close(void);
153
161 bool reopen(void);
162
175 ssize_t write(const void *buf, size_t count);
176
181 bool isOpen(void) const { return master >= 0; }
182
188 sigc::signal<void, const void*, size_t> dataReceived;
189
190 protected:
191
192 private:
193 static const int POLLHUP_CHECK_INTERVAL = 100;
194
195 std::string slave_link;
196 int master;
197 Async::FdWatch *watch;
198 Async::Timer pollhup_timer;
199
200 Pty(const Pty&);
201 Pty& operator=(const Pty&);
202
203 void charactersReceived(void);
204 short pollMaster(void);
205 void checkIfSlaveEndOpen(void);
206
207}; /* class Pty */
208
209
210} /* namespace */
211
212#endif /* ASYNC_PTY_INCLUDED */
213
214
215
216/*
217 * This file has not been truncated
218 */
Contains a single shot or periodic timer that emits a signal on timeout.
A class for watching file descriptors.
Definition: AsyncFdWatch.h:120
A wrapper class for using a PTY.
Definition: AsyncPty.h:125
bool isOpen(void) const
Check if the PTY is open or not.
Definition: AsyncPty.h:181
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:188
A class that produces timer events.
Definition: AsyncTimer.h:117
Namespace for the asynchronous programming classes.