]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/io_callback.h
remove_io_callback for Qt
[lyx.git] / src / frontends / qt2 / io_callback.h
1 /**
2  * \file io_callback.h
3  * Copyright 2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author unknown
7  * \author John Levon <moz@compsoc.man.ac.uk>
8  */
9
10 #ifndef IO_CALLBACK_H
11 #define IO_CALLBACK_H
12  
13 #include <config.h>
14
15 #include "lyxserver.h"
16 #include "debug.h"
17  
18 #include <qsocketnotifier.h>
19
20 #include <boost/scoped_ptr.hpp>
21  
22 /**
23  * io_callback - a simple wrapper for asynchronous pipe notification
24  *
25  * This is used by the lyxserver to notice the pipe is ready to be
26  * read.
27  *
28  * FIXME: this code apparently will not work on Windows.
29  */
30 class io_callback : public QObject {
31         Q_OBJECT 
32 public:
33         /// connect a read ready notification for fd to the LyXComm
34         io_callback(int fd, LyXComm * comm)
35                 : comm_(comm) {
36                 sn_.reset(new QSocketNotifier(fd, QSocketNotifier::Read, this));
37                 connect(sn_.get(), SIGNAL(activated(int)), this, SLOT(data_received()));
38         }
39  
40 public slots:
41         void data_received() {
42                 comm_->read_ready();
43         }
44
45 private:
46         /// our notifier
47         boost::scoped_ptr<QSocketNotifier> sn_;
48  
49         LyXComm * comm_;
50 };
51
52 #endif // IO_CALLBACK_H