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

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

struct S {

// Fixed-length structure

long

l_mem;

char

c_mem;

};

 

typedef S StructArray[3];

The mapping for the corresponding StructArray_var type is as follows:

class StructArray_var { public:

StructArray_var(); StructArray_var(StructArray_slice *); StructArray_var(const StructArray_var &); ~StructArray_var();

StructArray_var & operator=(StructArray_slice *); StructArray_var & operator=(const StructArray_var & rhs);

S &

operator[](CORBA::ULong);

const S &

operator[](CORBA::ULong) const;

 

operator StructArray_slice *();

 

operator const StructArray_slice *() const;

const StructArray_slice *

in() const;

StructArray_slice *

inout();

StructArray_slice *

out();

StructArray_slice *

_retn();

};

The only differences between _var types for arrays with fixed-length and those for variable-length elements are that for fixed-length elements, the out member function returns a pointer instead of a reference to a pointer and that no user-defined conversion operator for StructArray_slice * & is defined. These differences originate in the different parameter passing rules for variable-length and fixed-length types. We discuss these rules in detail in Section 7.14.

6.20 Summary

The basic C++ mapping defines how built-in types and user-defined types map to C++. Although some of the classes generated by the mapping have a large number of member functions, within a short time you will find yourself using them as you use any other data type. Even the memory management rules, which may seem complex right now, soon become second nature. When writing your code, keep in mind that you should be looking at the IDL definitions and not at the generated header files. In that way, you avoid getting confused by many internal details and cryptic work-arounds for different platforms and compilers.

203