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

9.3 Reading the IS type description

"Listing 9.1" shows how an application can get description for the Person type defined in Chapter 3.2.

Listing 9.1   Reading the Person type description

1: // include main IS header file
2: #include <is/Person.h>
3: #include <is/infodocument.h>
4: #include <ipc/core.h>
5:
6: int main( int ac, char ** av )
7: {
8: // Initialise communication library
9: IPCCore::init( ac, av );
10:
11: // Create the instance of partition
12: IPCPartition partition("MyPartition");
13:
14: Person person;
15:
16: // Create the IS information description object
17: // for the Person type
18: ISInfoDocument isd(partitition, person);
19:
20: // Print out Person's type description
21:
22: std::cout << "class " << isd.name()
23: << " { // " << isd.description() << std::endl;
24: for ( size_t i = 0; i < isd.attributeCount(); i++ )
25: {
26: const ISInfoDocument::Attribute * attr = isd.attribute(i);
27: std::cout << attr -> typeName()
28: << ( attr -> isArray() ? "[] " : " " )
29: << attr -> name()
30: << "; // " << attr -> description() << std::endl;
31: }
32: std::cout << "};" << std::endl;
33:
34: return 0;
35: }

First, the user program has to include the is/infodocument.h which declares the ISInfoDocument class. Then the program creates an instance of the IPCPartition class. This instance represents the partition in which the Information Service will be used. The ISInfoDocument class constructor takes this partition object as first argument. The second argument is the class for the valid IS information type, which is the Person class in this example.Then, lines 19-27 show how to get the Person type description using the methods of the ISInfoDocument class.


2 July 1998 - WebMaster
Copyright © CERN 1998