Re: Toolchain 2.7 release planning
Sagar Behere <[email protected]>
| Newsgroups | gmane.science.robotics.orocos.devel |
|---|---|
| Message-ID | <[email protected]> |
On 05/10/2013 12:13 PM, Peter Soetens wrote: > Hi all, > > It's about time to think about releasing master as 2.7. As usual, now is > the time to check if your favorite patches are already on master and > *reply here* if they aren't. Some time ago, you (Peter S.) sent me a patch to rtt/types/PropertyDecomposition.cpp that fixed a problem where enums inside typekits were not logged by value, in the logging component. That patch seems to be absent in the current master. Could you take a look? I have attached the patch. Regards, Sagar -- Orocos-Dev mailing list [email protected] http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
0001-properties-fix-decomposition-of-enums-in-structs.patch
(text/x-patch, 4 KB)
>From fac6a9494c1683968454d9550e2a5860f2bda1b7 Mon Sep 17 00:00:00 2001 From: Peter Soetens <[email protected]> Date: Thu, 25 Oct 2012 05:34:19 +0200 Subject: [PATCH] properties: fix decomposition of enums in structs. If decomposeType returned a new dsb, this was plainly ignored. Signed-off-by: Peter Soetens <[email protected]> --- rtt/types/EnumTypeInfo.hpp | 2 +- rtt/types/PropertyDecomposition.cpp | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/rtt/types/EnumTypeInfo.hpp b/rtt/types/EnumTypeInfo.hpp index 6ccaae5..2f59a85 100644 --- a/rtt/types/EnumTypeInfo.hpp +++ b/rtt/types/EnumTypeInfo.hpp @@ -145,7 +145,7 @@ namespace RTT { // if not available, just convert to int. if ( to_string.count( ds->get() ) == 0 ) { - log(Warning) << "No enum-to-string mapping defined for enum " << this->getTypeName() <<". Converting to int."<<endlog(); + //log(Warning) << "No enum-to-string mapping defined for enum " << this->getTypeName() <<". Converting to int."<<endlog(); return new internal::ValueDataSource<int>( ds->get() ); } internal::ValueDataSource<std::string>::shared_ptr vds = new internal::ValueDataSource<std::string>( to_string.find(ds->get())->second ); diff --git a/rtt/types/PropertyDecomposition.cpp b/rtt/types/PropertyDecomposition.cpp index 03a1440..400da80 100644 --- a/rtt/types/PropertyDecomposition.cpp +++ b/rtt/types/PropertyDecomposition.cpp @@ -77,6 +77,9 @@ bool typeDecomposition( base::DataSourceBase::shared_ptr dsb, PropertyBag& targe // try user's custom type decomposition first: DataSourceBase::shared_ptr decomposed = dsb->getTypeInfo()->decomposeType(dsb); + // In cases where decomposeType() returned dsb itself, we stop the decomposition here. + if (decomposed == dsb) + return false; if (decomposed) { // decomposed is or another type, or a PropertyBag internal::AssignableDataSource<PropertyBag>::shared_ptr bag = internal::AssignableDataSource<PropertyBag>::narrow( decomposed.get() ); @@ -86,7 +89,6 @@ bool typeDecomposition( base::DataSourceBase::shared_ptr dsb, PropertyBag& targe return true; } else { // it converted to something else than a bag. - // In cases where decomposeType() returned dsb itself, we stop the decomposition here. //log(Debug) << "propertyDecomposition: decomposeType() of "<< dsb->getTypeName() << " did not return a PropertyBag but a " << decomposed->getTypeName() << endlog(); return false; } @@ -120,10 +122,22 @@ bool typeDecomposition( base::DataSourceBase::shared_ptr dsb, PropertyBag& targe log(Error)<< "Decomposition failed because Part '"<<*it<<"' is not known to type system."<<endlog(); continue; } - if ( !recurse || !propertyDecomposition( newpb, recurse_bag->value(), true) ) { - assert( recurse_bag->value().empty() ); + if ( !recurse ) targetbag.ownProperty( newpb ); // leaf + else if ( !propertyDecomposition( newpb, recurse_bag->value(), true) ) { + //recurse_bag is empty + assert( recurse_bag->rvalue().empty() ); + base::DataSourceBase::shared_ptr clone = newpb->getDataSource(); + base::DataSourceBase::shared_ptr converted = clone->getTypeInfo()->decomposeType(clone); + if ( converted && converted != clone ) { + // converted contains another type + targetbag.add( converted->getTypeInfo()->buildProperty(*it, "", converted) ); + } else { + // use the original + targetbag.add( newpb ); + } } else { + assert( recurse_bag->rvalue().size() >= 1 ); recurse_bag->setName(*it); // setType() is done by recursive of self. targetbag.ownProperty( recurse_bag.release() ); //recursed. -- 1.7.5.4