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 2, 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.
37 class gr_select_handler
42 gr_select_handler(int file_descriptor);
45 virtual ~gr_select_handler();
47 int fd() const { return d_fd; }
48 int file_descriptor() const { return d_fd; }
51 * \brief Called when file_descriptor is readable.
53 * Called when the dispatcher detects that file_descriptor can
54 * be read without blocking.
56 virtual void handle_read() = 0;
59 * \brief Called when file_descriptor is writable.
61 * Called when dispatcher detects that file descriptor can be
62 * written without blocking.
64 virtual void handle_write() = 0;
67 * Called each time around the dispatcher loop to determine whether
68 * this handler's file descriptor should be added to the list on which
69 * read events can occur. The default method returns true, indicating
70 * that by default, all handlers are interested in read events.
72 virtual bool readable() { return true; }
75 * Called each time around the dispatcher loop to determine whether
76 * this handler's file descriptor should be added to the list on which
77 * write events can occur. The default method returns true, indicating
78 * that by default, all handlers are interested in write events.
80 virtual bool writable() { return true; }
83 #endif /* INCLUDED_GR_SELECT_HANDLER_H */