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

6.2 Using the IS server iterator

"Listing 6.1" shows how an application can enumerate all the valid IS servers in the specific IPC partition.

Listing 6.1   Using the IS server iterator

1: // include main IS header file
2: #include <is/infoiterator.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: // Create the IS server iterator instance
14: // using the partitition object as parameter
15: ISServerIterator it(partitition);
16:
17: // Print all the IS servers names
18:
19: std::cout << partition.name() << " has " << ii.entries() << " IS servers : " << endl;
20: while ( it() )
21: std::cout << it.name() << std::endl;
22: return 0;
23: }

First the user program has to include the is/info.h header file which declares the ISServerIterator class. Then the program creates the instance of the IPCPartition class. This instance represents the partition in which the Information Service will be used. The ISServerIterator class constructor takes this partition object as parameter. Then, lines 20-21 show how to use this iterator to get back names of all the valid IS servers in the "MyPartition" partition.


2 July 1998 - WebMaster
Copyright © CERN 1998