Moved to single generated fusb.h, headers now generated out of lib directory
[debian/gnuradio] / usrp / host / lib / fusb.h.in
1 struct  libusb_context;
2 class   fusb_ephandle;
3
4 /*!
5  * \brief abstract usb device handle
6  */
7 class fusb_devhandle {
8 private:
9   // NOT IMPLEMENTED
10   fusb_devhandle (const fusb_devhandle &rhs);             // no copy constructor
11   fusb_devhandle &operator= (const fusb_devhandle &rhs);  // no assignment operator
12
13 protected:
14   libusb_device_handle          *d_udh;
15
16 public:
17   // CREATORS
18   fusb_devhandle (libusb_device_handle *udh);
19   virtual ~fusb_devhandle ();
20
21   // MANIPULATORS
22   
23   /*!
24    * \brief return an ephandle of the correct subtype
25    */
26   virtual fusb_ephandle *make_ephandle (int endpoint, bool input_p,
27                                         int block_size = 0, int nblocks = 0) = 0;
28   
29   // ACCESSORS
30   libusb_device_handle *get_usb_dev_handle () const { return d_udh; }
31 };
32
33
34 /*!
35  * \brief abstract usb end point handle
36  */
37 class fusb_ephandle {
38 private:
39   // NOT IMPLEMENTED
40   fusb_ephandle (const fusb_ephandle &rhs);             // no copy constructor
41   fusb_ephandle &operator= (const fusb_ephandle &rhs);  // no assignment operator
42
43 protected:
44   int                           d_endpoint;
45   bool                          d_input_p;
46   int                           d_block_size;
47   int                           d_nblocks;
48   bool                          d_started;
49
50 public:
51   fusb_ephandle (int endpoint, bool input_p,
52                  int block_size = 0, int nblocks = 0);
53   virtual ~fusb_ephandle ();
54
55   virtual bool start () = 0;    //!< begin streaming i/o
56   virtual bool stop () = 0;     //!< stop streaming i/o
57
58   /*!
59    * \returns \p nbytes if write was successfully enqueued, else -1.
60    * Will block if no free buffers available.
61    */
62   virtual int write (const void *buffer, int nbytes) = 0;
63
64   /*!
65    * \returns number of bytes read or -1 if error.
66    * number of bytes read will be <= nbytes.
67    * Will block if no input available.
68    */
69   virtual int read (void *buffer, int nbytes) = 0;
70
71   /*
72    * block until all outstanding writes have completed
73    */
74   virtual void wait_for_completion () = 0;
75
76   /*!
77    * \brief returns current block size.
78    */
79   int block_size () { return d_block_size; };
80 };
81
82
83 /*!
84  * \brief factory for creating concrete instances of the appropriate subtype.
85  */
86 class fusb_sysconfig {
87 public:
88   /*!
89    * \brief returns fusb_devhandle or throws if trouble
90    */
91   static fusb_devhandle *make_devhandle (libusb_device_handle *udh,
92                                          libusb_context *ctx = 0);
93
94   /*!
95    * \brief Returns max block size in bytes (hard limit).
96    */
97   static int max_block_size ();
98
99   /*!
100    * \brief Returns default block size in bytes.
101    */
102   static int default_block_size ();
103
104   /*!
105    * \brief Returns the default buffer size in bytes.
106    */
107   static int default_buffer_size ();
108
109 };
110
111 #endif /* _FUSB_H_ */