Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Advanced CORBA Programming wit C++ - M. Henning, S. Vinoski.pdf
Скачиваний:
57
Добавлен:
24.05.2014
Размер:
5 Mб
Скачать

IT-SC book: Advanced CORBA® Programming with C++

CORBA::TypeCode_var SearchCriterion_tc; SearchCriterion_tc = orb->create_enum_tc(

"IDL:acme.com/CCS/Controller/SearchCriterion:1.0", "SearchCriterion", es);

//

// Create type code for KeyType union.

//

CORBA::TypeCode_var KeyType_tc; KeyType_tc = orb->create_union_tc(

"IDL:acme.com/CCS/Controller/KeyType:1.0", "KeyType", SearchCriterion_tc, mem_seq

);

Again, there is nothing remarkable about this code (other than its verbosity). Clearly, you will bother to create type codes in this way if you cannot link against the IDL definition, such as for a generic protocol bridge or an object inspector. Usually, such generic applications not only use dynamic creation of type codes but also use DynAny to dynamically construct values (Chapter 17). They also use an Interface Repository that provides run-time knowledge of the data types, and use the Dynamic Invocation Interface (DII) and the Dynamic Skeleton Interface (DSI).

16.9 Summary

Type codes provide run-time type safety and introspection capabilities in CORBA. In combination with types any and DynAny, type codes provide the fundamental mechanism required to manipulate values whose types are not known at run time. Type codes enable the creation of services such as the OMG Notification Service and are essential for applications such as protocol bridges, which use the Dynamic Invocation Interface and the Dynamic Skeleton Interface and intrinsically depend on the introspection capabilities provided by type codes.

Type code comparison semantics are ill defined prior to CORBA 2.3. If you want to build applications that require precise semantics for type code comparisons, it is probably best to use a CORBA 2.3 ORB for your implementation.

638