User`s guide
6 Defining Device-Specific Properties
6-10
Implementing Get and Set Support for Device-Specific Properties
After connecting to a device through your adaptor, users might want to view or modify
values of the properties of the device. For example, a user might adjust the value of the
Brightness property or retrieve the current value of the Temperature property. (For
information about how to define the properties you want to expose to users, see “Creating
Device Properties” on page 6-5.)
To receive notification from the engine when a user wants to view or modify a property,
associate a listener object with the property. The toolbox defines two types of listener
classes: get listeners that respond to get commands and set listeners that respond to set
commands.
To provide support for getting and setting property values, follow this procedure:
1
Define a listener class of the appropriate type. The toolbox defines two abstract
classes, one for get listeners and one for set listeners, from which you derive your
class.
2
Implement the virtual function required by the class.
3
Associate an instance of your listener class with the property.
The following sections describe how to set up get listeners and set listeners and in your
adaptor.
Setting Up Get Listeners in Your Adaptor
To receive notification from the engine when a user requests the current value of a
property using the get command:
1
Define a get listener class, deriving it from the IPropCustomGetFcn abstract class
—see “Defining a Get Listener Class” on page 6-10.
2
Implement the getValue() virtual function in your listener class—see “Creating
the getValue() Function for Your Class” on page 6-11.
3
Associate an instance of your listener class with a property—see “Associating Get
Listeners with Properties” on page 6-13.
Defining a Get Listener Class
Create a get listener class, deriving it from the abstract class IPropCustomGetFcn, as
shown in the following example.