Update revision to release 3.3.0-rc1, update autotools
[debian/gnuradio] / vrt / include / vrt / rx.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009 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 along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 #ifndef INCLUDED_VRT_RX_H
22 #define INCLUDED_VRT_RX_H
23
24 #include <boost/shared_ptr.hpp>
25 #include <boost/utility.hpp>
26 #include <vrt/rx_packet_handler.h>
27
28 namespace vrt {
29
30   class socket_rx_buffer;
31
32   /*!
33    * Relatively low-level interface to receive VRT packets over a datagram socket.
34    *
35    * (We'll refactor this if/when we use a non-UDP transport.)
36    * No VRT control issues are addressed here.
37    */
38   class rx : boost::noncopyable
39   {
40     int                 d_socket_fd;
41     socket_rx_buffer   *d_srb;
42
43   public:
44     /*!
45      * Shared pointer to this class
46      */ 
47     typedef boost::shared_ptr<rx> sptr;
48
49     /*! 
50      * \brief Static function to return an instance of rx as a shared pointer.
51      *
52      * \param socket_fd file descriptor that data grams will be received from.
53      *                  It is assumed that some higher-level control software
54      *                  opened the appropriate UDP socket for us.  This object
55      *                  assumes management of the socket's lifetime.  The
56      *                  socket will be closed when our destructor fires.
57      *
58      * \param rx_bufsize is a hint as to the number of bytes of memory
59      *                  to allocate for received ethernet frames (0 -> reasonable default)
60      */
61     static sptr make(int socket_fd, size_t rx_bufsize = 0);
62
63     /*! 
64      * \param socket_fd file descriptor that data grams will be received from.
65      *                  It is assumed that some higher-level control software
66      *                  opened the appropriate UDP socket for us.  This object
67      *                  assumes management of the socket's lifetime.  The
68      *                  socket will be closed when our destructor fires.
69      *
70      * \param rx_bufsize is a hint as to the number of bytes of memory
71      *                  to allocate for received ethernet frames (0 -> reasonable default)
72      */
73     rx(int socket_fd, size_t rx_bufsize = 0);
74     ~rx();
75
76     /*!
77      * \brief Receive packets from the given socket file descriptor.
78      *
79      * \p handler will be invoked for all available packets.
80      * Unless \p dont_wait is true, this function blocks until at
81      * least one packet has been processed.
82      */
83     bool rx_packets(rx_packet_handler *handler, bool dont_wait = false);
84
85     /*
86      * \returns the socket_fd.   Useful for select or poll.
87      */
88     int socket_fd() const { return d_socket_fd; }
89   };
90
91 }
92
93 #endif /* INCLUDED_VRT_RX_H */