sub_bag.value().addProperty versus rvalue().addProperty

Hi all,

In The Orocos Component Builder's Manual 1.10.2,
in the example under chapter 5.1. Task Property Configuration and XML format

I quote:
// we need to call addProperty on the PropertyBag object
// contained within the Property object, hence rvalue() is used.
sub_bag.rvalue().addProperty( &s_param );
sub_bag.rvalue().addProperty( &b_param );

If I use rvalue in a similar situation in my project I get:

[Control@Automation build]$ make
[ 33%] Building CXX object components/Bluetooth/CMakeFiles/Garage-bluetooth-
xenomai.dir/Bluetooth.o
In file included from
/home/Control/Documents/eclipse/Garage/components/Bluetooth/Bluetooth.cpp:9:
/home/Control/Documents/eclipse/Garage/components/Bluetooth/Bluetooth.hpp: In
constructor ‘Garage::Bluetooth::Bluetooth(const std::string&)’:
/home/Control/Documents/eclipse/Garage/components/Bluetooth/Bluetooth.hpp:313:
error: passing ‘const RTT::PropertyBag’ as ‘this’ argument of ‘bool
RTT::PropertyBag::addProperty(RTT::PropertyBase*)’ discards qualifiers
make[2]: *** [components/Bluetooth/CMakeFiles/Garage-bluetooth-
xenomai.dir/Bluetooth.o] Error 1
make[1]: *** [components/Bluetooth/CMakeFiles/Garage-bluetooth-
xenomai.dir/all] Error 2
make: *** [all] Error 2

If I use instead sub_bag.value().addProperty( &s_param );
sub_bag.value().addProperty( &b_param );

all works just fine - no error messages any longer.

Is this maybe a small mistake in the manual?

Thank you,

Gino Strobbe
--
Orocos-Users mailing list
Orocos-Users [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

sub_bag.value().addProperty versus rvalue().addProperty

On Sat, Feb 13, 2010 at 23:20, Gino Strobbe <G [dot] Strobbe [..] ...> wrote:
> Hi all,
>
> In The Orocos Component Builder's Manual 1.10.2,
> in the example under chapter 5.1. Task Property Configuration and XML format
>
> I quote:
>        // we need to call addProperty on the PropertyBag object
>        // contained within the Property object, hence rvalue() is used.
>                sub_bag.rvalue().addProperty( &s_param );
>                sub_bag.rvalue().addProperty( &b_param );
>
> If I use rvalue in a similar situation in my project I get:
>
> [Control@Automation build]$ make
> [ 33%] Building CXX object components/Bluetooth/CMakeFiles/Garage-bluetooth-
> xenomai.dir/Bluetooth.o
> In file included from
> /home/Control/Documents/eclipse/Garage/components/Bluetooth/Bluetooth.cpp:9:
> /home/Control/Documents/eclipse/Garage/components/Bluetooth/Bluetooth.hpp: In
> constructor ‘Garage::Bluetooth::Bluetooth(const std::string&)’:
> /home/Control/Documents/eclipse/Garage/components/Bluetooth/Bluetooth.hpp:313:
> error: passing ‘const RTT::PropertyBag’ as ‘this’ argument of ‘bool
> RTT::PropertyBag::addProperty(RTT::PropertyBase*)’ discards qualifiers
> make[2]: *** [components/Bluetooth/CMakeFiles/Garage-bluetooth-
> xenomai.dir/Bluetooth.o] Error 1
> make[1]: *** [components/Bluetooth/CMakeFiles/Garage-bluetooth-
> xenomai.dir/all] Error 2
> make: *** [all] Error 2
>
> If I use instead        sub_bag.value().addProperty( &s_param );
>                                sub_bag.value().addProperty( &b_param );
>
> all works just fine - no error messages any longer.
>
> Is this maybe a small mistake in the manual?

Yes it is. rvalue() returns a const reference, value() a normal
reference. You need the reference in order to access/extend the bag
object contained in the property. The 'r' of rvalue comes from 'right
hand side value' as is used in the C++ language specs (opposed to
lvalue, to which a reference can be taken).

Peter