[omniORB] Create org::omg::boxedRMI::seq1_octet_var Variable in C++ (octet per byte[])

Duncan Grisby duncan at grisby.org
Mon Dec 29 19:14:32 GMT 2008


On Friday 12 December, Jim Reilly wrote:

> I'm new to CORBA and extrememly rusty to C++  (especially to MS Visual Studio
> 2008).

You're off to a great start... Not only are you using CORBA, which is
complex enough, but you're using the perverse Java to IDL mapping as
well...

> I created 1 UML class in Visual Paradigm (VP) (UML Tool) with one
> method, then generated IDL from it (I do not know IDL).

If at all possible, I'd recommend that you learn IDL (it's quite simple)
and write IDL by hand. That will make life so much easier than trying to
use the Java to IDL mapping. Half the time the Java to IDL compiler
doesn't even generate valid IDL.

> Here is the method: 
>       public void sendThem(byte[] bytesToSend)

[...]
> From the example in : eg3_clt.cc as a basis, the problem I am having
> is trying to create (hardcode for now) an octet that will work with
> org::omg::boxedRMI::seq1_octet.  Per this c++ SK method

You don't need an octet -- that's a single byte value. You need a
sequence of octets...

Except that the Java to IDL mapping helpfully complicates everything by
putting the sequence into a "value box" which can either be an actual
sequence or null.

>      void springfw::_objref_TestService::sendThem
> (org::omg::boxedRMI::seq1_octet* aBytesToSend)\
> 
> When calling it, I want to do this:
> 
> e->sendThem(buf);
> 
> How do I create my buf variable?

Like this...


// seq1_octet_var is a manager type that automatically releases its
// contents when it goes out of scope. It starts out containing null.
org::omg::boxedRMI::seq1_octet_var buf;

// Allocate a new seq1_octet value to go in it. The sequence starts out
// with length 0.
buf = new org::omg::boxedRMI::seq1_octet;

// Set its length to be 1
buf->length(1);

// Assign a value to the sequence element. buf has the semantics of a
// pointer to the seq1_octet object, so we must dereference it before
// using operator[]
(*buf)[0] = 055;

// Send!
e->sendThem(buf);


Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list