User`s guide
Implementing Get and Set Support for Device-Specific Properties
6-17
Alternatively, you could define a separate set listener class for each property or each
property storage type. Then, the engine calls the specific listener for the property
specified.
You also can define set listener classes that fit the way the SDK organizes property
configuration. For example, if an SDK provides one function to configure all device
properties, you can define a set listener class for these properties.
Example
This example shows an implementation of a notify() function for integer types:
void MyDevicePropSetListener::notify(IPropInfo* propertyInfo,
void* newValue)
{
// Get property name from the IPropInfo object.
const char* propname = propertyInfo->getPropertyName();
// Cast newValue to the proper type
newVal = *reinterpret_cast<const int*>(newValue);
// *****************************************************
// Insert calls to device SDK to apply value to hardware.
// *****************************************************
// For debug purposes only.
imaqkit::adaptorWarn("In listener. Property name is %s\n",propname);
}
Associating Set Listeners with Properties
To set up a listener for a property, you associate the listener object with the property in
the property container. The following example shows how to add set listeners for all the
device-specific properties in the adaptor property container. Adaptor writers typically
set up property listeners in their adaptor class constructor—see “Implementing Your
Adaptor Class Constructor” on page 4-12.
1
Get a handle to the appropriate property container object.
The IEngine object has two member functions that return handles to property
containers (IPropContainer objects). The example calls the IEngine class
getAdaptorPropContainer() member function to get the device-specific property
container:
imaqkit::IPropContainer* adaptorPropContainer =