3 * Copyright 2005 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #ifndef INCLUDED_GR_SELECT_HANDLER_H
24 #define INCLUDED_GR_SELECT_HANDLER_H
26 #include <boost/shared_ptr.hpp>
28 class gr_select_handler;
29 typedef boost::shared_ptr<gr_select_handler> gr_select_handler_sptr;
33 * \brief Abstract handler for select based notification.
38 class gr_select_handler
43 gr_select_handler(int file_descriptor);
46 virtual ~gr_select_handler();
48 int fd() const { return d_fd; }
49 int file_descriptor() const { return d_fd; }
52 * \brief Called when file_descriptor is readable.
54 * Called when the dispatcher detects that file_descriptor can
55 * be read without blocking.
57 virtual void handle_read() = 0;
60 * \brief Called when file_descriptor is writable.
62 * Called when dispatcher detects that file descriptor can be
63 * written without blocking.
65 virtual void handle_write() = 0;
68 * Called each time around the dispatcher loop to determine whether
69 * this handler's file descriptor should be added to the list on which
70 * read events can occur. The default method returns true, indicating
71 * that by default, all handlers are interested in read events.
73 virtual bool readable() { return true; }
76 * Called each time around the dispatcher loop to determine whether
77 * this handler's file descriptor should be added to the list on which
78 * write events can occur. The default method returns true, indicating
79 * that by default, all handlers are interested in write events.
81 virtual bool writable() { return true; }
84 #endif /* INCLUDED_GR_SELECT_HANDLER_H */