47 #include "../internal/DataSource.hpp" 51 #include <boost/lexical_cast.hpp> 52 #include "../Logger.hpp" 54 #include "../Property.hpp" 61 namespace RTT {
namespace types {
81 if (decomposed == dsb)
97 vector<string> parts = dsb->getMemberNames();
98 if ( parts.empty() ) {
99 log(
Debug) <<
"propertyDecomposition: "<< dsb->getTypeName() <<
" does not have any members." << endlog();
103 targetbag.
setType( dsb->getTypeName() );
106 #if __cplusplus > 199711L 107 unique_ptr< Property<PropertyBag> >
109 auto_ptr< Property<PropertyBag> >
113 for(vector<string>::iterator it = parts.begin(); it != parts.end(); ++it ) {
116 log(
Error) <<
"propertyDecomposition: Inconsistent type info for "<< dsb->getTypeName() <<
": reported to have part '"<<*it<<
"' but failed to return it."<<endlog();
119 if ( !part->isAssignable() ) {
121 log(
Debug)<<
"propertyDecomposition: Part "<< *it <<
":"<< part->getTypeName() <<
" is not changeable."<<endlog();
127 log(
Error)<<
"Decomposition failed because Part '"<<*it<<
"' is not known to type system."<<endlog();
134 assert( recurse_bag->rvalue().empty() );
137 if ( converted && converted != clone ) {
139 targetbag.
add( converted->getTypeInfo()->buildProperty(*it,
"", converted) );
142 targetbag.
add( newpb );
145 assert( recurse_bag->rvalue().size() >= 1 );
146 recurse_bag->setName(*it);
155 recurse_bag->setDescription(
"Item");
160 int msize = size->
get();
161 for (
int i=0; i < msize; ++i) {
162 string indx = boost::lexical_cast<
string>( i );
165 if ( !item->isAssignable() ) {
167 log(
Warning)<<
"propertyDecomposition: Item '"<< indx <<
"' of type "<< dsb->getTypeName() <<
" is not changeable."<<endlog();
176 recurse_bag->setName(
"Element" + indx );
184 if (targetbag.
empty() )
185 log(
Debug) <<
"propertyDecomposition: "<< dsb->getTypeName() <<
" returns an empty property bag." << endlog();
DataSource is a base class representing a generic way to read data of type T.
virtual result_t get() const =0
Return the data as type T.
void add(base::PropertyBase *p)
Add a valid property to the container.
Base class for all properties.
void setType(const std::string &newtype)
A container for holding references to properties.
bool ownProperty(base::PropertyBase *p)
Set a property to be owned by this bag.
Convenient short notation for every sub-namespace of RTT.
virtual const_reference_t rvalue() const =0
Get a const reference to the value of this DataSource.
A property represents a named value of any type with a description.
bool propertyDecomposition(base::PropertyBase *source, PropertyBag &targetbag, bool recurse)
Uses the type decomposition to decompose a property into a property bag that refers to all its parts...
base::PropertyBase * buildProperty(const std::string &name, const std::string &desc, base::DataSourceBase::shared_ptr source=0) const
Build a Property of this type.
bool empty() const
Return true if no properties are present in this bag.
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
A DataSource which has set() methods.
bool typeDecomposition(base::DataSourceBase::shared_ptr dsb, PropertyBag &targetbag, bool recurse)
Identical to RTT::types::propertyDecomposition(), but takes a DataSourceBase as source.
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual DataSourceBase::shared_ptr getDataSource() const =0
Get an assignable base::DataSource through which this PropertyBase can be manipulated.
virtual const types::TypeInfo * getTypeInfo() const =0
Returns the types::TypeInfo object of this Property.