Implementing CORBA typekit for sequences

Hello,

I have a working typekit with support for the CORBA transport. I now want to
support std::vector of this new type, so I simply added this line to the
loadTypes() method of my typekit:

RTT::types::TypeInfoRepository::Instance()->addType( new
SequenceTypeInfo<std::vector<MyType> >("std.vector<MyType>") );

I also added this line to the registerTransport() method of my CORBA
typekit:

return ti->addProtocol(ORO_CORBA_PROTOCOL_ID, new
RTT::corba::CorbaTemplateProtocol< std::vector<MyType> >());

However, when obtaining remote operations from CORBA, I get the following
error:

0.058 [ ERROR  ][OperationCallerC] Registered transport for type
std.vector<MyType> could not create data source from Any (argument 1):
calling operation 'testMyType' will fail.

So the question is: considering that MyType is working properly over CORBA,
do I have to also implement the CORBA conversion for the sequence
(std::vector) of MyType?

Philippe

Implementing CORBA typekit for sequences

On Tuesday 26 July 2011 17:44:15 Philippe Hamelin wrote:
> Hello,
>
> I have a working typekit with support for the CORBA transport. I now want
> to support std::vector of this new type, so I simply added this line to
> the loadTypes() method of my typekit:
>
>

> RTT::types::TypeInfoRepository::Instance()->addType( new
> SequenceTypeInfo<std::vector<MyType> >("std.vector<MyType>") );
> 

>
> I also added this line to the registerTransport() method of my CORBA
> typekit:
>
>
> return ti->addProtocol(ORO_CORBA_PROTOCOL_ID, new
> RTT::corba::CorbaTemplateProtocol< std::vector<MyType> >());
> 

>
> However, when obtaining remote operations from CORBA, I get the following
> error:
>
>
> 0.058 [ ERROR  ][OperationCallerC] Registered transport for type
> std.vector<MyType> could not create data source from Any (argument 1):
> calling operation 'testMyType' will fail.
> 

>
> So the question is: considering that MyType is working properly over CORBA,
> do I have to also implement the CORBA conversion for the sequence
> (std::vector) of MyType?

I believe not. The header CorbaConversion.hpp contains a template for
std::vector<T> where T is a working-with-corba type, and the any conversion
for type T is included as well. Also, you didn't see the "Failing conversion
of ..." error message ? This message is printed if the fallback is used.

Now I'm seeing a very strange thing in CorbaTemplateProtocol.hpp line 120.
Could you change that line to read:

typename internal::AssignableDataSource<T>::shared_ptr ad_ref = 
boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >( target );

And recompile ? There's a big chance this will fix it.

Peter

Implementing CORBA typekit for sequences

On Tuesday 26 July 2011 21:43:08 Peter Soetens wrote:
> On Tuesday 26 July 2011 17:44:15 Philippe Hamelin wrote:
> > Hello,
> >
> > I have a working typekit with support for the CORBA transport. I now want
> > to support std::vector of this new type, so I simply added this line to
> > the loadTypes() method of my typekit:
> >
> >

> > RTT::types::TypeInfoRepository::Instance()->addType( new
> > SequenceTypeInfo<std::vector<MyType> >("std.vector<MyType>") );
> > 

> >
> > I also added this line to the registerTransport() method of my CORBA
> > typekit:
> >
> >
> > return ti->addProtocol(ORO_CORBA_PROTOCOL_ID, new
> > RTT::corba::CorbaTemplateProtocol< std::vector<MyType> >());
> > 

> >
> > However, when obtaining remote operations from CORBA, I get the following
> > error:
> >
> >
> > 0.058 [ ERROR  ][OperationCallerC] Registered transport for type
> > std.vector<MyType> could not create data source from Any (argument 1):
> > calling operation 'testMyType' will fail.
> > 

> >
> > So the question is: considering that MyType is working properly over
> > CORBA, do I have to also implement the CORBA conversion for the sequence
> > (std::vector) of MyType?
>
> I believe not. The header CorbaConversion.hpp contains a template for
> std::vector<T> where T is a working-with-corba type, and the any conversion
> for type T is included as well. Also, you didn't see the "Failing
> conversion of ..." error message ? This message is printed if the fallback
> is used.
>
> Now I'm seeing a very strange thing in CorbaTemplateProtocol.hpp line 120.
> Could you change that line to read:
>
>
> typename internal::AssignableDataSource<T>::shared_ptr ad_ref =
> boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >( target );
> 

>
> And recompile ? There's a big chance this will fix it.

Actually, replace every occurrence of 'ReferenceDataSource' to
'AssignableDataSource' in that file (6 times). None of them is correct.

Peter

Implementing CORBA typekit for sequences

On Tuesday 26 July 2011 21:45:57 Peter Soetens wrote:
> On Tuesday 26 July 2011 21:43:08 Peter Soetens wrote:
> > On Tuesday 26 July 2011 17:44:15 Philippe Hamelin wrote:
> > > Hello,
> > >
> > > I have a working typekit with support for the CORBA transport. I now
> > > want to support std::vector of this new type, so I simply added this
> > > line to the loadTypes() method of my typekit:
> > >
> > >

> > > RTT::types::TypeInfoRepository::Instance()->addType( new
> > > SequenceTypeInfo<std::vector<MyType> >("std.vector<MyType>") );
> > > 

> > >
> > > I also added this line to the registerTransport() method of my CORBA
> > > typekit:
> > >
> > >
> > > return ti->addProtocol(ORO_CORBA_PROTOCOL_ID, new
> > > RTT::corba::CorbaTemplateProtocol< std::vector<MyType> >());
> > > 

> > >
> > > However, when obtaining remote operations from CORBA, I get the
> > > following error:
> > >
> > >
> > > 0.058 [ ERROR  ][OperationCallerC] Registered transport for type
> > > std.vector<MyType> could not create data source from Any (argument 1):
> > > calling operation 'testMyType' will fail.
> > > 

> > >
> > > So the question is: considering that MyType is working properly over
> > > CORBA, do I have to also implement the CORBA conversion for the
> > > sequence (std::vector) of MyType?
> >
> > I believe not. The header CorbaConversion.hpp contains a template for
> > std::vector<T> where T is a working-with-corba type, and the any
> > conversion for type T is included as well. Also, you didn't see the
> > "Failing conversion of ..." error message ? This message is printed if
> > the fallback is used.
> >
> > Now I'm seeing a very strange thing in CorbaTemplateProtocol.hpp line
> > 120. Could you change that line to read:
> >
> >
> > typename internal::AssignableDataSource<T>::shared_ptr ad_ref =
> > boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >( target
> > ); 

> >
> > And recompile ? There's a big chance this will fix it.
>
> Actually, replace every occurrence of 'ReferenceDataSource' to
> 'AssignableDataSource' in that file (6 times). None of them is correct.

Hmm. I doubt now it is sufficient to fix it. The optimisations Sylvain added for
ReferenceDataSource *should* have been written for AssignableDataSource, but I
overlooked the indentation and it falls back to something for
AssignableDataSource anyway. The problem is then that the call in
AnyConversion<std::vector where result is defined by your AnyConversion<T>::sequence.

I think what is really lacking is that your AnyConversion<T> needs to define a
'sequence' typedef which is a CORBA sequence<CorbaType>, see line 221 pf
CorbaConversion.hpp. Could it be that you hacked something to fix a compilation
issue involving 'sequence' ?

Peter

Implementing CORBA typekit for sequences

e mardi 26 juillet 2011, Peter Soetens <peter [..] ...> a écrit :
> On Tuesday 26 July 2011 21:45:57 Peter Soetens wrote:
>> On Tuesday 26 July 2011 21:43:08 Peter Soetens wrote:
>> > On Tuesday 26 July 2011 17:44:15 Philippe Hamelin wrote:
>> > > Hello,
>> > >
>> > > I have a working typekit with support for the CORBA transport. I now
>> > > want to support std::vector of this new type, so I simply added this
>> > > line to the loadTypes() method of my typekit:
>> > >
>> > >

>> > > RTT::types::TypeInfoRepository::Instance()->addType( new
>> > > SequenceTypeInfo<std::vector<MyType> >("std.vector<MyType>") );
>> > > 

>> > >
>> > > I also added this line to the registerTransport() method of my CORBA
>> > > typekit:
>> > >
>> > >
>> > > return ti->addProtocol(ORO_CORBA_PROTOCOL_ID, new
>> > > RTT::corba::CorbaTemplateProtocol< std::vector<MyType> >());
>> > > 

>> > >
>> > > However, when obtaining remote operations from CORBA, I get the
>> > > following error:
>> > >
>> > >
>> > > 0.058 [ ERROR  ][OperationCallerC] Registered transport for type
>> > > std.vector<MyType> could not create data source from Any (argument
1):
>> > > calling operation 'testMyType' will fail.
>> > > 

>> > >
>> > > So the question is: considering that MyType is working properly over
>> > > CORBA, do I have to also implement the CORBA conversion for the
>> > > sequence (std::vector) of MyType?
>> >
>> > I believe not. The header CorbaConversion.hpp contains a template for
>> > std::vector<T> where T is a working-with-corba type, and the any
>> > conversion for type T is included as well. Also, you didn't see the
>> > "Failing conversion of ..." error message ? This message is printed if
>> > the fallback is used.
>> >
>> > Now I'm seeing a very strange thing in CorbaTemplateProtocol.hpp line
>> > 120. Could you change that line to read:
>> >
>> >
>> > typename internal::AssignableDataSource<T>::shared_ptr ad_ref =
>> > boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >(
target
>> > ); 

>> >
>> > And recompile ? There's a big chance this will fix it.
>>
>> Actually, replace every occurrence of 'ReferenceDataSource' to
>> 'AssignableDataSource' in that file (6 times). None of them is correct.
>
> Hmm. I doubt now it is sufficient to fix it. The optimisations Sylvain
added for
> ReferenceDataSource *should* have been written for AssignableDataSource,
but I
> overlooked the indentation and it falls back to something for
> AssignableDataSource anyway. The problem is then that the call in
> AnyConversion<std::vector fails,
> where result is defined by your AnyConversion<T>::sequence.
>
> I think what is really lacking is that your AnyConversion<T> needs to
define a
> 'sequence' typedef which is a CORBA sequence<CorbaType>, see line 221 pf
> CorbaConversion.hpp. Could it be that you hacked something to fix a
compilation
> issue involving 'sequence' ?
>
> Peter
>

The problem wasn't RTT! I had a name clashing problem with the CORBA
variable name and the C++ variable name because I was using the wrong
namespace in the CorbaTemplateProtocol. You are right: I needed to define
'sequence' in my AnyConversion. I'm still debugging that...

Implementing CORBA typekit for sequences

Le mardi 26 juillet 2011, Philippe Hamelin <philippe [dot] hamelin [..] ...> a
écrit :
> e mardi 26 juillet 2011, Peter Soetens <peter [..] ...> a
écrit :
>> On Tuesday 26 July 2011 21:45:57 Peter Soetens wrote:
>>> On Tuesday 26 July 2011 21:43:08 Peter Soetens wrote:
>>> > On Tuesday 26 July 2011 17:44:15 Philippe Hamelin wrote:
>>> > > Hello,
>>> > >
>>> > > I have a working typekit with support for the CORBA transport. I now
>>> > > want to support std::vector of this new type, so I simply added this
>>> > > line to the loadTypes() method of my typekit:
>>> > >
>>> > >

>>> > > RTT::types::TypeInfoRepository::Instance()->addType( new
>>> > > SequenceTypeInfo<std::vector<MyType> >("std.vector<MyType>") );
>>> > > 

>>> > >
>>> > > I also added this line to the registerTransport() method of my CORBA
>>> > > typekit:
>>> > >
>>> > >
>>> > > return ti->addProtocol(ORO_CORBA_PROTOCOL_ID, new
>>> > > RTT::corba::CorbaTemplateProtocol< std::vector<MyType> >());
>>> > > 

>>> > >
>>> > > However, when obtaining remote operations from CORBA, I get the
>>> > > following error:
>>> > >
>>> > >
>>> > > 0.058 [ ERROR  ][OperationCallerC] Registered transport for type
>>> > > std.vector<MyType> could not create data source from Any (argument
1):
>>> > > calling operation 'testMyType' will fail.
>>> > > 

>>> > >
>>> > > So the question is: considering that MyType is working properly over
>>> > > CORBA, do I have to also implement the CORBA conversion for the
>>> > > sequence (std::vector) of MyType?
>>> >
>>> > I believe not. The header CorbaConversion.hpp contains a template for
>>> > std::vector<T> where T is a working-with-corba type, and the any
>>> > conversion for type T is included as well. Also, you didn't see the
>>> > "Failing conversion of ..." error message ? This message is printed if
>>> > the fallback is used.
>>> >
>>> > Now I'm seeing a very strange thing in CorbaTemplateProtocol.hpp line
>>> > 120. Could you change that line to read:
>>> >
>>> >
>>> > typename internal::AssignableDataSource<T>::shared_ptr ad_ref =
>>> > boost::dynamic_pointer_cast< internal::AssignableDataSource<T> >(
target
>>> > ); 

>>> >
>>> > And recompile ? There's a big chance this will fix it.
>>>
>>> Actually, replace every occurrence of 'ReferenceDataSource' to
>>> 'AssignableDataSource' in that file (6 times). None of them is correct.
>>
>> Hmm. I doubt now it is sufficient to fix it. The optimisations Sylvain
added for
>> ReferenceDataSource *should* have been written for AssignableDataSource,
but I
>> overlooked the indentation and it falls back to something for
>> AssignableDataSource anyway. The problem is then that the call in
>> AnyConversion<std::vector fails,
>> where result is defined by your AnyConversion<T>::sequence.
>>
>> I think what is really lacking is that your AnyConversion<T> needs to
define a
>> 'sequence' typedef which is a CORBA sequence<CorbaType>, see line 221 pf
>> CorbaConversion.hpp. Could it be that you hacked something to fix a
compilation
>> issue involving 'sequence' ?
>>
>> Peter
>>
>
> The problem wasn't RTT! I had a name clashing problem with the CORBA
variable name and the C++ variable name because I was using the wrong
namespace in the CorbaTemplateProtocol. You are right: I needed to define
'sequence' in my AnyConversion. I'm still debugging that...

I confirm that the problem wasn't RTT. My unit test is now working. Sorry
for the false alarm :-).

Philippe