diff --git a/eigen_typekit/eigen_typekit.cpp b/eigen_typekit/eigen_typekit.cpp index 6c333c6..cdd3686 100644 --- a/eigen_typekit/eigen_typekit.cpp +++ b/eigen_typekit/eigen_typekit.cpp @@ -34,33 +34,44 @@ #include #include - -template class RTT_EXPORT RTT::internal::DataSourceTypeInfo< Eigen::VectorXd >; -template class RTT_EXPORT RTT::internal::DataSource< Eigen::VectorXd >; -template class RTT_EXPORT RTT::internal::AssignableDataSource< Eigen::VectorXd >; -template class RTT_EXPORT RTT::internal::AssignCommand< Eigen::VectorXd >; -template class RTT_EXPORT RTT::internal::ValueDataSource< Eigen::VectorXd >; -template class RTT_EXPORT RTT::internal::ConstantDataSource< Eigen::VectorXd >; -template class RTT_EXPORT RTT::internal::ReferenceDataSource< Eigen::VectorXd >; -template class RTT_EXPORT RTT::OutputPort< Eigen::VectorXd >; -template class RTT_EXPORT RTT::InputPort< Eigen::VectorXd >; -template class RTT_EXPORT RTT::Property< Eigen::VectorXd >; -template class RTT_EXPORT RTT::Attribute< Eigen::VectorXd >; -template class RTT_EXPORT RTT::Constant< Eigen::VectorXd >; - -template class RTT_EXPORT RTT::internal::DataSourceTypeInfo< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::internal::DataSource< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::internal::AssignableDataSource< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::internal::AssignCommand< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::internal::ValueDataSource< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::internal::ConstantDataSource< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::internal::ReferenceDataSource< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::OutputPort< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::InputPort< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::Property< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::Attribute< Eigen::MatrixXd >; -template class RTT_EXPORT RTT::Constant< Eigen::MatrixXd >; - +#define DECLARE_RTT_VECTOR_EXPORTS( VectorType ) \ +template class RTT_EXPORT RTT::internal::DataSourceTypeInfo< VectorType >; \ +template class RTT_EXPORT RTT::internal::DataSource< VectorType >; \ +template class RTT_EXPORT RTT::internal::AssignableDataSource< VectorType >; \ +template class RTT_EXPORT RTT::internal::AssignCommand< VectorType >; \ +template class RTT_EXPORT RTT::internal::ValueDataSource< VectorType >; \ +template class RTT_EXPORT RTT::internal::ConstantDataSource< VectorType >; \ +template class RTT_EXPORT RTT::internal::ReferenceDataSource< VectorType >; \ +template class RTT_EXPORT RTT::OutputPort< VectorType >; \ +template class RTT_EXPORT RTT::InputPort< VectorType >; \ +template class RTT_EXPORT RTT::Property< VectorType >; \ +template class RTT_EXPORT RTT::Attribute< VectorType >; \ +template class RTT_EXPORT RTT::Constant< VectorType >; + +DECLARE_RTT_VECTOR_EXPORTS( Eigen::VectorXd ) +DECLARE_RTT_VECTOR_EXPORTS( Eigen::Vector2d ) +DECLARE_RTT_VECTOR_EXPORTS( Eigen::Vector3d ) +DECLARE_RTT_VECTOR_EXPORTS( Eigen::Vector4d ) +DECLARE_RTT_VECTOR_EXPORTS( Eigen::Vector6d ) + +#define DECLARE_RTT_MATRIX_EXPORTS( MatrixType ) \ +template class RTT_EXPORT RTT::internal::DataSourceTypeInfo< MatrixType >; \ +template class RTT_EXPORT RTT::internal::DataSource< MatrixType >; \ +template class RTT_EXPORT RTT::internal::AssignableDataSource< MatrixType >; \ +template class RTT_EXPORT RTT::internal::AssignCommand< MatrixType >; \ +template class RTT_EXPORT RTT::internal::ValueDataSource< MatrixType >; \ +template class RTT_EXPORT RTT::internal::ConstantDataSource< MatrixType >; \ +template class RTT_EXPORT RTT::internal::ReferenceDataSource< MatrixType >; \ +template class RTT_EXPORT RTT::OutputPort< MatrixType >; \ +template class RTT_EXPORT RTT::InputPort< MatrixType >; \ +template class RTT_EXPORT RTT::Property< MatrixType >; \ +template class RTT_EXPORT RTT::Attribute< MatrixType >; \ +template class RTT_EXPORT RTT::Constant< MatrixType >; + +DECLARE_RTT_MATRIX_EXPORTS( Eigen::MatrixXd ) +DECLARE_RTT_MATRIX_EXPORTS( Eigen::Matrix2d ) +DECLARE_RTT_MATRIX_EXPORTS( Eigen::Matrix3d ) +DECLARE_RTT_MATRIX_EXPORTS( Eigen::Matrix4d ) #include namespace Eigen{ @@ -69,49 +80,52 @@ namespace Eigen{ using namespace RTT::detail; using namespace RTT::types; - std::istream& operator>>(std::istream &is,MatrixXd& v){ + template + std::istream& operator>>(std::istream &is, EigenBase& v){ return is; } - std::istream& operator>>(std::istream &is,VectorXd& v){ - return is; - } - - double& get_item(VectorXd& v, int index) + + template + double& get_item(VectorType& v, int index) { if (index >= (int) (v.size()) || index < 0) return RTT::internal::NA::na(); return v[index]; } - - double get_item_copy(const VectorXd& v, int index) + + template + double get_item_copy(const VectorType& v, int index) { if (index >= (int) (v.size()) || index < 0) return RTT::internal::NA::na(); return v[index]; } - - - int get_size(const VectorXd& v) + + template + int get_size(const VectorType& v) { return v.size(); } - struct VectorTypeInfo : public types::TemplateTypeInfo + template + struct VectorTypeInfo : public types::TemplateTypeInfo #if (RTT_VERSION_MAJOR*100+RTT_VERSION_MINOR) >= 206 , public MemberFactory #endif { - VectorTypeInfo():TemplateTypeInfo("eigen_vector") + VectorTypeInfo(const std::string& type_name):TemplateTypeInfo(type_name) { }; - + #if (RTT_VERSION_MAJOR*100+RTT_VERSION_MINOR) >= 206 bool installTypeInfoObject(TypeInfo* ti) { // aquire a shared reference to the this object - boost::shared_ptr< VectorTypeInfo > mthis = boost::dynamic_pointer_cast( this->getSharedPtr() ); + typedef typename boost::shared_ptr< VectorTypeInfo > sh_ptr; + sh_ptr mthis = boost::dynamic_pointer_cast( this->getSharedPtr() ); + assert(mthis); // Allow base to install first - TemplateTypeInfo::installTypeInfoObject(ti); + TemplateTypeInfo::installTypeInfoObject(ti); // Install the factories for primitive types ti->setMemberFactory( mthis ); // Don't delete us, we're memory-managed. @@ -122,8 +136,9 @@ namespace Eigen{ bool resize(base::DataSourceBase::shared_ptr arg, int size) const { if (arg->isAssignable()) { - RTT::internal::AssignableDataSource::shared_ptr asarg = RTT::internal::AssignableDataSource::narrow( arg.get() ); - asarg->set().resize( size ); + typedef typename RTT::internal::AssignableDataSource::shared_ptr sh_ptr; + sh_ptr asarg = RTT::internal::AssignableDataSource::narrow( arg.get() ); + asarg->set().conservativeResizeLike(VectorType::Zero(size)); asarg->updated(); return true; } @@ -157,7 +172,7 @@ namespace Eigen{ if ( id_name ) { if ( id_name->get() == "size" || id_name->get() == "capacity") { try { - return RTT::internal::newFunctorDataSource(&get_size, RTT::internal::GenerateDataSource()(item.get()) ); + return RTT::internal::newFunctorDataSource(&get_size, RTT::internal::GenerateDataSource()(item.get()) ); } catch(...) {} } } @@ -165,9 +180,13 @@ namespace Eigen{ if ( id_indx ) { try { if ( item->isAssignable() ) - return RTT::internal::newFunctorDataSource(&get_item, RTT::internal::GenerateDataSource()(item.get(), id_indx.get() ) ); + { + return RTT::internal::newFunctorDataSource(get_item, RTT::internal::GenerateDataSource()(item.get(), id_indx.get() ) ); + } else - return RTT::internal::newFunctorDataSource(&get_item_copy, RTT::internal::GenerateDataSource()(item.get(), id_indx.get() ) ); + { + return RTT::internal::newFunctorDataSource(get_item_copy, RTT::internal::GenerateDataSource()(item.get(), id_indx.get() ) ); + } } catch(...) {} } if (id_name) { @@ -182,9 +201,9 @@ namespace Eigen{ } - virtual bool decomposeTypeImpl(const VectorXd& vec, PropertyBag& targetbag) const + virtual bool decomposeTypeImpl(const VectorType& vec, PropertyBag& targetbag) const { - targetbag.setType("eigen_vector"); + targetbag.setType(this->getTypeName()); int dimension = vec.rows(); std::string str; @@ -201,11 +220,11 @@ namespace Eigen{ return true; }; - virtual bool composeTypeImpl(const PropertyBag& bag, VectorXd& result) const{ + virtual bool composeTypeImpl(const PropertyBag& bag, VectorType& result) const{ - if ( bag.getType() == "eigen_vector" ) { + if ( bag.getType() == this->getTypeName() ) { int dimension = bag.size(); - result.resize( dimension ); + result.conservativeResizeLike(VectorType::Zero(dimension)); // Get values for (int i = 0; i < dimension ; i++) { @@ -220,7 +239,7 @@ namespace Eigen{ } } }else{ - log(Error) << "Composing Property< VectorXd > :" + log(Error) << "Composing Property< " << this->getTypeName() << " > :" << " type mismatch, got type '"<< bag.getType() << "', expected type "<<"eigen_vector."<{ - MatrixTypeInfo():TemplateTypeInfo("eigen_matrix"){ + template + struct MatrixTypeInfo : public types::TemplateTypeInfo{ + MatrixTypeInfo(const std::string& type_name):TemplateTypeInfo(type_name){ }; - bool decomposeTypeImpl(const MatrixXd& mat, PropertyBag& targetbag) const{ - targetbag.setType("eigen_matrix"); + bool decomposeTypeImpl(const MatrixType& mat, PropertyBag& targetbag) const{ + targetbag.setType(this->getTypeName()); unsigned int dimension = mat.rows(); if(!targetbag.empty()) return false; @@ -249,8 +269,8 @@ namespace Eigen{ return true; }; - bool composeTypeImpl(const PropertyBag& bag, MatrixXd& result) const{ - if ( bag.getType() == "eigen_matrix" ) { + bool composeTypeImpl(const PropertyBag& bag, MatrixType& result) const{ + if ( bag.getType() == this->getTypeName() ) { unsigned int rows = bag.size(); unsigned int cols = 0; // Get values @@ -283,7 +303,7 @@ namespace Eigen{ } } }else { - log(Error) << "Composing Property< MatrixXd > :" + log(Error) << "Composing Property< " << this->getTypeName() << " > :" << " type mismatch, got type '"<< bag.getType() << "', expected type "<<"ublas_matrix."< struct vector_index - : public std::binary_function + : public std::binary_function { - double operator()(const VectorXd& v, int index) const + double operator()(const VectorType& v, int index) const { if ( index >= (int)(v.size()) || index < 0) return 0.0; return v(index); } }; - - struct get_size - : public std::unary_function + + template + struct get_size_functor + : public std::unary_function { - int operator()(const VectorXd& cont ) const + int operator()(const VectorType& cont ) const { return cont.rows(); } }; - struct vector_index_value_constructor - : public std::binary_function + template + struct vector_size_value_constructor + : public std::binary_function + { + typedef VectorType (Signature)( int, double ); + VectorType operator()(int size,double value ) const + { + return VectorType::Constant(size,value); + } + }; + + template + struct vector_array_constructor + : public std::unary_function,VectorType> { - typedef const VectorXd& (Signature)( int, double ); - mutable boost::shared_ptr< VectorXd > ptr; - vector_index_value_constructor() : - ptr( new VectorXd ){} - const VectorXd& operator()(int size,double value ) const + typedef VectorType (Signature)( std::vector ); + VectorType operator()(std::vector values) const { - ptr->resize(size); - (*ptr)=Eigen::VectorXd::Constant(size,value); - return *(ptr); + return VectorType::Map(values.data(),values.size()); } }; - struct vector_index_array_constructor - : public std::unary_function,const VectorXd&> + template + struct vector_fixed_array_constructor + : public std::unary_function,VectorType> { - typedef const VectorXd& (Signature)( std::vector ); - mutable boost::shared_ptr< VectorXd > ptr; - vector_index_array_constructor() : - ptr( new VectorXd ){} - const VectorXd& operator()(std::vector values) const + typedef VectorType (Signature)( std::vector ); + VectorType operator()(std::vector values) const { - (*ptr)=VectorXd::Map(&values[0],values.size()); - return *(ptr); + int size = VectorType::RowsAtCompileTime; + if(size != Eigen::Dynamic && size != values.size()) + { + log(Debug) << "Cannot copy an std vector of size " << values.size() + << " into an eigen vector of (fixed) size " << size + << endlog(); + return VectorType::Constant(size, RTT::internal::NA::na()); + } + // NOTE: this can resize the eigen_vector + return VectorType::Map(values.data(),values.size()); } }; - struct vector_index_constructor - : public std::unary_function + template + struct vector_size_constructor + : public std::unary_function { - typedef const VectorXd& (Signature)( int ); - mutable boost::shared_ptr< VectorXd > ptr; - vector_index_constructor() : - ptr( new VectorXd() ){} - const VectorXd& operator()(int size ) const + typedef VectorType (Signature)( int ); + VectorType operator()(int size ) const { - ptr->resize(size); - return *(ptr); + return VectorType::Zero(size); } }; - struct matrix_index - : public std::ternary_function + template + struct matrix_index_functor + : public std::ternary_function { - double operator()(const MatrixXd& m, int i, int j) const{ + double operator()(const MatrixType& m, int i, int j) const{ if ( i >= (int)(m.rows()) || i < 0 || j<0 || j>= (int)(m.cols())) return 0.0; return m(i,j); } }; + template struct matrix_i_j_constructor - : public std::binary_function + : public std::binary_function { - typedef const MatrixXd& (Signature)( int, int ); - mutable boost::shared_ptr< MatrixXd > ptr; - matrix_i_j_constructor() : - ptr( new MatrixXd() ){} - const MatrixXd& operator()(int size1,int size2) const + typedef MatrixType (Signature)( int, int ); + MatrixType operator()(int size1,int size2) const { - ptr->resize(size1,size2); - return *(ptr); + return MatrixType::Zero(size1,size2); } }; - std::string EigenTypekitPlugin::getName() { return "Eigen"; @@ -387,23 +416,40 @@ namespace Eigen{ bool EigenTypekitPlugin::loadTypes() { - RTT::types::TypeInfoRepository::Instance()->addType( new VectorTypeInfo() ); - RTT::types::TypeInfoRepository::Instance()->addType( new MatrixTypeInfo() ); + RTT::types::TypeInfoRepository::Instance()->addType( new VectorTypeInfo("eigen_vector") ); + RTT::types::TypeInfoRepository::Instance()->addType( new VectorTypeInfo("eigen_vector2") ); + RTT::types::TypeInfoRepository::Instance()->addType( new VectorTypeInfo("eigen_vector3") ); + RTT::types::TypeInfoRepository::Instance()->addType( new VectorTypeInfo("eigen_vector4") ); + RTT::types::TypeInfoRepository::Instance()->addType( new VectorTypeInfo("eigen_vector6") ); + RTT::types::TypeInfoRepository::Instance()->addType( new MatrixTypeInfo("eigen_matrix") ); + RTT::types::TypeInfoRepository::Instance()->addType( new MatrixTypeInfo("eigen_matrix2") ); + RTT::types::TypeInfoRepository::Instance()->addType( new MatrixTypeInfo("eigen_matrix3") ); + RTT::types::TypeInfoRepository::Instance()->addType( new MatrixTypeInfo("eigen_matrix4") ); return true; } bool EigenTypekitPlugin::loadConstructors() { - RTT::types::Types()->type("eigen_vector")->addConstructor(types::newConstructor(vector_index_constructor())); - RTT::types::Types()->type("eigen_vector")->addConstructor(types::newConstructor(vector_index_value_constructor())); - RTT::types::Types()->type("eigen_vector")->addConstructor(types::newConstructor(vector_index_array_constructor())); - RTT::types::Types()->type("eigen_matrix")->addConstructor(types::newConstructor(matrix_i_j_constructor())); + RTT::types::Types()->type("eigen_vector")->addConstructor(types::newConstructor(vector_size_constructor())); + RTT::types::Types()->type("eigen_vector")->addConstructor(types::newConstructor(vector_size_value_constructor())); + + RTT::types::Types()->type("eigen_vector")->addConstructor(types::newConstructor(vector_array_constructor(),true)); + RTT::types::Types()->type("eigen_vector2")->addConstructor(types::newConstructor(vector_fixed_array_constructor(),true)); + RTT::types::Types()->type("eigen_vector3")->addConstructor(types::newConstructor(vector_fixed_array_constructor(),true)); + RTT::types::Types()->type("eigen_vector4")->addConstructor(types::newConstructor(vector_fixed_array_constructor(),true)); + RTT::types::Types()->type("eigen_vector6")->addConstructor(types::newConstructor(vector_fixed_array_constructor(),true)); + + RTT::types::Types()->type("eigen_matrix")->addConstructor(types::newConstructor(matrix_i_j_constructor())); return true; } bool EigenTypekitPlugin::loadOperators() { - RTT::types::OperatorRepository::Instance()->add( newBinaryOperator( "[]", vector_index() ) ); + RTT::types::OperatorRepository::Instance()->add( newBinaryOperator( "[]", vector_index() ) ); + RTT::types::OperatorRepository::Instance()->add( newBinaryOperator( "[]", vector_index() ) ); + RTT::types::OperatorRepository::Instance()->add( newBinaryOperator( "[]", vector_index() ) ); + RTT::types::OperatorRepository::Instance()->add( newBinaryOperator( "[]", vector_index() ) ); + RTT::types::OperatorRepository::Instance()->add( newBinaryOperator( "[]", vector_index() ) ); //RTT::types::OperatorRepository::Instance()->add( newDotOperator( "size", get_size() ) ); //RTT::types::OperatorRepository::Instance()->add( newTernaryOperator( "[,]", matrix_index() ) ); return true; diff --git a/eigen_typekit/include/orocos/eigen_typekit/eigen_typekit.hpp b/eigen_typekit/include/orocos/eigen_typekit/eigen_typekit.hpp index a2c2938..7ffe046 100644 --- a/eigen_typekit/include/orocos/eigen_typekit/eigen_typekit.hpp +++ b/eigen_typekit/include/orocos/eigen_typekit/eigen_typekit.hpp @@ -28,6 +28,8 @@ // import most common Eigen types namespace Eigen { +typedef Matrix Vector6d; + class EigenTypekitPlugin: public RTT::types::TypekitPlugin { public: virtual std::string getName(); @@ -37,54 +39,121 @@ class EigenTypekitPlugin: public RTT::types::TypekitPlugin { virtual bool loadOperators(); }; } + #ifdef CORELIB_DATASOURCE_HPP - extern template class RTT::internal::DataSourceTypeInfo< Eigen::VectorXd >; - extern template class RTT::internal::DataSource< Eigen::VectorXd >; - extern template class RTT::internal::AssignableDataSource< Eigen::VectorXd >; - extern template class RTT::internal::AssignCommand< Eigen::VectorXd >; +#define DECLARE_VECTOR_CORELIB_DATASOURCE_HPP(VectorType) \ + extern template class RTT::internal::DataSourceTypeInfo< VectorType >; \ + extern template class RTT::internal::DataSource< VectorType >; \ + extern template class RTT::internal::AssignableDataSource< VectorType >; \ + extern template class RTT::internal::AssignCommand< VectorType >; + + DECLARE_VECTOR_CORELIB_DATASOURCE_HPP(Eigen::VectorXd) + DECLARE_VECTOR_CORELIB_DATASOURCE_HPP(Eigen::Vector2d) + DECLARE_VECTOR_CORELIB_DATASOURCE_HPP(Eigen::Vector3d) + DECLARE_VECTOR_CORELIB_DATASOURCE_HPP(Eigen::Vector4d) + DECLARE_VECTOR_CORELIB_DATASOURCE_HPP(Eigen::Vector6d) #endif + #ifdef ORO_CORELIB_DATASOURCES_HPP - extern template class RTT::internal::ValueDataSource< Eigen::VectorXd >; - extern template class RTT::internal::ConstantDataSource< Eigen::VectorXd >; - extern template class RTT::internal::ReferenceDataSource< Eigen::VectorXd >; +#define DECLARE_VECTOR_ORO_CORELIB_DATASOURCES_HPP(VectorType) \ + extern template class RTT::internal::ValueDataSource< VectorType >; \ + extern template class RTT::internal::ConstantDataSource< VectorType >; \ + extern template class RTT::internal::ReferenceDataSource< VectorType >; + + DECLARE_VECTOR_ORO_CORELIB_DATASOURCES_HPP(Eigen::VectorXd) + DECLARE_VECTOR_ORO_CORELIB_DATASOURCES_HPP(Eigen::Vector2d) + DECLARE_VECTOR_ORO_CORELIB_DATASOURCES_HPP(Eigen::Vector3d) + DECLARE_VECTOR_ORO_CORELIB_DATASOURCES_HPP(Eigen::Vector4d) + DECLARE_VECTOR_ORO_CORELIB_DATASOURCES_HPP(Eigen::Vector6d) #endif + #ifdef ORO_OUTPUT_PORT_HPP extern template class RTT::OutputPort< Eigen::VectorXd >; + extern template class RTT::OutputPort< Eigen::Vector2d >; + extern template class RTT::OutputPort< Eigen::Vector3d >; + extern template class RTT::OutputPort< Eigen::Vector4d >; + extern template class RTT::OutputPort< Eigen::Vector6d >; #endif + #ifdef ORO_INPUT_PORT_HPP extern template class RTT::InputPort< Eigen::VectorXd >; + extern template class RTT::InputPort< Eigen::Vector2d >; + extern template class RTT::InputPort< Eigen::Vector3d >; + extern template class RTT::InputPort< Eigen::Vector4d >; + extern template class RTT::InputPort< Eigen::Vector6d >; #endif + #ifdef ORO_PROPERTY_HPP extern template class RTT::Property< Eigen::VectorXd >; + extern template class RTT::Property< Eigen::Vector2d >; + extern template class RTT::Property< Eigen::Vector3d >; + extern template class RTT::Property< Eigen::Vector4d >; + extern template class RTT::Property< Eigen::Vector6d >; #endif + #ifdef ORO_CORELIB_ATTRIBUTE_HPP - extern template class RTT::Attribute< Eigen::VectorXd >; - extern template class RTT::Constant< Eigen::VectorXd >; +#define DECLARE_VECTOR_ORO_CORELIB_ATTRIBUTE_HPP(VectorType) \ + extern template class RTT::Attribute< VectorType >; \ + extern template class RTT::Constant< VectorType >; + + DECLARE_VECTOR_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::VectorXd) + DECLARE_VECTOR_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::Vector2d) + DECLARE_VECTOR_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::Vector3d) + DECLARE_VECTOR_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::Vector4d) + DECLARE_VECTOR_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::Vector6d) #endif + #ifdef CORELIB_DATASOURCE_HPP - extern template class RTT::internal::DataSourceTypeInfo< Eigen::MatrixXd >; - extern template class RTT::internal::DataSource< Eigen::MatrixXd >; - extern template class RTT::internal::AssignableDataSource< Eigen::MatrixXd >; - extern template class RTT::internal::AssignCommand< Eigen::MatrixXd >; +#define DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(MatrixType) \ + extern template class RTT::internal::DataSourceTypeInfo< MatrixType >; \ + extern template class RTT::internal::DataSource< MatrixType >; \ + extern template class RTT::internal::AssignableDataSource< MatrixType >; \ + extern template class RTT::internal::AssignCommand< MatrixType >; + + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::MatrixXd) + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::Matrix2d) + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::Matrix3d) + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::Matrix4d) #endif #ifdef ORO_CORELIB_DATASOURCES_HPP - extern template class RTT::internal::ValueDataSource< Eigen::MatrixXd >; - extern template class RTT::internal::ConstantDataSource< Eigen::MatrixXd >; - extern template class RTT::internal::ReferenceDataSource< Eigen::MatrixXd >; +#define DECLARE_MATRIX_ORO_CORELIB_DATASOURCES_HPP(MatrixType) \ + extern template class RTT::internal::ValueDataSource< MatrixType >; \ + extern template class RTT::internal::ConstantDataSource< MatrixType >; \ + extern template class RTT::internal::ReferenceDataSource< MatrixType >; + + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::MatrixXd) + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::Matrix2d) + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::Matrix3d) + DECLARE_MATRIX_CORELIB_DATASOURCE_HPP(Eigen::Matrix4d) #endif #ifdef ORO_OUTPUT_PORT_HPP extern template class RTT::OutputPort< Eigen::MatrixXd >; + extern template class RTT::OutputPort< Eigen::Matrix2d >; + extern template class RTT::OutputPort< Eigen::Matrix3d >; + extern template class RTT::OutputPort< Eigen::Matrix4d >; #endif #ifdef ORO_INPUT_PORT_HPP extern template class RTT::InputPort< Eigen::MatrixXd >; + extern template class RTT::InputPort< Eigen::Matrix2d >; + extern template class RTT::InputPort< Eigen::Matrix3d >; + extern template class RTT::InputPort< Eigen::Matrix4d >; #endif #ifdef ORO_PROPERTY_HPP extern template class RTT::Property< Eigen::MatrixXd >; + extern template class RTT::Property< Eigen::Matrix2d >; + extern template class RTT::Property< Eigen::Matrix3d >; + extern template class RTT::Property< Eigen::Matrix4d >; #endif #ifdef ORO_CORELIB_ATTRIBUTE_HPP - extern template class RTT::Attribute< Eigen::MatrixXd >; - extern template class RTT::Constant< Eigen::MatrixXd >; +#define DECLARE_MATRIX_ORO_CORELIB_ATTRIBUTE_HPP(MatrixType) \ + extern template class RTT::Attribute< MatrixType >; \ + extern template class RTT::Constant< MatrixType >; + + DECLARE_MATRIX_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::MatrixXd) + DECLARE_MATRIX_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::Matrix2d) + DECLARE_MATRIX_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::Matrix3d) + DECLARE_MATRIX_ORO_CORELIB_ATTRIBUTE_HPP(Eigen::Matrix4d) #endif #endif // ifndef EIGEN_TYPEKIT_HPP