"Listing 6.1" shows how to an application can subscribe for an individual information in the IS repository.
First the user program has to include the is/info.h header file which declares the ISInfoReceiver class. This class provides the main interface for the information subscribers. Then the program creates an instance of the IPCPartition class. This instance represents the partition in which the Information Service will be used. The ISInfoReceiver class constructor takes this partition object as parameter.
Line 25 shows how to subscribe for the changes of the information called "MyServer.DeviceVoltage". Line 30 shows how to block the current thread to prevent it from exiting immediately. This example calls the run method of the ISInfoReceiver class to do this. This method is implemented by the IPCServer class from which the ISInfoReceiver inherits. For more information about the IPCServer class see [9]. But of course this is not mandatory, a user can use his own way of blocking the thread till it is necessary.
When the "MyServer.DeviceVoltage" information is changed the callback function is called. The isc argument (line 4) is a pointer to the object that describes the information changes. One can get name, type and value of the changed information from this object. In addition it can also be used to get the reason why the callback has been called. The valid reasons are: information has been inserted, updated or removed from the IS repository.
2 July 1998 - WebMaster | Copyright © CERN 1998 |