Re: read/write access to the buffer of a sequence]

Dion Picco <[email protected]>
Newsgroups gmane.comp.corba.orbacus
Organization IONA | Making Software Work Together TM
Message-ID <[email protected]>
----- Forwarded message from André Borrmann <[email protected]> -----

From: André Borrmann <[email protected]>
Date: Fri, 17 Sep 2004 10:12:33 +0200
To: "Dion Picco" <[email protected]>
Subject: AW: [OB-Users] read/write access to the buffer of a sequence

Hi Dion,

I'm sorry, the snippet was a bit confusing. But you're completely right, I
meant pressure, not v_x. I can not use inout because the interface is used
by the Typed Event Service, which allows oneway operations only. So I will
have to use the const_cast...

Thank you very much!

Some days ago I posted to the mailing list a question regarding the
behaviour of 'encapsulated structs' on Linux. It's a serious problem for me,
so maybe you could have a look at that...

Thank you!
Sincerly,

André Borrmann



-----Ursprüngliche Nachricht-----
Von: Dion Picco [mailto:[email protected]]
Gesendet: Donnerstag, 16. September 2004 22:40
An: André Borrmann
Cc: [email protected]
Betreff: Re: [OB-Users] read/write access to the buffer of a sequence


Hi Andr,

On Thu, Sep 16, 2004 at 10:34:10AM +0200, André Borrmann wrote:
> Hi,
>
> I want to have read/write access to the buffer of a sequence. Here is the
> code snippet:
>
> void clientSimuEventHandler::receiveData(const
> ::corbaSimuNotify::floatsequence& pressure)
> {
>   float* f = v_x.get_buffer(1);
>   //...
> }
>
> The 1 demarks that I get the responsibility for memory management, as
> described on p.193 in Henning/Vinoski. Unfortunatly, that does not work.
It
> tells me something like 'There is no valid conversion for the
this-Pointer'.
> I guess the problem lies in the 'const' in the parameter list of that
> function.
>
> Does anyone have an idea on how to bypass this problem? I don't want to
copy
> the whole buffer.
>
> Thank you in advance!
>
> Sincerly,
> André Borrmann

I'm not exactly sure what is causing your problem outlined in the
function.  You specify a parameter called pressure but you are accessing
a v_x paramter.  Is v_x a member of 'this' class?  If so, are you
forgetting to include the const modifier at the end of the function in
your example above?

Assuming v_x is supposed to be pressure...:
I suspect that the sequence parameter as described in the IDL file is
specified as an 'in' parameter?  You can specify it as an 'inout'
parameter to remove the constant at the expense that it will be returned
to the caller.  If you don't want to send the sequence back to the
caller but you still want to modify its contents without copying the
sequence, then perhaps you will have to use the const_cast<> operator to
dispel the const property from the parameter.  I won't get into the
good/bad of this but it should let you do what you want.

--
Dion Picco, Software Engineer
IONA Technologies Inc.
Team Orbacus - Your CORBA Source
mailto:[email protected]
http://www.orbacus.com

----- End forwarded message -----

-- 
Dion Picco, Software Engineer
IONA Technologies Inc.
Team Orbacus - Your CORBA Source
mailto:[email protected]
http://www.orbacus.com
_______________________________________________
OB-Users Mailing List - [email protected]
http://mail.ooc.nf.ca/mailman/listinfo/ob-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.