User`s guide

3 Providing Hardware Information
3-18
The demo adaptor provides an example, defining a class to hold additional format
information. This class, named DemoDeviceFormat, stores format information
such as width, height, and color space. The following example, taken from the demo
adaptor, shows how to instantiate an object of this derived class, assign values to
the data members of the class, and then store the object in the adaptor data of the
IDeviceFormat object.
DemoDeviceFormat* rgbFormatInfo = new DemoDeviceFormat();
rgbFormatInfo->setFormatWidth(demo::RGB_FORMAT_WIDTH);
rgbFormatInfo->setFormatHeight(demo::RGB_FORMAT_HEIGHT);
rgbFormatInfo->setFormatNumBands(demo::RGB_FORMAT_BANDS);
rgbFormatInfo->setFormatColorSpace(imaqkit::colorspaces::RGB);
deviceFormat->setAdaptorData(rgbFormatInfo);
Accessing Adaptor Data
To access the adaptor data stored in an IDeviceInfo or IDeviceFormat object, use the
getAdaptorData() member function of the object.
The following example, taken from the demo adaptor, shows how to retrieve the
adaptor data from the IDeviceFormat object. In the example, selectedFormat is a
DemoDeviceFormat object. Note that because the getAdaptorData() member function
returns a handle to the IMAQInterface class, you must cast the returned object to your
defined class.
dynamic_cast<DemoDeviceFormat*>(selectedFormat->getAdaptorData());