CERN -> IPT Group -> FrameMaker at CERN
Information Service User's Guide

8.2 Simple usage of the IS information stream

Program in "Listing 8.1" shows how to read all information objects from the given IS server using ISInfoStream class.

Listing 8.1   Using the IS information iterator

1: // include main IS header file
2: #include <is/infostream.h>
3: #include <ipc/core.h>
4:
5: int main( int ac, char ** av )
6: {
7: // Initialise communication library
8: IPCCore::init( ac, av );
9:
10: // Create the instance of partition
11: IPCPartition partition("MyPartition");
12:
13: ISInfoStream in( p, "MyServer" );
14: while( !in.eof() )
15: {
16: std::cout << in.name() << " : " << in.type() << std::endl;
17: ISInfoAny isa;
18: in >> isa;
19: std::cout << isa << std::endl;
20: }
21: return 0;
22: }

In line 13 the ISInfoStream is created for the "MyServer" IS server. The lines 14-20 show how to retrieve information from the ISInfoStream. Each call to the stream input operator removes the head object from the stream and assigns it to the given ISInfo object. Before calling it next time a program must the that the stream is not empty by calling the ISInfoStream::eof function (line 14).


There is very important distinction between the ISInfoStream public functions (like name and type) which return the respective attributes of the IS object at the current stream position and the ISInfoStream input operator function. While the former ones do not change the current streams position and can be called many times returning always the same result, the input operator removed the current object from the stream after reading it and changes the current stream position to the next available object.


2 July 1998 - WebMaster
Copyright © CERN 1998