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

3.5 Using custom information types

3.5.1 Using classes based on the ISInfo

Usage of the custom IS classes, based on the ISInfo class, is quite straightforward - they are used exactly in the same way as the simple IS types which were explained in the previous chapter. "Listing 3.1" shows, for example, how to publish information of the type Person (see Appendix B for the Person class declaration).

Listing 3.1   Publishing and updating custom information using classes based on the ISInfo

1: // include header file generated for the Person class
2: #include <Person.h>
3: #include <is/infodictionary.h>
4: #include <ipc/core.h>
5:
6: int main( int ac, char ** av ){
7: // Initialise communication library
8: IPCCore::init( ac, av );
9:
10: // Create the instance of partition
11: IPCPartition partition(partition_name);
12:
13: // Create the IS dictionary instance
14: // using the partitition object as parameter
15: ISInfoDictionary dict(partitition);
16:
17: // Create the instance of the information
18: // that will be published, and initialise it
19: Person person;
20: person.name = "Jone";
21: person.sex = Male;
22: person.birth_date = OWLDate( "24/09/83" );
23:
24: // Publish information
25: dict.insert( "MyServer.Person1", person );
26:
27: // Update person's information
28: person.name = "Jone Smith";
29:
30: // Update information in the IS
31: dict.update( "MyServer.Person1", person );
32:
33: return 0;
34: }

3.5.2 Using classes based on the ISNamedInfo

The ISNamedInfo class inherits the ISInfo and therefore provides the same interface for the information declaration. But in addition to that it has a number of public methods to work with the IS repository. A program can create an instance of the custom information class based on the ISNamedInfo and use the methods of the ISNamedInfo class to insert this information into the IS, to update it or to remove from it from the IS. In another words, this class combines features provided by the ISInfo and ISInfoDictionary classes. For example, "Listing 3.2" shows how to publish information of type Person using the PersonNamed class which inherits the ISNamedInfo (see Appendix C for the PersonNamed class declaration).

Listing 3.2   Publishing and updating custom information using classes based on the ISNamedInfo

1: // include header file generated for the Person class
2: #include <PersonNamed.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(partition_name);
12:
13: // Create the instance of the information
14: // that will be published, and initialise it
15: PersonNamed person( partitition, "MyServer.Person1" );
16: person.name = "Jone";
17: person.sex = Male;
18: person.birth_date = OWLDate( "24/09/83" );
19:
20: // Publish information with the name "MyServer.Person1"
21: // If information with this name already exists it will
22: // be updated
23: person.chekin( );
24:
25: // Describe another person
26: person.name = "Elena";
27: person.sex = Female;
28: person.birth_date = OWLDate( "21/07/85" );
29:
30: // Set new IS name for the information
31: person.name( "MyServer.Person2" );
32:
33: // Publish information with the name "MyServer.Person2"
34: // If information with this name already exists it will
35: // be updated
36: person.chekin( );
37:
38: return 0;
39: }

The ISNamedInfo::checkin function (lines 23,36) is used here to put the new information value to the IS repository. This function updates the information value if the information already exists in the repository. Otherwise it inserts the new information to the repository. This is the main difference with the usage of the information classes, which inherit the ISInfo class.


2 July 1998 - WebMaster
Copyright © CERN 1998