Discussion:
[omniORB] Create org::omg::boxedRMI::seq1_octet_var Variable in C++ (octet per byte[])
Jim Reilly
2008-12-13 02:15:14 UTC
Permalink
I'm new to CORBA and extrememly rusty to C++ (especially to MS Visual Studio 2008).

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

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

[notice the byte[])


My objective is to send from a Corba C++ client (stub) a byte arrry to a Corba Java service (skeleton).

NOTE: I have already been able to basically have this same method work, but sending a 'Long' vs a byte[]. So,
I have some successful experience getting it to work.

VP created 2 IDL files: TestService.idl and seq1_octet.idl. (NOT sure why 2, meaning the seq1_octet)

After using omniidl to create c++ source and idlj to create java source, and used the template of \omniORB-4.1.3\src\examples\echo\eg3_clt.cc (from examples) (It uses the COSS naming service to obtain the object reference) to kick start my client [as I did already correctly with the 'Long' parameter test noted above].
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
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?

These do NOT work: (or combinations there-for of)

org::omg::boxedRMI::seq1_octet_var buf;

buf = 055;

CORBA::Octet *p = new CORBA::Octet[7];

buf = *p;

Octet oct = 040;
CORBA::OctetSeq_var src = oct;


Any help would be much apprecaiged!!!!!!!!!!!!!!


The error on the compile, is this:
1>c:\backup\cpp\pubber\pubber\pubber.cpp(64) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
1> c:\downloadextract\omniorb-4.1.3\include\omniorb4\valuetemplatedecls.h(106): could be '_CORBA_Value_Var<T,T_Helper> &_CORBA_Value_Var<T,T_Helper>::operator =(T *)'
.....


that points to this line:
buf = 01;

where buf is defined like this:
org::omg::boxedRMI::seq1_octet_var buf; (above where I assign it to 01)


NOTE: Weird thing is if I set buf = 00, it all works (no compile problem), but on the java corba svc side, it spits out null when I output what it receives..

Any ideas?????
(That is how do I instantiate a buf of type: org::omg::boxedRMI::seq1_octet_var or whatever...???????)


Thanks,
Jim



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20081212/7ad50e3d/attachment.htm
Duncan Grisby
2008-12-30 01:14:34 UTC
Permalink
Post by Jim Reilly
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...
Post by Jim Reilly
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.
Post by Jim Reilly
public void sendThem(byte[] bytesToSend)
[...]
Post by Jim Reilly
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.
Post by Jim Reilly
void springfw::_objref_TestService::sendThem
(org::omg::boxedRMI::seq1_octet* aBytesToSend)\
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 --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...