Last updated: 28 January 2004
A number of people have submitted comments, constructive criticism, and feedback since the first printing. Our thanks go to everyone who helped us weed out bugs and make this a better book. All the people who contributed are listed in the acknowledgments to our readers.
The first sentence of the section Additional T_var
Member Functions for Fixed-Length Types should read:
For aT_var
for a fixed-length structure or union of typeT
, the IDL compiler generates the following:
The return type T &
of the T_var
assignment
operator is incorrect. The correct signature is:
T_var & operator=(const T &)
The type definition for Varr_slice
should read:
typedef Vls Varr_slice;
The IDL at the top of the page should read:
interface Foo { Foo ref_op( in Foo ref_in, inout Foo ref_inout, out Foo ref_out ); };
The C++ mapping for _var
types is under-specified in CORBA 2.3
because it does not show how _var
types for fixed-length
underlying types should work. On 10 January 2000, the OMG C++
Mapping RTF voted to clarify the situation by specifying the
mapping for _var
types for
fixed-length underlying types. (Note that the implementation shown
is not binding in the sense that its internals may differ in each ORB;
however, the semantics must be the same.) The upshot of this mapping is that,
once initialized (which is always via a deep copy), a _var
variable for a fixed-length underlying type behaves like a value of the
underlying type.
The code example deletes the previously allocated vls_out
pointer and then throws an exception without changing the pointer value.
This is a grey area in the C++ mapping: it is not clear whether the
skeleton will attempt to delete the value of an out
parameter
when an exception is thrown. (Currently, we are aware of skeleton
implementions that call delete
on the parameter when an
exception is thrown and others that do not.)
To make the code portable for either kind of skeleton implementation, it is
necessary to set the vls_out
argument to zero before throwing
the exception:
catch (const CORBA::Exception &) { delete vls_out.ptr(); vls_out = 0; // Required for portability delete result; throw; }
The same situation arises for inout
parameters, which also
need to be set to zero before throwing an exception.
Note that there is no need to set the return value to zero for either kind of skeleton implementation.
Instead of writing code such as the example on page 380/381, we recommend
that you use a _var
type to hold an allocated
out
or inout
parameter and call its
_retn
member function once no more exceptions can be thrown,
as shown on page 381/382. This is both simpler and correct for either kind
of skeleton implementation.
The StrFinder
function contains a memory leak. The two calls
to strcmp
should read:
andreturn strcmp(CORBA::String_var(p.second->location()), m_str) == 0;
return strcmp(CORBA::String_var(p.second->model()), m_str) == 0;
The same error appears on page 417.
The call to activate_object
incorrectly passes the servant instead of the address of the servant. The call should read:
poa->activate_object(&ctrl_servant);
The code example makes a number of calls to find_POA
and then
activates the POA manager. However, the POA manager is created in the holding
state, so the calls to find_POA
will not be dispatched and
the code deadlocks.
To fix the problem, the statements
must be moved to precede the calls to// Activate our POAManager. PortableServer::POAManager_var mgr = root_poa->the_POAManager(); mgr->activate();
find_POA
.
The third paragraph following the IDL example states:
Note that the size of the structure CD in Figure 13.2 is 13 bytes...This should read:
Note that the size of the structure CD in Figure 13.2 is 14 bytes...
The last line states that the components
field
is used only by IIOP 1.1. This is incorrect; the components
field is used by both IIOP 1.1 and IIOP 1.2.
The type code for the Node
structure is correct,
but TypeCode::equal
does not return true when
comparing this type code to the _tc_Node
type code
that is generated by the IDL compiler. (Only TypeCode::equivalent
returns true for the comparison.)
To get TypeCode::equal
to return true when comparing the
struct_tc
in the example with the generated
_tc_Node
type code, the second-last statement of the example
should read:
members[1].type = orb->create_sequence_tc(0, rec_tc);
The first two sentences of the second paragraph should read:
resolve_initial_references
cannot return a nil reference,
unless someone has misconfigured the ORB.
The expression near the bottom of the page is missing a *
operator and should read:
min(12.3 * mem_size + 4.6 * file_size)
The second paragraph states that even for requests made locally, they must be dispatched on the POA's single thread instead of the caller's thread.
Different ORB vendors have interpreted the wording in the specification
differently, so the semantics of the SINGLE_THREAD_MODEL
policy with respect to collocated calls are currently under discussion.
Until this matter is settled in the OMG Core Revision Task Force, you
must assume that it is implementation-dependent whether the call is
dispatched on the POA's single thread or the caller's thread.