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").
"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.
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 |