diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-18 09:45:34 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-18 17:51:35 -0800 |
commit | a53130679944ddd179593259eb953b89ab1a7a38 (patch) | |
tree | 5d8274750bed0b21aa133bc93d97d75bbce0ecd9 /host/lib/transport/libusb1_base.hpp | |
parent | 2a44d6836ca08b6b67b83b63487b838e138ac379 (diff) | |
download | uhd-a53130679944ddd179593259eb953b89ab1a7a38.tar.gz uhd-a53130679944ddd179593259eb953b89ab1a7a38.tar.bz2 uhd-a53130679944ddd179593259eb953b89ab1a7a38.zip |
lib: transport: apply clang-format
This is a continuation of 967be2a4.
$ find host/lib/transport -iname *.hpp -o -iname *.cpp |\
xargs clang-format -i -style=file
Skipping host/lib/transport/nirio/ because of build errors.
$ git checkout host/lib/transport/nirio
Diffstat (limited to 'host/lib/transport/libusb1_base.hpp')
-rw-r--r-- | host/lib/transport/libusb1_base.hpp | 213 |
1 files changed, 107 insertions, 106 deletions
diff --git a/host/lib/transport/libusb1_base.hpp b/host/lib/transport/libusb1_base.hpp index 958248a5c..8ff1cf4cc 100644 --- a/host/lib/transport/libusb1_base.hpp +++ b/host/lib/transport/libusb1_base.hpp @@ -9,32 +9,30 @@ #define INCLUDED_LIBUHD_TRANSPORT_LIBUSB_HPP #include <uhd/config.hpp> -#include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> #include <uhd/transport/usb_device_handle.hpp> #include <libusb.h> +#include <boost/shared_ptr.hpp> +#include <boost/utility.hpp> //! Define LIBUSB_CALL when its missing (non-windows) #ifndef LIBUSB_CALL - #define LIBUSB_CALL +# define LIBUSB_CALL #endif /*LIBUSB_CALL*/ //! libusb_handle_events_timeout_completed is only in newer API #ifndef HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED - #define libusb_handle_events_timeout_completed(ctx, tx, completed) \ +# define libusb_handle_events_timeout_completed(ctx, tx, completed) \ libusb_handle_events_timeout(ctx, tx) #endif /* HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED */ //! libusb_error_name is only in newer API #ifndef HAVE_LIBUSB_ERROR_NAME - #define libusb_error_name(code) \ - str(boost::format("LIBUSB_ERROR_CODE %d") % code) +# define libusb_error_name(code) str(boost::format("LIBUSB_ERROR_CODE %d") % code) #endif /* HAVE_LIBUSB_ERROR_NAME */ //! libusb_strerror is only in newer API #ifndef HAVE_LIBUSB_STRERROR - #define libusb_strerror(code) \ - libusb_error_name(code) +# define libusb_strerror(code) libusb_error_name(code) #endif /* HAVE_LIBUSB_STRERROR */ /*********************************************************************** @@ -44,135 +42,138 @@ * also store tables of already allocated structures to avoid multiple * occurrences of opened handles (for example). **********************************************************************/ -namespace uhd { namespace transport { - -namespace libusb { - - /*! - * This session class holds a global libusb context for this process. - * The get global session call will create a new context if none exists. - * When all references to session are destroyed, the context will be freed. - */ - class session : boost::noncopyable { - public: - typedef boost::shared_ptr<session> sptr; - - virtual ~session(void); +namespace uhd { namespace transport { namespace libusb { - /*! - * Level 0: no messages ever printed by the library (default) - * Level 1: error messages are printed to stderr - * Level 2: warning and error messages are printed to stderr - * Level 3: informational messages are printed to stdout, warning - * and error messages are printed to stderr - */ - static const int debug_level = 0; +/*! + * This session class holds a global libusb context for this process. + * The get global session call will create a new context if none exists. + * When all references to session are destroyed, the context will be freed. + */ +class session : boost::noncopyable +{ +public: + typedef boost::shared_ptr<session> sptr; - //! get a shared pointer to the global session - static sptr get_global_session(void); - - //! get the underlying libusb context pointer - virtual libusb_context *get_context(void) const = 0; - }; + virtual ~session(void); /*! - * Holds a device pointer with a reference to the session. + * Level 0: no messages ever printed by the library (default) + * Level 1: error messages are printed to stderr + * Level 2: warning and error messages are printed to stderr + * Level 3: informational messages are printed to stdout, warning + * and error messages are printed to stderr */ - class device : boost::noncopyable { - public: - typedef boost::shared_ptr<device> sptr; + static const int debug_level = 0; - virtual ~device(void); + //! get a shared pointer to the global session + static sptr get_global_session(void); - //! get the underlying device pointer - virtual libusb_device *get(void) const = 0; - }; + //! get the underlying libusb context pointer + virtual libusb_context* get_context(void) const = 0; +}; - /*! - * This device list class holds a device list that will be - * automatically freed when the last reference is destroyed. - */ - class device_list : boost::noncopyable { - public: - typedef boost::shared_ptr<device_list> sptr; +/*! + * Holds a device pointer with a reference to the session. + */ +class device : boost::noncopyable +{ +public: + typedef boost::shared_ptr<device> sptr; - virtual ~device_list(void); + virtual ~device(void); - //! make a new device list - static sptr make(void); + //! get the underlying device pointer + virtual libusb_device* get(void) const = 0; +}; - //! the number of devices in this list - virtual size_t size() const = 0; +/*! + * This device list class holds a device list that will be + * automatically freed when the last reference is destroyed. + */ +class device_list : boost::noncopyable +{ +public: + typedef boost::shared_ptr<device_list> sptr; - //! get the device pointer at a particular index - virtual device::sptr at(size_t index) const = 0; - }; + virtual ~device_list(void); - /*! - * Holds a device descriptor and a reference to the device. - */ - class device_descriptor : boost::noncopyable { - public: - typedef boost::shared_ptr<device_descriptor> sptr; + //! make a new device list + static sptr make(void); - virtual ~device_descriptor(void); + //! the number of devices in this list + virtual size_t size() const = 0; - //! make a new descriptor from a device reference - static sptr make(device::sptr); + //! get the device pointer at a particular index + virtual device::sptr at(size_t index) const = 0; +}; - //! get the underlying device descriptor - virtual const libusb_device_descriptor &get(void) const = 0; +/*! + * Holds a device descriptor and a reference to the device. + */ +class device_descriptor : boost::noncopyable +{ +public: + typedef boost::shared_ptr<device_descriptor> sptr; - virtual std::string get_ascii_property(const std::string &what) const = 0; - }; + virtual ~device_descriptor(void); - /*! - * Holds a device handle and a reference to the device. - */ - class device_handle : boost::noncopyable { - public: - typedef boost::shared_ptr<device_handle> sptr; + //! make a new descriptor from a device reference + static sptr make(device::sptr); - virtual ~device_handle(void); + //! get the underlying device descriptor + virtual const libusb_device_descriptor& get(void) const = 0; - //! get a cached handle or make a new one given the device - static sptr get_cached_handle(device::sptr); + virtual std::string get_ascii_property(const std::string& what) const = 0; +}; - //! get the underlying device handle - virtual libusb_device_handle *get(void) const = 0; +/*! + * Holds a device handle and a reference to the device. + */ +class device_handle : boost::noncopyable +{ +public: + typedef boost::shared_ptr<device_handle> sptr; - /*! - * Open USB interfaces for control using magic value - * IN interface: 2 - * OUT interface: 1 - * Control interface: 0 - */ - virtual void claim_interface(int) = 0; + virtual ~device_handle(void); - virtual void clear_endpoints(unsigned char recv_endpoint, unsigned char send_endpoint) = 0; + //! get a cached handle or make a new one given the device + static sptr get_cached_handle(device::sptr); - virtual void reset_device(void) = 0; - }; + //! get the underlying device handle + virtual libusb_device_handle* get(void) const = 0; /*! - * The special handle is our internal implementation of the - * usb device handle which is used publicly to identify a device. + * Open USB interfaces for control using magic value + * IN interface: 2 + * OUT interface: 1 + * Control interface: 0 */ - class special_handle : public usb_device_handle { - public: - typedef boost::shared_ptr<special_handle> sptr; + virtual void claim_interface(int) = 0; + + virtual void clear_endpoints( + unsigned char recv_endpoint, unsigned char send_endpoint) = 0; + + virtual void reset_device(void) = 0; +}; - virtual ~special_handle(void); +/*! + * The special handle is our internal implementation of the + * usb device handle which is used publicly to identify a device. + */ +class special_handle : public usb_device_handle +{ +public: + typedef boost::shared_ptr<special_handle> sptr; - //! make a new special handle from device - static sptr make(device::sptr); + virtual ~special_handle(void); - //! get the underlying device reference - virtual device::sptr get_device(void) const = 0; - }; + //! make a new special handle from device + static sptr make(device::sptr); -} + //! get the underlying device reference + virtual device::sptr get_device(void) const = 0; +}; -}} //namespace +}}} // namespace uhd::transport::libusb #endif /* INCLUDED_LIBUHD_TRANSPORT_LIBUSB_HPP */ |