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

10.4 Publishing objects using ISInfoDynAny

The ISInfoDynAny class can be used as well for publishing objects of the information types which are not known at compilation time. However this does not mean that the types can be dynamically constructed at run-time. Contrary to that the ISInfoDynAny allows to create and publish objects whose types are available in the IS Meta-information repository (see Section , "Reading information type description").


This feature is practically useless and even dangerous for a normal application. It shall be used carefully only by a very special class of applications, for example for establishing a bridge from some external information service to IS or for implementing a generic GUI application which provides a way of modifying any information in the repository.

"Listing 10.5" shows how to create an instance of the ISInfoDynAny class, which mimics the structure of the class "Person", which has its description available in the IS Meta-information repository.

Listing 10.5   Creating and publishing dynamic information

1: // include IS header file
2: #include <is/infodynany.h>
3: #include <is/infodictionary.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: ISInfoDynAny person( partition, "Person" );
14:
15: person.getAttributeValue( "name" ) = "John";
16: person.getAttributeValue( "birth_date" ) = OWLDate( "23/11/2001" );
17: person.getAttributeValue( "sex" ) = 0; // male
18:
19: ISInfoDictionary id( partition );
20:
21: is.checkin( "MyServer.John", person );
22:
23: return 0;
24: }
25:

For simplicity the type checks and exception handling is omitted in this example, but any real world application must have them included. For example the ISInfoDynAny constructor in the line 12 may throw the daq::is::DocumentNotFound exception if the IS Meta-information repository is not available or does not contain the "Person" type description. The lines 15-17 may throw the daq::is::AttributeNotFound exception if the type does not contain an attribute with the given name. In addition, the value which is assigned to the attribute must be of the correct type (i.e. of the same type as defined for this attribute - use ISInfoDynAny::getAttributeType to verify it), otherwise unmanageable assertion will be made leading to the crash of the application.

 


2 July 1998 - WebMaster
Copyright © CERN 1998