![]() |
Home | Libraries | Author | Links |
This class can be instantiated or be used as base class of a special Windows device class which may reimplement the interface of stm::W32Device as well as that of the abstract base class stm::Device.
Definition at line 128 of file w32device.hpp.
Public Types | |
enum | DescribeFlags { DevicePath = DriverVersion << 1, DeviceInstance = DevicePath << 1, DeviceIfClass = DeviceInstance << 1 } |
Describe flags (bitwise orable). More... | |
Public Member Functions | |
W32Device (int defaultTimeout=Forever, const Descriptor &descr=Descriptor()) | |
Constructor of a W32Device object representing a Windows device described by descr. | |
virtual | ~W32Device () |
Destructor. | |
virtual bool | canRead () const |
Return the read capability of this W32Device. | |
virtual bool | canWrite () const |
Return the write capability of this W32Device. | |
virtual bool | canControl () const |
Return the control capability of this W32Device. | |
virtual int | error () const |
Return the error state of this W32Device. | |
virtual void | setError (int error, const std::string &msg=std::string()) const |
Set the error state and error string of this W32Device according to error and msg. | |
virtual void | clearError () const |
Clear the error state and error string of this W32Device. | |
virtual bool | isOpen () const |
Determine, if this W32Device is open. | |
virtual bool | open (unsigned int openMode) |
Open this W32Device in openMode. | |
virtual bool | close () |
Close this W32Device. | |
virtual int64_t | read (void *data, int64_t maxLen, int timeout=DefaultTimeout, unsigned int flags=NoFlags) |
Read maxLen bytes from this W32Device into the data buffer. | |
virtual int64_t | write (const void *data, int64_t len, int timeout=DefaultTimeout, unsigned int flags=NoFlags) |
Write len bytes from the data buffer to this W32Device. | |
virtual int64_t | control (unsigned int request, const void *inData, int64_t inLen, void *outData, int64_t maxOutLen, int timeout=DefaultTimeout, unsigned int flags=NoFlags) const |
Perform the control operation request on this W32Device. | |
virtual std::ostream & | describe (std::ostream &os, unsigned int flags=DefaultProperties) const |
Insert a description of this W32Device into os. | |
bool | isA (const InterfaceClass &interfaceClass) const |
The method returns true, if this W32Device is a device supporting the Windows device interface class described by interfaceClass. | |
template<class ForwardIterator> | |
bool | isA (ForwardIterator beginInterfaceClass, ForwardIterator endInterfaceClass) const |
The method template returns true, if this W32Device is a device supporting one of the the Windows device interface classes whose description is contained in the half open interval [*beginInterfaceClass, *endInterfaceClass). | |
Static Public Member Functions | |
static size_t | enumerate (std::vector< Descriptor > &descriptors, const InterfaceClass &interfaceClass, bool append=false) |
Enumerate all Device::Descriptor objects describing Windows devices supporting the Windows device interface class described by interfaceClass. | |
template<class ForwardIterator> | |
static size_t | enumerate (std::vector< Descriptor > &descriptors, ForwardIterator beginInterfaceClass, ForwardIterator endInterfaceClass, bool append=false) |
Enumerate all Device::Descriptor objects describing Windows devices supporting one of the the Windows device interface classes whose description is contained in the half open interval [*beginInterfaceClass, *endInterfaceClass). | |
Classes | |
struct | InterfaceClass |
Type describing a Windows device interface class. More... |
Describe flags (bitwise orable).
The enumerators of W32Device::DescribeFlags augment the Device::DescribeFlags further specifying the extent produced by describe().
Reimplemented from stm::Device.
Definition at line 137 of file w32device.hpp.
stm::W32Device::W32Device | ( | int | defaultTimeout = Forever , |
|
const Descriptor & | descr = Descriptor() | |||
) |
Constructor of a W32Device object representing a Windows device described by descr.
[in] | defaultTimeout | Timeout in milliseconds used by default for all operations of this W32Device. |
[in] | descr | A valid Device::Descriptor of the Windows device to be represented by the W32Device object to be constructed or an invalid Device::Descriptor. A valid Device::Descriptor is typically yielded by one of the static methods enumerate() or enumerateAll(). |
virtual stm::W32Device::~W32Device | ( | ) | [virtual] |
virtual bool stm::W32Device::canRead | ( | ) | const [virtual] |
Return the read capability of this W32Device.
true
. It is not necessary that this W32Device is open.
Reimplemented from stm::Device.
virtual bool stm::W32Device::canWrite | ( | ) | const [virtual] |
Return the write capability of this W32Device.
true
. It is not necessary that this W32Device is open.
Reimplemented from stm::Device.
virtual bool stm::W32Device::canControl | ( | ) | const [virtual] |
Return the control capability of this W32Device.
true
. It is not necessary that this W32Device is open.
Reimplemented from stm::Device.
virtual int stm::W32Device::error | ( | ) | const [virtual] |
Return the error state of this W32Device.
Reimplemented from stm::Device.
virtual void stm::W32Device::setError | ( | int | error, | |
const std::string & | msg = std::string() | |||
) | const [virtual] |
Set the error state and error string of this W32Device according to error and msg.
[in] | error | Error state as one of the enumerators of Device::ErrorState optionally ored with one ore more of the enumerators of Device::ErrorFlags. |
[in] | msg | Error string. |
It is not necessary that this W32Device is open.
Reimplemented from stm::Device.
virtual void stm::W32Device::clearError | ( | ) | const [virtual] |
Clear the error state and error string of this W32Device.
It is not necessary that this W32Device is open.
Reimplemented from stm::Device.
virtual bool stm::W32Device::isOpen | ( | ) | const [virtual] |
Determine, if this W32Device is open.
true
, if this W32Device is open, that is if its open mode is not the Device::OpenMode enumerator Device::NoAccess.
false
, if this W32Device is not open, that is if its open mode is the Device::OpenMode enumerator Device::NoAccess.
Reimplemented from stm::Device.
virtual bool stm::W32Device::open | ( | unsigned int | openMode | ) | [virtual] |
Open this W32Device in openMode.
[in] | openMode | Open mode to be set. |
true
, if this W32Device could be opened in openMode.
false
, if this W32Device could not be opened in openMode. Then the error state of this W32Device is set to Device::OpenError.
Reimplemented from stm::Device.
virtual bool stm::W32Device::close | ( | ) | [virtual] |
Close this W32Device.
true
, if this W32Device could be closed successfully.
false
, if this W32Device could not be closed successfully. Then the error state of this W32Device is set to Device::CloseError.
Reimplemented from stm::Device.
virtual int64_t stm::W32Device::read | ( | void * | data, | |
int64_t | maxLen, | |||
int | timeout = DefaultTimeout , |
|||
unsigned int | flags = NoFlags | |||
) | [virtual] |
Read maxLen bytes from this W32Device into the data buffer.
[out] | data | Buffer for the data to be read. |
[in] | maxLen | Maximal number of bytes to be read. |
[in] | timeout | Operation timeout in milliseconds. If the value is Device::Forever, no timeout occurs. The default value Device::DefaultTimeout means, that the default timeout of this W32Device is used. |
[in] | flags | If the flag bit Device::AcceptTimeout is set, a timeout is no error. |
-1
, if the read operation was not successful. Then the error state of this W32Device is set to Device::ReadError.
Reimplemented from stm::Device.
virtual int64_t stm::W32Device::write | ( | const void * | data, | |
int64_t | len, | |||
int | timeout = DefaultTimeout , |
|||
unsigned int | flags = NoFlags | |||
) | [virtual] |
Write len bytes from the data buffer to this W32Device.
[in] | data | Buffer containing the data to be written. |
[in] | len | Number of bytes to be written. |
[in] | timeout | Operation timeout in milliseconds. If the value is Device::Forever, no timeout occurs. The default value Device::DefaultTimeout means, that the default timeout of this W32Device is used. |
[in] | flags | If the flag bit Device::AcceptTimeout is set, a timeout is no error. |
-1
, if the write operation was not successful. Then the error state of this W32Device is set to Device::WriteError.
Reimplemented from stm::Device.
virtual int64_t stm::W32Device::control | ( | unsigned int | request, | |
const void * | inData, | |||
int64_t | inLen, | |||
void * | outData, | |||
int64_t | maxOutLen, | |||
int | timeout = DefaultTimeout , |
|||
unsigned int | flags = NoFlags | |||
) | const [virtual] |
Perform the control operation request on this W32Device.
[in] | request | Specifies the particular control operation to be performed. |
[in] | inData | Buffer containing the input data for the control operation. |
[in] | inLen | Number of bytes of the input data. |
[out] | outData | Buffer for the output data generated by the control operation. |
[in] | maxOutLen | Maximal number of the output data. |
[in] | timeout | Operation timeout in milliseconds. If the value is Device::Forever, no timeout occurs. The default value Device::DefaultTimeout means, that the default timeout of this W32Device is used. |
[in] | flags | If the flag bit Device::AcceptTimeout is set, a timeout is no error. |
-1
, if the operation was not successful. Then the error state of this W32Device is set to the Device::ErrorState enumerator Device::ControlError.
Reimplemented from stm::Device.
virtual std::ostream& stm::W32Device::describe | ( | std::ostream & | os, | |
unsigned int | flags = DefaultProperties | |||
) | const [virtual] |
Insert a description of this W32Device into os.
[in] | os | The output stream to insert the description. |
[in] | flags | Description flags. |
Reimplemented from stm::Device.
bool stm::W32Device::isA | ( | const InterfaceClass & | interfaceClass | ) | const |
The method returns true, if this W32Device is a device supporting the Windows device interface class described by interfaceClass.
That means it returns true, if the Device::Descriptor of this W32Device describes a Windows device supporting the Windows device interface class described by interfaceClass, else false.
bool stm::W32Device::isA | ( | ForwardIterator | beginInterfaceClass, | |
ForwardIterator | endInterfaceClass | |||
) | const |
The method template returns true, if this W32Device is a device supporting one of the the Windows device interface classes whose description is contained in the half open interval [*beginInterfaceClass, *endInterfaceClass).
That means it returns true, if the Device::Descriptor of this W32Device describes a Windows device supporting one of the Windows device interface classes described by that interval, else false.
static size_t stm::W32Device::enumerate | ( | std::vector< Descriptor > & | descriptors, | |
const InterfaceClass & | interfaceClass, | |||
bool | append = false | |||
) | [static] |
Enumerate all Device::Descriptor objects describing Windows devices supporting the Windows device interface class described by interfaceClass.
The static method clears the vector descriptors, scans the system for all Windows devices supporting the Windows device interface class described by interfaceClass, stores the Device::Descriptor objects describing those devices in the vector descriptors and returns the size of that vector.
static size_t stm::W32Device::enumerate | ( | std::vector< Descriptor > & | descriptors, | |
ForwardIterator | beginInterfaceClass, | |||
ForwardIterator | endInterfaceClass, | |||
bool | append = false | |||
) | [static] |
Enumerate all Device::Descriptor objects describing Windows devices supporting one of the the Windows device interface classes whose description is contained in the half open interval [*beginInterfaceClass, *endInterfaceClass).
The static method template clears the vector descriptors, scans the system for all Windows devices supporting one of the Windows device interface classes described by that interval, stores the Device::Descriptor objects describing those devices in the vector descriptors and returns the size of that vector.
© Copyright Tom Michaelis 2002-2007
Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).