Imported Upstream version 3.2.2
[debian/gnuradio] / usrp / host / lib / legacy / fusb_win32.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2003 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 _FUSB_WIN32_H_
24 #define _FUSB_WIN32_H_
25
26 #include <fusb.h>
27
28 /*!
29  * \brief win32 implementation of fusb_devhandle using libusb-win32
30  */
31 class fusb_devhandle_win32 : public fusb_devhandle
32 {
33 public:
34   // CREATORS
35   fusb_devhandle_win32 (usb_dev_handle *udh);
36   virtual ~fusb_devhandle_win32 ();
37
38   // MANIPULATORS
39   virtual fusb_ephandle *make_ephandle (int endpoint, bool input_p,
40                                         int block_size = 0, int nblocks = 0);
41 };
42
43
44 /*!
45  * \brief win32 implementation of fusb_ephandle using libusb-win32
46  */
47 class fusb_ephandle_win32 : public fusb_ephandle
48 {
49 private:
50   fusb_devhandle_win32  *d_devhandle;
51
52   unsigned d_curr;
53   unsigned d_outstanding_write;
54   int d_output_short;
55   int d_input_leftover;
56   void ** d_context;
57   char * d_buffer;
58
59 public:
60   // CREATORS
61   fusb_ephandle_win32 (fusb_devhandle_win32 *dh, int endpoint, bool input_p,
62                          int block_size = 0, int nblocks = 0);
63   virtual ~fusb_ephandle_win32 ();
64
65   // MANIPULATORS
66
67   virtual bool start ();        //!< begin streaming i/o
68   virtual bool stop ();         //!< stop streaming i/o
69
70   /*!
71    * \returns \p nbytes if write was successfully enqueued, else -1.
72    * Will block if no free buffers available.
73    */
74   virtual int write (const void *buffer, int nbytes);
75
76   /*!
77    * \returns number of bytes read or -1 if error.
78    * number of bytes read will be <= nbytes.
79    * Will block if no input available.
80    */
81   virtual int read (void *buffer, int nbytes);
82
83   /*
84    * block until all outstanding writes have completed
85    */
86   virtual void wait_for_completion ();
87 };
88
89 #endif /* _FUSB_WIN32_H_ */
90