User`s guide

Implementing Get and Set Support for Device-Specific Properties
6-13
Example
This example shows an implementation of a getValue() function for integer types:
void MyDevicePropGetListener::getValue(IPropInfo* propertyInfo,
void* value)
{
// Get property name from the IPropInfo object.
const char* propname = propertyInfo->getPropertyName();
// Get the value using whatever facility your device's SDK provides.
*reinterpret_cast<const int*>(value) = sdk_function_get();
// For debug purposes only.
imaqkit::adaptorWarn("In listener. Property name is %s\n",propname);
}
Associating Get 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 get listeners for all
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 =
getEngine()->getAdaptorPropContainer();
2
Add a get listener to a property in the container, using the IPropContainer object
setCustomGetFcn() function. As arguments, specify the property name and a
handle to the listener object.
Note Because the toolbox deletes each instance of a listener object when a user
deletes the video input object, associate a new instance of a listener object with each
property.