"Listing 8.1" shows what an application has to do in order to be able to receive commands, which are sent to the information objects provided by this application.
First, the user program has to include the is/infoprovider.h which declares the ISInfoProvider and ISCommandListener classes. Then it is necessary to declare the command listener class, which has to inherit the ISCommandListener and override a single pure virtual function defined in this class. In the above example this is done by lines 5-13. The user's command listener class is called MyCommandListener. This class provides implementation of the command function. This function will be called when a command to this information provider is received. It has two arguments: first one is a command itself and the second one is the name of the information object, to which this command has been sent.
Then the program creates the instance of the MyCommandListener class and activates this instance using the ISInfoProvider::addCommandListener function (line 23). Only after the call to the addCommandListener function, the user's command listener will be able to receive commands. The counterpart of the addCommandListener function is the ISInfoProvider::removeCommandListener one, which can be used to deactivate a particular command listener as it is shown in line 26.
2 July 1998 - WebMaster | Copyright © CERN 1998 |