dxd - dynax driver framework  3211
cross platform open source driver development framework
dx::device Class Reference

generic device interface class More...

#include <dx_device.h>

+ Inheritance diagram for dx::device:
+ Collaboration diagram for dx::device:

Classes

struct  creator
 

Public Types

typedef ::io_service_t creator
 

Public Member Functions

 catchall_rethrow () virtual ~device() noexcept
 the device class destructor More...
 
virtual void conclude () noexcept
 conclude notification: device will be removed from tree More...
 
virtual void conclude ()
 conclude notifacation: device will be removed from tree More...
 
void ctl (unsigned int ioctl) const
 
void ctl (unsigned int ioctl) const
 
 device (::io_service_t io_service)
 the device class constructor More...
 
 device (const creator &creator)
 the device class constructor More...
 
registryerase (const char *key=nullptr)
 
preferenceerase (::CFStringRef key=nullptr)
 
::CFTypeRef get (::CFStringRef key) const
 
::CFTypeRef get (::CFStringRef key, ::CFTypeRef dflt) const noexcept
 
template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t get (::CFStringRef key) const
 
template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t get (::CFStringRef key, ::CFTypeRef dflt) const noexcept
 
template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t get (::CFStringRef key, value_t dflt) const noexcept
 
template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
::CFTypeRef get (key_t key) const
 
template<typename key_t , typename value_t , typename = typename cf::enable_if_convertible<key_t>::type, typename = typename cf::enable_if_convertible<value_t>::type>
value_t get (key_t key) const
 
template<typename rx_t >
rx_t ictl (unsigned int ioctl) const
 member ioctl More...
 
template<typename rx_t >
size_t ictl (unsigned int ioctl, rx_t &rx) const
 
template<typename rx_t >
rx_t ictl (unsigned int ioctl) const
 Windows: member ioctl. More...
 
template<typename rx_t >
size_t ictl (unsigned int ioctl, rx_t &rx) const
 
void initialize (const char *path, ::HKEY root, ::REGSAM rights=KEY_READ, const char *key=nullptr)
 
void initialize (const char *path, ::REGSAM rights=KEY_READ, ::HKEY root=HKEY_CURRENT_USER, const char *key=nullptr)
 
template<typename rx_t , typename tx_t >
size_t ioctl (unsigned int ioctl, const tx_t &tx, rx_t &rx) const
 
template<typename rx_t , typename tx_t >
rx_t ioctl (unsigned int ioctl, const tx_t &tx) const
 
size_t ioctl (unsigned int ioctl, const void *tx=nullptr, size_t tx_size=0, void *rx=nullptr, size_t rx_size=0) const
 
template<typename tx_t , typename rx_t >
size_t ioctl (unsigned int ioctl, const tx_t &tx, rx_t &rx) const
 
template<typename rx_t , typename tx_t >
rx_t ioctl (unsigned int ioctl, const tx_t &tx) const
 
virtual void launch ()
 launch notification: device mounted in tree and ready to use More...
 
virtual void launch ()
 launch notifacation: device mounted in tree and ready to use More...
 
template<typename tx_t >
void octl (unsigned int ioctl, const tx_t &tx) const
 
template<typename tx_t >
void octl (unsigned int ioctl, const tx_t &tx) const
 
 operator const io_registry_entry_t & () const
 auto converter into const object More...
 
 operator io_registry_entry_t & ()
 auto converter into object More...
 
 operator std::string () const
 
 operator uint64_t () const
 
template<typename value_t >
 operator value_t () const
 
template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
 operator value_t () const
 
template<typename value_t >
value_t operator() (value_t dflt) const
 
::CFPropertyListRef operator() (::CFPropertyListRef dflt) const
 
::CFDictionaryRef operator() (::CFDictionaryRef dflt) const noexcept
 
template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t operator() (value_t dflt) const
 
 operator::CFArrayRef () const noexcept
 
 operator::CFDictionaryRef () const noexcept
 
 operator::CFMutableDictionaryRef () const
 
 operator::CFPropertyListRef () const
 
 operator::HANDLE () const noexcept
 
registryoperator= (::CFTypeRef properties)
 
deviceoperator= (const union log &log)
 
deviceoperator= (const union log &log)
 
bool operator== (io_registry_entry_t object) const noexcept
 
registry operator[] (const char *key) const
 
::CFTypeRef operator[] (::CFStringRef key) const
 
template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
::CFTypeRef operator[] (key_t key) const
 
preference operator[] (::CFStringRef key) const
 
template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
preference operator[] (key_t key) const
 
registryset (::CFTypeRef properties)
 Setting properties in a registry entry is not generally supported, it is more common to support setting of properties of the connection based property setting of dx::device. More...
 
registryset (::CFStringRef key, ::CFTypeRef value) noexcept
 
template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
registryset (::CFStringRef key, value_t value)
 
template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
registryset (key_t key, ::CFTypeRef value)
 
template<typename key_t , typename value_t , typename = typename cf::enable_if_convertible<key_t>::type, typename = typename cf::enable_if_convertible<value_t>::type>
registryset (key_t key, value_t value)
 
registrysignal ()
 
registrywait (int64_t timeout=0, ::DWORD filter=REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_ATTRIBUTES|REG_NOTIFY_CHANGE_LAST_SET|REG_NOTIFY_CHANGE_SECURITY, bool subtree=true)
 
virtual ~device () noexcept
 

Public Attributes

dx::log log {}
 
cf::preference preference
 
registry preference
 
cf::type< const char * > bundle_id
 
cf::type< const char * > class_name
 

Protected Attributes

struct {
   cf::type< const char * >   bundle_id
 
   cf::type< const char * >   class_name
 
kernel
 
io::port port
 

Detailed Description

generic device interface class

generic device class

This is the generic device interface class. This class is used for a platform independent way of accessing devices. The device class uses the driver interface helper class to construct the device object and to bind the device to the driver identified by the GUID.

example:

try() { // guard the block
// choose a driver
// enumerate devices
std::cout<< driver.size()<<" device(s) found:"<< std::endl;
// go thru all devices; you have to lock the driver if this multi-threaded
for (auto device: driver){
// return an int from an IOCTL served by the driver
int my_data= device.ioctl<int>(kMyIoctl);
}
catch (const dx::exception& exception) {
std::cerr<< exception<< std::endl;
}
}
Exceptions
Incase of an error returned by the underlaying API the device class throws a dx::exception.

this is the generic device class. the template parameter defines the exception class to be thrown. the device class uses the driver interface helper class to construct the device object and to bind the device to the driver identified by the GUID.

example:

try{ // guard the block
// choose a driver
dx::driver<>driver(GUID_MYDEVICE);
// enumerate devices
std::cout<<driver.size()<<" device(s) found:"<<std::endl;
// go thru all devices; you have to lock the driver if this multi-threaded
for (dx::driver<>::iterator i=driver.begin();i!=driver.end();i++){
// select a device
dx::reference<dx::device<> >device=*i;
// return an int from an IOCTL served by the driver
int my_data=device->ioctl<int>(kMyIoctl);
}
catch(dx::os_result error) {
std::cerr << "OS aborted operation with error #" << error << std::endl;
}
}
Exceptions
incase of an error returned by the underlaying API the device class throws an exception converted from dx::os_result. with the default exception_t=dx::os_result template parameter the dx::os_result itself will be thrown.

Member Typedef Documentation

◆ creator

typedef ::io_service_t dx::device::creator

Constructor & Destructor Documentation

◆ device() [1/2]

dx::device::device ( ::io_service_t  io_service)
inline

the device class constructor

Exceptions
kIOReturnNoMemory means that the system couldn't allocate the class defined in the drivers plist, or nub which ever its trying connecting to

Constructs and open device,

connects notification port

Parameters
io_servicethe IOService object to open the device connection for. This will be hold (but not retained) during device class lifetime
+ Here is the call graph for this function:

◆ device() [2/2]

dx::device::device ( const creator creator)
inline

the device class constructor

the underlaying windows API is RegisterDeviceNotification(). for detailed information see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363431(v=vs.85).aspx

Exceptions
n/amicrosoft does not give information about what possible errors values are provided by its OS

◆ ~device()

virtual dx::device::~device ( )
inlinevirtualnoexcept

Member Function Documentation

◆ catchall_rethrow()

dx::device::catchall_rethrow ( )
inlinenoexcept

the device class destructor

the underlaying IOKit API is IOServiceClose().

remark: The io_service reference itself is managed by inherited io::reference

for detailed information see

Disconnect notification port,

closes the connection to the IOService object

◆ conclude() [1/2]

virtual void dx::device::conclude ( )
inlinevirtualnoexcept

conclude notification: device will be removed from tree

Reimplemented in dx::usb::device, and dx::coreaudio::device< io_t, bus_t, desc_t >.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ conclude() [2/2]

virtual void dx::device::conclude ( )
inlinevirtual

conclude notifacation: device will be removed from tree

Reimplemented in dx::usb::device, and dx::coreaudio::device< io_t, bus_t, desc_t >.

◆ ctl() [1/2]

void dx::device::ctl ( unsigned int  ioctl) const
inline

◆ ctl() [2/2]

void dx::device::ctl ( unsigned int  ioctl) const
inline

◆ erase() [1/2]

registry& dx::registry::erase ( const char *  key = nullptr)
inlineinherited

◆ erase() [2/2]

preference& dx::cf::preference::erase ( ::CFStringRef  key = nullptr)
inlineinherited
+ Here is the caller graph for this function:

◆ get() [1/7]

::CFTypeRef dx::io::registry::get ( ::CFStringRef  key) const
inlineinherited

◆ get() [2/7]

::CFTypeRef dx::io::registry::get ( ::CFStringRef  key,
::CFTypeRef  dflt 
) const
inlinenoexceptinherited

◆ get() [3/7]

template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t dx::io::registry::get ( ::CFStringRef  key) const
inlineinherited

◆ get() [4/7]

template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t dx::io::registry::get ( ::CFStringRef  key,
::CFTypeRef  dflt 
) const
inlinenoexceptinherited

◆ get() [5/7]

template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t dx::io::registry::get ( ::CFStringRef  key,
value_t  dflt 
) const
inlinenoexceptinherited

◆ get() [6/7]

template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
::CFTypeRef dx::io::registry::get ( key_t  key) const
inlineinherited

◆ get() [7/7]

template<typename key_t , typename value_t , typename = typename cf::enable_if_convertible<key_t>::type, typename = typename cf::enable_if_convertible<value_t>::type>
value_t dx::io::registry::get ( key_t  key) const
inlineinherited

◆ ictl() [1/4]

template<typename rx_t >
rx_t dx::device::ictl ( unsigned int  ioctl) const
inline

member ioctl

this member retreives data from the device by providing an IOCTL code. the template argument defines the type of data to be retreived. this member is intended as a convinient way to retreive only small amounts of data since there is an intermediate stack copy involved in returning the data.

+ Here is the caller graph for this function:

◆ ictl() [2/4]

template<typename rx_t >
size_t dx::device::ictl ( unsigned int  ioctl,
rx_t &  rx 
) const
inline

◆ ictl() [3/4]

template<typename rx_t >
rx_t dx::device::ictl ( unsigned int  ioctl) const
inline

Windows: member ioctl.

this member retreives data from the device by providing an IOCTL code. the template argument defines the type of data to be retreived. this member is intended as a convinient way to retreive only small amounts of data since there is an intermediate stack copy involved in returning the data.

the underlaying windows API is DeviceIoControl(). for detailed information see http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx

Exceptions
n/amicrosoft does not give information about what possible errors values are provided by its OS other than
ERROR_INSUFFICIENT_BUFFERif the output buffer is too small to receive any data

◆ ictl() [4/4]

template<typename rx_t >
size_t dx::device::ictl ( unsigned int  ioctl,
rx_t &  rx 
) const
inline

◆ initialize() [1/2]

void dx::registry::initialize ( const char *  path,
::HKEY  root,
::REGSAM  rights = KEY_READ,
const char *  key = nullptr 
)
inlineinherited
+ Here is the caller graph for this function:

◆ initialize() [2/2]

void dx::registry::initialize ( const char *  path,
::REGSAM  rights = KEY_READ,
::HKEY  root = HKEY_CURRENT_USER,
const char *  key = nullptr 
)
inlineinherited
+ Here is the call graph for this function:

◆ ioctl() [1/5]

template<typename rx_t , typename tx_t >
size_t dx::device::ioctl ( unsigned int  ioctl,
const tx_t &  tx,
rx_t &  rx 
) const
inline

◆ ioctl() [2/5]

template<typename rx_t , typename tx_t >
rx_t dx::device::ioctl ( unsigned int  ioctl,
const tx_t &  tx 
) const
inline

◆ ioctl() [3/5]

size_t dx::device::ioctl ( unsigned int  ioctl,
const void *  tx = nullptr,
size_t  tx_size = 0,
void *  rx = nullptr,
size_t  rx_size = 0 
) const
inline

◆ ioctl() [4/5]

template<typename tx_t , typename rx_t >
size_t dx::device::ioctl ( unsigned int  ioctl,
const tx_t &  tx,
rx_t &  rx 
) const
inline

◆ ioctl() [5/5]

template<typename rx_t , typename tx_t >
rx_t dx::device::ioctl ( unsigned int  ioctl,
const tx_t &  tx 
) const
inline

◆ launch() [1/2]

virtual void dx::device::launch ( )
inlinevirtual

launch notification: device mounted in tree and ready to use

Reimplemented in dx::usb::device, and dx::coreaudio::device< io_t, bus_t, desc_t >.

◆ launch() [2/2]

virtual void dx::device::launch ( )
inlinevirtual

launch notifacation: device mounted in tree and ready to use

Reimplemented in dx::usb::device, and dx::coreaudio::device< io_t, bus_t, desc_t >.

◆ octl() [1/2]

template<typename tx_t >
void dx::device::octl ( unsigned int  ioctl,
const tx_t &  tx 
) const
inline
+ Here is the caller graph for this function:

◆ octl() [2/2]

template<typename tx_t >
void dx::device::octl ( unsigned int  ioctl,
const tx_t &  tx 
) const
inline

◆ operator const io_registry_entry_t &()

dx::io::reference< io_registry_entry_t >::operator const io_registry_entry_t & ( ) const
inlineinherited

auto converter into const object

◆ operator io_registry_entry_t &()

dx::io::reference< io_registry_entry_t >::operator io_registry_entry_t & ( )
inlineinherited

auto converter into object

◆ operator std::string()

dx::registry::operator std::string ( ) const
inlineinherited

◆ operator uint64_t()

dx::io::registry::operator uint64_t ( ) const
inlineexplicitinherited

◆ operator value_t() [1/2]

template<typename value_t >
dx::registry::operator value_t ( ) const
inlineinherited

◆ operator value_t() [2/2]

template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
dx::cf::preference::operator value_t ( ) const
inlineinherited

◆ operator()() [1/4]

template<typename value_t >
value_t dx::registry::operator() ( value_t  dflt) const
inlineinherited

◆ operator()() [2/4]

::CFPropertyListRef dx::cf::preference::operator() ( ::CFPropertyListRef  dflt) const
inlineinherited

◆ operator()() [3/4]

::CFDictionaryRef dx::cf::preference::operator() ( ::CFDictionaryRef  dflt) const
inlinenoexceptinherited

◆ operator()() [4/4]

template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
value_t dx::cf::preference::operator() ( value_t  dflt) const
inlineinherited

◆ operator::CFArrayRef()

dx::cf::preference::operator::CFArrayRef ( ) const
inlinenoexceptinherited

◆ operator::CFDictionaryRef()

dx::cf::preference::operator::CFDictionaryRef ( ) const
inlinenoexceptinherited

◆ operator::CFMutableDictionaryRef()

dx::io::registry::operator::CFMutableDictionaryRef ( ) const
inlineexplicitinherited

◆ operator::CFPropertyListRef()

dx::cf::preference::operator::CFPropertyListRef ( ) const
inlineinherited

◆ operator::HANDLE()

dx::device::operator::HANDLE ( ) const
inlinenoexcept

◆ operator=() [1/3]

registry& dx::device::operator= ( ::CFTypeRef  properties)
inline

◆ operator=() [2/3]

device& dx::device::operator= ( const union log log)
inline

◆ operator=() [3/3]

device& dx::device::operator= ( const union log log)
inline

◆ operator==()

bool dx::io::reference< io_registry_entry_t >::operator== ( io_registry_entry_t  object) const
inlinenoexceptinherited

◆ operator[]() [1/5]

registry dx::registry::operator[] ( const char *  key) const
inlineinherited
+ Here is the call graph for this function:

◆ operator[]() [2/5]

::CFTypeRef dx::io::registry::operator[] ( ::CFStringRef  key) const
inlineinherited

◆ operator[]() [3/5]

template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
::CFTypeRef dx::io::registry::operator[] ( key_t  key) const
inlineinherited

◆ operator[]() [4/5]

preference dx::cf::preference::operator[] ( ::CFStringRef  key) const
inlineinherited

◆ operator[]() [5/5]

template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
preference dx::cf::preference::operator[] ( key_t  key) const
inlineinherited

◆ set() [1/5]

registry& dx::device::set ( ::CFTypeRef  properties)
inline

Setting properties in a registry entry is not generally supported, it is more common to support setting of properties of the connection based property setting of dx::device.

◆ set() [2/5]

registry& dx::device::set ( ::CFStringRef  key,
::CFTypeRef  value 
)
inlinenoexcept

◆ set() [3/5]

template<typename value_t , typename = typename cf::enable_if_convertible<value_t>::type>
registry& dx::device::set ( ::CFStringRef  key,
value_t  value 
)
inline

◆ set() [4/5]

template<typename key_t , typename = typename cf::enable_if_convertible<key_t>::type>
registry& dx::device::set ( key_t  key,
::CFTypeRef  value 
)
inline

◆ set() [5/5]

template<typename key_t , typename value_t , typename = typename cf::enable_if_convertible<key_t>::type, typename = typename cf::enable_if_convertible<value_t>::type>
registry& dx::device::set ( key_t  key,
value_t  value 
)
inline

◆ signal()

registry& dx::registry::signal ( )
inlineinherited
+ Here is the caller graph for this function:

◆ wait()

registry& dx::registry::wait ( int64_t  timeout = 0,
::DWORD  filter = REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_ATTRIBUTES|REG_NOTIFY_CHANGE_LAST_SET|REG_NOTIFY_CHANGE_SECURITY,
bool  subtree = true 
)
inlineinherited

Member Data Documentation

◆ bundle_id

cf::type<const char*> dx::device::bundle_id

◆ class_name

cf::type<const char*> dx::device::class_name

◆ kernel

struct { ... } dx::device::kernel

◆ log

dx::log dx::device::log {}

◆ port

io::port dx::device::port
protected

◆ preference [1/2]

cf::preference dx::device::preference

◆ preference [2/2]

registry dx::device::preference

The documentation for this class was generated from the following file:

(c) copyright 2009 dynamic acoustics e.U. generated on Sat Aug 22 2020

a closed source license may be obtained by requesting a written permission from dynamic acoustics e.U.
however - governmental use generally and military use especially is strictly prohibited though.