/** * Implementation that updates result with the matching parts in source * Relies on the fact that getMember returns a C++ reference to each part of \a result, which is then updated * with a property found in source. */ virtual bool composeTypeImpl(const PropertyBag& source, typename internal::AssignableDataSource<T>::reference_t result) const { // The default implementation decomposes result and refreshes it with source. TypeInfoRepository::shared_ptr tir = Types(); internal::ReferenceDataSource<T> rds(result); rds.ref(); // prevent dealloc. PropertyBag decomp; // only try refreshProperties if decomp's type is equal to source type. // update vs refresh: since it is intentional that the decomposition leads to references to parts of result, // only refreshProperties() is meaningful (ie we have a one-to-one mapping). In case of sequences, this would // of course not match, so this is struct specific. return typeDecomposition( &rds, decomp, false) && ( tir->type(decomp.getType()) == tir->type(source.getType()) ) && refreshProperties(decomp, source); }
void loadStdTypes(TypeInfoRepository::shared_ptr ti) { // string is a special case for assignment, we need to assign from the c_str() instead of from the string(), // the latter causes capacity changes, probably due to the copy-on-write implementation of string(). Assignment // from a c-style string obviously disables a copy-on-write connection. #ifndef RTT_NO_STD_TYPES ti->addType( new StdStringTypeInfo() ); ti->addType( new SequenceTypeInfo<std::vector<double> >("array") ); #endif #ifdef OS_RT_MALLOC ti->addType( new RTStringTypeInfo() ); #endif }
bool composeTemplateProperty(const PropertyBag& bag, T& result) { TypeInfoRepository::shared_ptr tir = Types(); if ( tir->type( bag.getType()) == tir->getTypeInfo< T >() ) { Property< typename T::value_type>* comp; int dimension = bag.size(); result.resize( dimension ); // Get values int size_correction = 0; for (int i = 0; i < dimension ; i++) { base::PropertyBase* element = bag.getItem( i ); comp = dynamic_cast< Property< typename T::value_type>* >( element ); if ( comp == 0 ) { // detect LEGACY element: if ( element->getName() == "Size" ) { // oops, our result vector will be one smaller. size_correction += 1; continue; } Logger::log() << Logger::Error << "Aborting composition of Property< T > " << ": Exptected data element "<< i << " to be of type " << internal::DataSourceTypeInfo< typename T::value_type>::getTypeName() <<" got type " << element->getType() <<Logger::endl; return false; } result[ i - size_correction ] = comp->get(); } result.resize( dimension - size_correction ); } else { Logger::log() << Logger::Error << "Composing Property< T > :" << " type mismatch, got type '"<< bag.getType() << "', expected 'vector<" << internal::DataSourceTypeInfo< typename T::value_type>::getTypeName() <<">'."<<Logger::endl; return false; } return true; }
// load the Orocos specific types: void loadOrocosTypes( TypeInfoRepository::shared_ptr ti ) { ti->addType( new StdTypeInfo<FlowStatus>("FlowStatus")); ti->addType( new StdTypeInfo<SendStatus>("SendStatus")); ti->addType( new TemplateTypeInfo<PropertyBag, true>("PropertyBag") ); ti->addType( new StdVectorTypeInfo("array") ); ti->addType( new StructTypeInfo<ConnPolicy,false>("ConnPolicy") ); ti->addType( new TemplateTypeInfo<EmptySendHandle>("SendHandle") ); //dummy, replaced by real stuff when seen by parser. ti->addType( new TemplateTypeInfo<TaskContext*>("TaskContext")); }
bool KDLTypekitPlugin::loadConstructors() { TypeInfoRepository::shared_ptr ti = TypeInfoRepository::Instance(); ti->type("KDL.Vector")->addConstructor( newConstructor(&vectorxyz) ); ti->type("KDL.Rotation")->addConstructor( newConstructor( ptr_fun( Rotation::RPY )) ); ti->type("KDL.Rotation")->addConstructor( newConstructor(&rotationAngleAxis) ); ti->type("KDL.Frame")->addConstructor( newConstructor(&framerv) ); ti->type("KDL.Frame")->addConstructor( newConstructor(&framevr) ); ti->type("KDL.Wrench")->addConstructor( newConstructor(&wrenchft) ); ti->type("KDL.Twist")->addConstructor( newConstructor(&twistvw) ); RTT::Service::shared_ptr gs = RTT::internal::GlobalService::Instance(); gs->provides("KDL")->provides("Rotation")->addOperation("RotX",&Rotation::RotX).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("RotY",&Rotation::RotY).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("RotZ",&Rotation::RotZ).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("RPY",&Rotation::RPY).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("EulerZYX",&Rotation::EulerZYX).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("EulerZYZ",&Rotation::EulerZYZ).doc(""); gs->provides("KDL")->provides("Rotation")->addOperation("Quaternion",&Rotation::Quaternion).doc(""); //ti->type("Frame[]")->addConstructor(newConstructor(stdvector_ctor<Frame>() ) ); //ti->type("Frame[]")->addConstructor(newConstructor(stdvector_ctor2<Frame>() ) ); //ti->type("Frame[]")->addConstructor(new StdVectorBuilder<Frame>() ); //ti->type("Vector[]")->addConstructor(newConstructor(stdvector_ctor<Vector>() ) ); //ti->type("Vector[]")->addConstructor(newConstructor(stdvector_ctor2<Vector>() ) ); //ti->type("Vector[]")->addConstructor(new StdVectorBuilder<Vector>() ); //ti->type("Rotation[]")->addConstructor(newConstructor(stdvector_ctor<Rotation>() ) ); //ti->type("Rotation[]")->addConstructor(newConstructor(stdvector_ctor2<Rotation>() ) ); //ti->type("Rotation[]")->addConstructor(new StdVectorBuilder<Rotation>() ); //ti->type("Wrench[]")->addConstructor(newConstructor(stdvector_ctor<Wrench>() ) ); //ti->type("Wrench[]")->addConstructor(newConstructor(stdvector_ctor2<Wrench>() ) ); //ti->type("Wrench[]")->addConstructor(new StdVectorBuilder<Wrench>() ); //ti->type("Twist[]")->addConstructor(newConstructor(stdvector_ctor<Twist>() ) ); //ti->type("Twist[]")->addConstructor(newConstructor(stdvector_ctor2<Twist>() ) ); //ti->type("Twist[]")->addConstructor(new StdVectorBuilder<Twist>() ); return true; }
bool RealTimeTypekitPlugin::loadConstructors() { TypeInfoRepository::shared_ptr ti = TypeInfoRepository::Instance(); #ifndef ORO_EMBEDDED ti->type("double")->addConstructor( newConstructor( &float_to_double, true )); ti->type("double")->addConstructor( newConstructor( &int_to_double, true )); ti->type("float")->addConstructor( newConstructor( &int_to_float, true )); ti->type("float")->addConstructor( newConstructor( &double_to_float, true )); ti->type("int")->addConstructor( newConstructor( &float_to_int, false )); ti->type("int")->addConstructor( newConstructor( &double_to_int, false )); ti->type("int")->addConstructor( newConstructor( &uint_to_int, true )); ti->type("int")->addConstructor( newConstructor( &bool_to_int, true )); ti->type("uint")->addConstructor( newConstructor( &int_to_uint, true )); ti->type("string")->addConstructor( newConstructor( string_ctor() ) ); #ifdef OS_RT_MALLOC ti->type("rt_string")->addConstructor( newConstructor( rt_string_ctor_int() ) ); ti->type("rt_string")->addConstructor( newConstructor( rt_string_ctor_string() ) ); ti->type("string")->addConstructor( newConstructor( string_ctor_rt_string() ) ); #endif ti->type("bool")->addConstructor( newConstructor( &flow_to_bool, true ) ); ti->type("bool")->addConstructor( newConstructor( &send_to_bool, true ) ); ti->type("bool")->addConstructor( newConstructor( &int_to_bool, true ) ); #endif return true; }