GNU Radio 3.5.3.1 C++ API
gr_select_handler.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2005 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
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)
10  * any later version.
11  *
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.
16  *
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.
21  */
22 
23 #ifndef INCLUDED_GR_SELECT_HANDLER_H
24 #define INCLUDED_GR_SELECT_HANDLER_H
25 
26 #include <gr_core_api.h>
27 #include <boost/shared_ptr.hpp>
28 
29 class gr_select_handler;
31 
32 
33 /*!
34  * \brief Abstract handler for select based notification.
35  * \ingroup base
36  *
37  * \sa gr_dispatcher
38  */
40 {
41  int d_fd;
42 
43 protected:
44  gr_select_handler(int file_descriptor);
45 
46 public:
47  virtual ~gr_select_handler();
48 
49  int fd() const { return d_fd; }
50  int file_descriptor() const { return d_fd; }
51 
52  /*!
53  * \brief Called when file_descriptor is readable.
54  *
55  * Called when the dispatcher detects that file_descriptor can
56  * be read without blocking.
57  */
58  virtual void handle_read() = 0;
59 
60  /*!
61  * \brief Called when file_descriptor is writable.
62  *
63  * Called when dispatcher detects that file descriptor can be
64  * written without blocking.
65  */
66  virtual void handle_write() = 0;
67 
68  /*!
69  * Called each time around the dispatcher loop to determine whether
70  * this handler's file descriptor should be added to the list on which
71  * read events can occur. The default method returns true, indicating
72  * that by default, all handlers are interested in read events.
73  */
74  virtual bool readable() { return true; }
75 
76  /*!
77  * Called each time around the dispatcher loop to determine whether
78  * this handler's file descriptor should be added to the list on which
79  * write events can occur. The default method returns true, indicating
80  * that by default, all handlers are interested in write events.
81  */
82  virtual bool writable() { return true; }
83 };
84 
85 #endif /* INCLUDED_GR_SELECT_HANDLER_H */