3 #include "../Logger.hpp" 4 #include "../Property.hpp" 12 if ( !target.
empty() ) {
13 log(
Error) <<
"composePropertyBag: target bag must be empty."<< endlog();
16 bool has_error =
false;
18 for( ; sit != sourcebag.
end(); ++sit) {
22 if ( isbag.
ready() && isbag.
value().getType() !=
"PropertyBag") {
26 log(
Error) <<
"Could not compose unknown type '" << isbag.
value().getType() <<
"'." <<endlog();
32 log(
Debug) <<
"Used user's composition function for " << tgtprop->
getName() <<
":"<<tgtprop->
getType()<<endlog();
35 log(
Error) <<
"The type '" << isbag.
value().getType() <<
"' did not provide a type composition function, but I need one to compose it from a PropertyBag." <<endlog();
41 if ( isbag.
ready() ) {
62 if ( !target.
empty() ) {
63 log(
Error) <<
"decomposePropertyBag: target bag must be empty."<< endlog();
67 while( sit != sourcebag.
end()) {
71 if ( isbag.
ready() ) {
74 newtarget->
value().setType( isbag.
rvalue().getType() );
77 assert(
false &&
"internal error in decomposePropertyBag.");
81 log(
Debug) <<
"Checking for decompose "<< (*sit)->getName() <<endlog();
87 if ( dsb == (*sit)->getDataSource() ) {
96 newtarget->
value().setType( bagds->
rvalue().getType() );
99 assert(
false &&
"internal error in decomposePropertyBag.");
105 log(
Error) <<
"Failed to create a property of decomposed data of type "<<(*sit)->
getType() <<endlog();
virtual base::DataSourceBase::shared_ptr getDataSource() const
Get an assignable base::DataSource through which this PropertyBase can be manipulated.
bool composeType(base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr target) const
Compose a type (target) from a DataSourceBase (source) containing its members.
bool ready() const
Inspect if this Property is correctly initialised and ready for usage.
Base class for all properties.
bool RTT_API composePropertyBag(PropertyBag const &sourcebag, PropertyBag &target)
Uses the type composition to compose all typed properties from a property bag.
const_reference_t rvalue() const
Read-only (const&) access to the value of the Property.
A container for holding references to properties.
reference_t value()
Access to the value of the Property.
bool ownProperty(base::PropertyBase *p)
Set a property to be owned by this bag.
bool RTT_API decomposePropertyBag(PropertyBag const &sourcebag, PropertyBag &target)
Inverse of RTT::types::composePropertyBag().
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.
virtual std::string getType() const =0
Returns the type of this PropertyBase.
A class for representing a user type, and which can build instances of that type. ...
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...
const std::string & getDescription() const
Get a description of the property.
base::PropertyBase * buildProperty(const std::string &name, const std::string &desc, base::DataSourceBase::shared_ptr source=0) const
Build a Property of this type.
TypeInfoRepository::shared_ptr Types()
Obtain a pointer to the global type system.
Properties::const_iterator const_iterator
A const iterator over the Properties.
bool empty() const
Return true if no properties are present in this bag.
boost::intrusive_ptr< DataSource< T > > shared_ptr
const std::string & getName() const
Get the name of the property.
static DataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded DataSource, possibly returning a new object...
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.