00001 #include "eigen_mqueue.hpp"
00002 #include <rtt/transports/mqueue/MQTemplateProtocol.hpp>
00003 #include <rtt/transports/mqueue/MQSerializationProtocol.hpp>
00004 #include <rtt/types/TransportPlugin.hpp>
00005 #include <rtt/types/TypekitPlugin.hpp>
00006 #include <boost/serialization/vector.hpp>
00007 #include <Eigen/Dense>
00008
00009 using namespace std;
00010 using namespace RTT::detail;
00011 using namespace Eigen;
00012 using namespace RTT;
00013 using namespace RTT::mqueue;
00014 using namespace RTT::types;
00015
00016
00017 namespace boost{
00018 namespace serialization{
00019
00020 template< class Archive,
00021 class S,
00022 int Rows_,
00023 int Cols_,
00024 int Ops_,
00025 int MaxRows_,
00026 int MaxCols_>
00027 inline void save(
00028 Archive & ar,
00029 const Eigen::Matrix<S, Rows_, Cols_, Ops_, MaxRows_, MaxCols_> & g,
00030 const unsigned int version)
00031 {
00032 int rows = g.rows();
00033 int cols = g.cols();
00034
00035 ar & rows;
00036 ar & cols;
00037 ar & boost::serialization::make_array(g.data(), g.size());
00038 }
00039
00040 template< class Archive,
00041 class S,
00042 int Rows_,
00043 int Cols_,
00044 int Ops_,
00045 int MaxRows_,
00046 int MaxCols_>
00047 inline void load(
00048 Archive & ar,
00049 Eigen::Matrix<S, Rows_, Cols_, Ops_, MaxRows_, MaxCols_> & g,
00050 const unsigned int version)
00051 {
00052 int rows, cols;
00053 ar & rows;
00054 ar & cols;
00055 g.resize(rows, cols);
00056 ar & boost::serialization::make_array(g.data(), g.size());
00057 }
00058
00059 template< class Archive,
00060 class S,
00061 int Rows_,
00062 int Cols_,
00063 int Ops_,
00064 int MaxRows_,
00065 int MaxCols_>
00066 inline void serialize(
00067 Archive & ar,
00068 Eigen::Matrix<S, Rows_, Cols_, Ops_, MaxRows_, MaxCols_> & g,
00069 const unsigned int version)
00070 {
00071 split_free(ar, g, version);
00072 }
00073
00074
00075 }
00076 }
00077 namespace RTT {
00078 namespace mqueue {
00079 bool MQEigenPlugin::registerTransport(std::string name, TypeInfo* ti)
00080 {
00081 if ( name == "eigen_vector" )
00082 return ti->addProtocol(ORO_MQUEUE_PROTOCOL_ID, new MQSerializationProtocol<Eigen::VectorXd>() );
00083 if ( name == "eigen_matrix" )
00084 return ti->addProtocol(ORO_MQUEUE_PROTOCOL_ID, new MQSerializationProtocol<Eigen::MatrixXd>() );
00085
00086 return false;
00087 }
00088
00089 std::string MQEigenPlugin::getTransportName() const {
00090 return "mqueue";
00091 }
00092
00093 std::string MQEigenPlugin::getTypekitName() const {
00094 return "Eigen";
00095 }
00096 std::string MQEigenPlugin::getName() const {
00097 return "eigen-mqueue-types";
00098 }
00099 }
00100 }
00101
00102 ORO_TYPEKIT_PLUGIN( RTT::mqueue::MQEigenPlugin )
00103