5 * \brief abstract usb device handle
10 fusb_devhandle (const fusb_devhandle &rhs); // no copy constructor
11 fusb_devhandle &operator= (const fusb_devhandle &rhs); // no assignment operator
14 libusb_device_handle *d_udh;
18 fusb_devhandle (libusb_device_handle *udh);
19 virtual ~fusb_devhandle ();
24 * \brief return an ephandle of the correct subtype
26 virtual fusb_ephandle *make_ephandle (int endpoint, bool input_p,
27 int block_size = 0, int nblocks = 0) = 0;
30 libusb_device_handle *get_usb_dev_handle () const { return d_udh; }
35 * \brief abstract usb end point handle
40 fusb_ephandle (const fusb_ephandle &rhs); // no copy constructor
41 fusb_ephandle &operator= (const fusb_ephandle &rhs); // no assignment operator
51 fusb_ephandle (int endpoint, bool input_p,
52 int block_size = 0, int nblocks = 0);
53 virtual ~fusb_ephandle ();
55 virtual bool start () = 0; //!< begin streaming i/o
56 virtual bool stop () = 0; //!< stop streaming i/o
59 * \returns \p nbytes if write was successfully enqueued, else -1.
60 * Will block if no free buffers available.
62 virtual int write (const void *buffer, int nbytes) = 0;
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.
69 virtual int read (void *buffer, int nbytes) = 0;
72 * block until all outstanding writes have completed
74 virtual void wait_for_completion () = 0;
77 * \brief returns current block size.
79 int block_size () { return d_block_size; };
84 * \brief factory for creating concrete instances of the appropriate subtype.
86 class fusb_sysconfig {
89 * \brief returns fusb_devhandle or throws if trouble
91 static fusb_devhandle *make_devhandle (libusb_device_handle *udh,
92 libusb_context *ctx = 0);
95 * \brief Returns max block size in bytes (hard limit).
97 static int max_block_size ();
100 * \brief Returns default block size in bytes.
102 static int default_block_size ();
105 * \brief Returns the default buffer size in bytes.
107 static int default_buffer_size ();
111 #endif /* _FUSB_H_ */