Created
March 3, 2017 16:44
-
-
Save Loki-Astari/e5a905597af6a4f61e438dc6bcde72f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class USBLib | |
{ | |
// Some form of singelton that is used to initialize library. | |
public: | |
static std::shared_ptr<USBLib> getContext() | |
{ | |
static std::shared_ptr<USBLIB> context; | |
return context; | |
} | |
}; | |
class USBDevice | |
{ | |
// A USB device | |
public: | |
USBDevice(); | |
USBDevice(USBDevice const&); | |
USBDevice(USBDevice&&); | |
~USBDevice(); | |
USBDevice& operator=(USBDevice const&); | |
USBDevice& operator=(USBDevice&&); | |
void setReaderAction(Action); | |
void setWriterACtion(Action); | |
// You could add these | |
// But I would try and avoid it. | |
// You should try and define the operations that happen on the device at a higher level. | |
// Privately the object will call these. | |
uint8_t getBusNumber () | |
uint8_t getPortNumber () | |
int getPortPath (uint8_t *port_numbers, uint8_t port_numbers_len) | |
USBDevice getParent () | |
uint8_t getDeviceAddress () | |
int getDeviceSpeed () | |
int getMaxPacketSize (unsigned char endpoint) | |
int getMaxIsoPacketSize (unsigned char endpoint) | |
int getConfiguration () | |
void setConfiguration (int configuration) | |
int setInterfaceAltSetting (lint interface_number, int alternate_setting) | |
}; | |
class USBDeviceList | |
{ | |
// A List of USB Devices | |
public: | |
USBDeviceList(); | |
USBDeviceList(USBDeviceList const&); | |
USBDeviceList(USBDeviceList&&); | |
~USBDeviceList(); | |
USBDeviceList& operator=(USBDeviceList const&); | |
USBDeviceList& operaotr=(USBDeviceList&&); | |
std::size_t size() const; | |
bool empty() const; | |
USBDevice& operator[](std::size_t index); | |
USBDevice const& operator[](std::size_t index) const; | |
iterator begin(); | |
const_iterator begin() const; | |
const_iterator cbegin() const; | |
iterator end(); | |
const_iterator end() const; | |
const_iterator cend() const; | |
bool operator==(USBDeviceList const&) const; | |
bool operator!=(USBDeviceList const&) const; | |
void swap(USBDeviceList&); | |
friend void swap(USBDeviceList&, USBDeviceList&); | |
}; | |
class USBAction | |
{ | |
// An Event handler for an action that happens on a USB device. | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment