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

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

{

throw *this;

}

The _raise function allows exception-aware code to transform an IDL exception received as a parameter into a real C++ exception. Unless you need to mix non- exception-aware and exception-aware source code, you will not need to call _raise. As you can see from its implementation, _raise simply throws the corresponding exception.

_raise is also useful for clients using the Dynamic Invocation Interface because it enables the client to rethrow an exception without knowing its precise type.

7.16 Mapping for Contexts

If an IDL operation uses a context clause, the corresponding C++ operation signature has an extra trailing parameter. For example:

interface Foo {

string get_name(in long id) context("USER", "GROUP", "X*");

};

This generates the following operation signature:

char * get_name(CORBA::Long id, CORBA::Context_ptr c);

The extra parameter is a reference to a pseudo-object of type CORBA::Context. The Context object has methods you can call to create and modify context variables. You can also connect multiple context objects into hierarchies, so that objects higher in the hierarchy provide default values and objects lower in the hierarchy override these defaults.

Because of the problems we outlined in Section 4.13, we do not show the mapping for contexts in this book. You can consult the specification [17a] for details.

7.17 Summary

The client-side C++ mapping provides APIs that permit clients to initialize the ORB run time, obtain object references, invoke operations, and handle exceptions. To preserve location transparency and efficiency, the client-side mapping has complex memory management rules for fixedand variable-length types. The complexity of these rules can be overcome by judicious use of _var types, which hide much of the low-level memory management responsibilities from you and make errors less likely.

291

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

Despite its apparent complexity, the client-side mapping quickly becomes second nature. After a few days of programming, you will be less and less concerned with the mapping and handle most CORBA programming tasks as routinely as any other programming task.

292