PCSCDriverBundle.h [plain text]
#ifndef _H_XPCSCDRIVERBUNDLE
#define _H_XPCSCDRIVERBUNDLE
#include <string>
#include <vector>
#include <security_utilities/refcount.h>
#include <security_utilities/osxcode.h>
#include "PCSCDevice.h"
#if defined(__cplusplus)
namespace PCSCD {
class DeviceDescription
{
public:
DeviceDescription() { }
DeviceDescription(uint16_t vendor, uint16_t product, std::string name) :
mVendor(vendor), mProduct(product),
mDeviceClass(0), mDeviceSubClass(0), mDeviceProtocol(0),
mFriendlyName(name) {}
DeviceDescription(uint8_t deviceClass, uint8_t deviceSubClass, uint8_t protocol, std::string name) :
mVendor(0), mProduct(0),
mDeviceClass(deviceClass), mDeviceSubClass(deviceSubClass), mDeviceProtocol(protocol),
mFriendlyName(name) {}
bool operator < (const DeviceDescription &other) const throw();
uint8_t interfaceClass() const { return mDeviceClass; }
uint16_t vendorid() const { return mVendor; }
uint16_t productid() const { return mProduct; }
std::string name() const { return mFriendlyName; }
void dump();
protected:
uint16_t mVendor; uint16_t mProduct;
uint8_t mDeviceClass;
uint8_t mDeviceSubClass;
uint8_t mDeviceProtocol;
std::string mFriendlyName; };
class DriverBundle : public LoadableBundle
{
private:
DriverBundle(const char *pathname) : LoadableBundle(pathname) { }
public:
DriverBundle(CFBundleRef bundle);
virtual ~DriverBundle() throw();
bool operator < (const DriverBundle &other) const throw();
void addProduct(DeviceDescription *dev) { mDeviceDescriptions.push_back(dev); }
uint32_t matches(const Device &device, std::string &name) const;
enum
{
eMatchNone = 0,
eMatchInterfaceClass, eMatchVendorSpecific
};
protected:
void initialize(CFDictionaryRef dict);
private:
typedef std::vector<DeviceDescription *> DeviceDescriptions;
typedef DeviceDescriptions::iterator DeviceDescriptionIterator;
typedef DeviceDescriptions::const_iterator ConstDeviceDescriptionIterator;
DeviceDescriptions mDeviceDescriptions;
std::string getStringAttr(CFDictionaryRef dict, CFStringRef key);
std::string getStringAttr(CFArrayRef arr, CFIndex idx);
void dump();
};
}
#endif
#endif