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:

&#10;typename internal::AssignableDataSource&lt;T&gt;::shared_ptr ad_ref = &#10;boost::dynamic_pointer_cast&lt; internal::AssignableDataSource&lt;T&gt; &gt;( target );&#10;

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:
> >
> > &#10;&gt; &gt; RTT::types::TypeInfoRepository::Instance()-&gt;addType( new&#10;&gt; &gt; SequenceTypeInfo&lt;std::vector&lt;MyType&gt; &gt;(&quot;std.vector&lt;MyType&gt;&quot;) );&#10;&gt; &gt;
> >
> > I also added this line to the registerTransport() method of my CORBA
> > typekit:
> >
> > &#10;&gt; &gt; return ti-&gt;addProtocol(ORO_CORBA_PROTOCOL_ID, new&#10;&gt; &gt; RTT::corba::CorbaTemplateProtocol&lt; std::vector&lt;MyType&gt; &gt;());&#10;&gt; &gt;
> >
> > However, when obtaining remote operations from CORBA, I get the following
> > error:
> >
> > &#10;&gt; &gt; 0.058 [ ERROR  ][OperationCallerC] Registered transport for type&#10;&gt; &gt; std.vector&lt;MyType&gt; could not create data source from Any (argument 1):&#10;&gt; &gt; calling operation &#039;testMyType&#039; will fail.&#10;&gt; &gt;
> >
> > 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:
>
> &#10;&gt; typename internal::AssignableDataSource&lt;T&gt;::shared_ptr ad_ref =&#10;&gt; boost::dynamic_pointer_cast&lt; internal::AssignableDataSource&lt;T&gt; &gt;( target );&#10;&gt;
>
> 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:
> > >
> > > &#10;&gt; &gt; &gt; RTT::types::TypeInfoRepository::Instance()-&gt;addType( new&#10;&gt; &gt; &gt; SequenceTypeInfo&lt;std::vector&lt;MyType&gt; &gt;(&quot;std.vector&lt;MyType&gt;&quot;) );&#10;&gt; &gt; &gt;
> > >
> > > I also added this line to the registerTransport() method of my CORBA
> > > typekit:
> > >
> > > &#10;&gt; &gt; &gt; return ti-&gt;addProtocol(ORO_CORBA_PROTOCOL_ID, new&#10;&gt; &gt; &gt; RTT::corba::CorbaTemplateProtocol&lt; std::vector&lt;MyType&gt; &gt;());&#10;&gt; &gt; &gt;
> > >
> > > However, when obtaining remote operations from CORBA, I get the
> > > following error:
> > >
> > > &#10;&gt; &gt; &gt; 0.058 [ ERROR  ][OperationCallerC] Registered transport for type&#10;&gt; &gt; &gt; std.vector&lt;MyType&gt; could not create data source from Any (argument 1):&#10;&gt; &gt; &gt; calling operation &#039;testMyType&#039; will fail.&#10;&gt; &gt; &gt;
> > >
> > > 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:
> >
> > &#10;&gt; &gt; typename internal::AssignableDataSource&lt;T&gt;::shared_ptr ad_ref =&#10;&gt; &gt; boost::dynamic_pointer_cast&lt; internal::AssignableDataSource&lt;T&gt; &gt;( target&#10;&gt; &gt; );
> >
> > 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<T> >::update() fails because any >>= result 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

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:
>> > >
>> > > &#10;&gt;&gt; &gt; &gt; RTT::types::TypeInfoRepository::Instance()-&gt;addType( new&#10;&gt;&gt; &gt; &gt; SequenceTypeInfo&lt;std::vector&lt;MyType&gt; &gt;(&quot;std.vector&lt;MyType&gt;&quot;) );&#10;&gt;&gt; &gt; &gt;
>> > >
>> > > I also added this line to the registerTransport() method of my CORBA
>> > > typekit:
>> > >
>> > > &#10;&gt;&gt; &gt; &gt; return ti-&gt;addProtocol(ORO_CORBA_PROTOCOL_ID, new&#10;&gt;&gt; &gt; &gt; RTT::corba::CorbaTemplateProtocol&lt; std::vector&lt;MyType&gt; &gt;());&#10;&gt;&gt; &gt; &gt;
>> > >
>> > > However, when obtaining remote operations from CORBA, I get the
>> > > following error:
>> > >
>> > > &#10;&gt;&gt; &gt; &gt; 0.058 [ ERROR  ][OperationCallerC] Registered transport for type&#10;&gt;&gt; &gt; &gt; std.vector&lt;MyType&gt; could not create data source from Any (argument&#10;1):&#10;&gt;&gt; &gt; &gt; calling operation &#039;testMyType&#039; will fail.&#10;&gt;&gt; &gt; &gt;
>> > >
>> > > 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:
>> >
>> > &#10;&gt;&gt; &gt; typename internal::AssignableDataSource&lt;T&gt;::shared_ptr ad_ref =&#10;&gt;&gt; &gt; boost::dynamic_pointer_cast&lt; internal::AssignableDataSource&lt;T&gt; &gt;(&#10;target&#10;&gt;&gt; &gt; );
>> >
>> > 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<T> >::update() fails because any >>= result
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:
>>> > >
>>> > > &#10;&gt;&gt;&gt; &gt; &gt; RTT::types::TypeInfoRepository::Instance()-&gt;addType( new&#10;&gt;&gt;&gt; &gt; &gt; SequenceTypeInfo&lt;std::vector&lt;MyType&gt; &gt;(&quot;std.vector&lt;MyType&gt;&quot;) );&#10;&gt;&gt;&gt; &gt; &gt;
>>> > >
>>> > > I also added this line to the registerTransport() method of my CORBA
>>> > > typekit:
>>> > >
>>> > > &#10;&gt;&gt;&gt; &gt; &gt; return ti-&gt;addProtocol(ORO_CORBA_PROTOCOL_ID, new&#10;&gt;&gt;&gt; &gt; &gt; RTT::corba::CorbaTemplateProtocol&lt; std::vector&lt;MyType&gt; &gt;());&#10;&gt;&gt;&gt; &gt; &gt;
>>> > >
>>> > > However, when obtaining remote operations from CORBA, I get the
>>> > > following error:
>>> > >
>>> > > &#10;&gt;&gt;&gt; &gt; &gt; 0.058 [ ERROR  ][OperationCallerC] Registered transport for type&#10;&gt;&gt;&gt; &gt; &gt; std.vector&lt;MyType&gt; could not create data source from Any (argument&#10;1):&#10;&gt;&gt;&gt; &gt; &gt; calling operation &#039;testMyType&#039; will fail.&#10;&gt;&gt;&gt; &gt; &gt;
>>> > >
>>> > > 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:
>>> >
>>> > &#10;&gt;&gt;&gt; &gt; typename internal::AssignableDataSource&lt;T&gt;::shared_ptr ad_ref =&#10;&gt;&gt;&gt; &gt; boost::dynamic_pointer_cast&lt; internal::AssignableDataSource&lt;T&gt; &gt;(&#10;target&#10;&gt;&gt;&gt; &gt; );
>>> >
>>> > 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<T> >::update() fails because any >>= result
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