User`s guide
Defining Classes to Hold Device-Specific Information
3-17
Defining Classes to Hold Device-Specific Information
You might want to store more information about a device or format than the
IDeviceInfo and IDeviceFormat objects allow. One way to do this is to define a
new class that contains this additional information. Then, in your adaptor, instantiate
an object of this class and store it in the adaptor data of the IDeviceInfo or
IDeviceFormat objects. Using adaptor data is a good way to pass important information
around inside your adaptor because the IDeviceInfo and IDeviceFormat objects are
passed to other adaptor functions.
Using adaptor data is a three-step process:
1
Define a class to hold the device or format information. See “Defining a Device or
Format Information Class” on page 3-17 for more information.
2
Instantiate an object of this class in your adaptor. Use the constructor you define for
your class.
3
Store the object in the adaptor data of the IDeviceInfo or IDeviceFormat object.
See “Storing Adaptor Data” on page 3-17 for more information.
Defining a Device or Format Information Class
The class that you define to store additional device or format information must be
derived from the IMAQinterface class. Subclassing the IMAQInterface class ensures
that all memory deallocations for these classes are routed through the toolbox engine.
For an example of such a class, see the DemoDeviceFormat class in the demo adaptor,
defined in the file DemoDeviceFormat.h.
Storing Adaptor Data
To store your device or format class in the adaptor data of an IDeviceInfo or
IDeviceFormat object, use the setAdaptorData() member function of the object.
Note The objects you store in adaptor data are automatically destroyed when the
IDeviceInfo and IDeviceFormat objects are destroyed. Once you store an object in
adaptor data, do not try to destroy the objects yourself.