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]>
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
_______________________________________________
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.