GNU Radio 3.5.3.2 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2005 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_SELECT_HANDLER_H 00024 #define INCLUDED_GR_SELECT_HANDLER_H 00025 00026 #include <gr_core_api.h> 00027 #include <boost/shared_ptr.hpp> 00028 00029 class gr_select_handler; 00030 typedef boost::shared_ptr<gr_select_handler> gr_select_handler_sptr; 00031 00032 00033 /*! 00034 * \brief Abstract handler for select based notification. 00035 * \ingroup base 00036 * 00037 * \sa gr_dispatcher 00038 */ 00039 class GR_CORE_API gr_select_handler 00040 { 00041 int d_fd; 00042 00043 protected: 00044 gr_select_handler(int file_descriptor); 00045 00046 public: 00047 virtual ~gr_select_handler(); 00048 00049 int fd() const { return d_fd; } 00050 int file_descriptor() const { return d_fd; } 00051 00052 /*! 00053 * \brief Called when file_descriptor is readable. 00054 * 00055 * Called when the dispatcher detects that file_descriptor can 00056 * be read without blocking. 00057 */ 00058 virtual void handle_read() = 0; 00059 00060 /*! 00061 * \brief Called when file_descriptor is writable. 00062 * 00063 * Called when dispatcher detects that file descriptor can be 00064 * written without blocking. 00065 */ 00066 virtual void handle_write() = 0; 00067 00068 /*! 00069 * Called each time around the dispatcher loop to determine whether 00070 * this handler's file descriptor should be added to the list on which 00071 * read events can occur. The default method returns true, indicating 00072 * that by default, all handlers are interested in read events. 00073 */ 00074 virtual bool readable() { return true; } 00075 00076 /*! 00077 * Called each time around the dispatcher loop to determine whether 00078 * this handler's file descriptor should be added to the list on which 00079 * write events can occur. The default method returns true, indicating 00080 * that by default, all handlers are interested in write events. 00081 */ 00082 virtual bool writable() { return true; } 00083 }; 00084 00085 #endif /* INCLUDED_GR_SELECT_HANDLER_H */