Skip to content

Commit

Permalink
WIP: remove CObject and CSerializable
Browse files Browse the repository at this point in the history
  • Loading branch information
jolting committed Oct 10, 2016
1 parent ec9422d commit 0dbaa3c
Show file tree
Hide file tree
Showing 67 changed files with 244 additions and 1,986 deletions.
19 changes: 6 additions & 13 deletions libs/base/include/mrpt/math/CMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,22 @@
#ifndef CMATRIX_H
#define CMATRIX_H

#include <mrpt/utils/CSerializable.h>
#include <mrpt/math/CMatrixTemplateNumeric.h>
#include <mrpt/math/CMatrixFixedNumeric.h>
#include <memory>

namespace mrpt
{
namespace math
{
// This must be added to any CSerializable derived class:
// Note: instead of the standard "DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE", classes inheriting
// from templates need special nasty handling for MSVC DLL exports...
DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(CMatrix, mrpt::utils::CSerializable, CMatrix)
BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, CMatrixPtr &pObj);

/** This class is a "CSerializable" wrapper for "CMatrixFloat".
* \note For a complete introduction to Matrices and vectors in MRPT, see: http://www.mrpt.org/Matrices_vectors_arrays_and_Linear_Algebra_MRPT_and_Eigen_classes
* \ingroup mrpt_base_grp
*/
class BASE_IMPEXP_TEMPL CMatrix : public mrpt::utils::CSerializable, public CMatrixFloat
class BASE_IMPEXP_TEMPL CMatrix : public CMatrixFloat
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE_CUSTOM_LINKAGE( CMatrix, void BASE_IMPEXP, static BASE_IMPEXP, virtual BASE_IMPEXP )

public:
typedef std::shared_ptr<CMatrix> Ptr;
/** Constructor */
CMatrix() : CMatrixFloat(1,1)
{ }
Expand Down Expand Up @@ -80,9 +72,10 @@ namespace mrpt
/*! Constructor from any other Eigen class */
template<typename OtherDerived>
inline CMatrix(const Eigen::MatrixBase <OtherDerived>& other) : CMatrixTemplateNumeric<float>(other) { }

void writeToStream(mrpt::utils::CStream &out, int *version) const;
void readFromStream(mrpt::utils::CStream &in, int version);
}; // end of class definition
DEFINE_MRPT_OBJECT_POST_CUSTOM_BASE_LINKAGE2(CMatrix, mrpt::utils::CSerializable, CMatrix)
BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, CMatrix::Ptr &pObj);

} // End of namespace
} // End of namespace
Expand Down
11 changes: 4 additions & 7 deletions libs/base/include/mrpt/math/CMatrixB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,23 @@ namespace mrpt
{
namespace math
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CMatrixB, mrpt::utils::CSerializable )

/** This class is a "CSerializable" wrapper for "CMatrixBool".
* \note For a complete introduction to Matrices and vectors in MRPT, see: http://www.mrpt.org/Matrices_vectors_arrays_and_Linear_Algebra_MRPT_and_Eigen_classes
* \ingroup mrpt_base_grp
*/
class BASE_IMPEXP CMatrixB : public mrpt::utils::CSerializable, public CMatrixBool
class BASE_IMPEXP CMatrixB : public CMatrixBool
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE( CMatrixB )
public:
typedef std::shared_ptr<CMatrixB> Ptr;
/** Constructor */
CMatrixB(size_t row = 1, size_t col = 1) : CMatrixBool(row,col) { }
/** Copy constructor */
CMatrixB( const CMatrixBool &m ) : CMatrixBool(m) { }
/** Assignment operator for float matrixes */
CMatrixB & operator = (const CMatrixBool& m) { CMatrixBool::operator =(m); return *this; }
void writeToStream(mrpt::utils::CStream &out, int *out_Version) const;
void readFromStream(mrpt::utils::CStream &in, int version);
}; // end of class definition
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE( CMatrixB, mrpt::utils::CSerializable )

} // End of namespace
} // End of namespace
Expand Down
18 changes: 7 additions & 11 deletions libs/base/include/mrpt/math/CMatrixD.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,22 @@
#ifndef CMATRIXD_H
#define CMATRIXD_H

#include <mrpt/utils/CSerializable.h>
#include <mrpt/math/CMatrixTemplateNumeric.h>

#include <memory>
namespace mrpt
{
namespace math
{
// This must be added to any CSerializable derived class:
// Note: instead of the standard "DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE", classes inheriting
// from templates need special nasty handling for MSVC DLL exports...
DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(CMatrixD, mrpt::utils::CSerializable, CMatrixD)
BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, CMatrixDPtr &pObj);


/** This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
* \note For a complete introduction to Matrices and vectors in MRPT, see: http://www.mrpt.org/Matrices_vectors_arrays_and_Linear_Algebra_MRPT_and_Eigen_classes
* \ingroup mrpt_base_grp
*/
class BASE_IMPEXP_TEMPL CMatrixD : public mrpt::utils::CSerializable, public CMatrixTemplateNumeric<double>
class BASE_IMPEXP_TEMPL CMatrixD : public CMatrixTemplateNumeric<double>
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE_CUSTOM_LINKAGE( CMatrixD, void BASE_IMPEXP, static BASE_IMPEXP, virtual BASE_IMPEXP )
public:
typedef std::shared_ptr<CMatrixD> Ptr;
/** Constructor */
CMatrixD() : CMatrixTemplateNumeric<double>(1,1)
{ }
Expand Down Expand Up @@ -68,8 +61,11 @@ namespace mrpt
/** Constructor from a TPoint3D, which generates a 3x1 matrix \f$ [x y z]^T \f$ */
explicit CMatrixD( const TPoint3D &p);

void writeToStream(mrpt::utils::CStream &out, int *out_Version) const;
void readFromStream(mrpt::utils::CStream &in, int version);
}; // end of class definition
DEFINE_MRPT_OBJECT_POST_CUSTOM_BASE_LINKAGE2(CMatrixD, mrpt::utils::CSerializable, CMatrixD)

BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, CMatrixD::Ptr &pObj);

} // End of namespace
} // End of namespace
Expand Down
10 changes: 1 addition & 9 deletions libs/base/include/mrpt/math/CMatrixFixedNumeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <mrpt/math/math_frwds.h> // Forward declarations
#include <mrpt/math/eigen_frwds.h>
#include <mrpt/utils/types_math.h>
#include <mrpt/utils/CSerializable.h>
#include <mrpt/math/point_poses2vectors.h> // MRPT_MATRIX_CONSTRUCTORS_FROM_POSES()
#include <mrpt/utils/mrpt_macros.h>

namespace mrpt
{
Expand Down Expand Up @@ -104,14 +104,6 @@ namespace mrpt

} // End of namespace

namespace utils
{
// Extensions to mrpt::utils::TTypeName for matrices:
template<typename T,size_t N,size_t M> struct TTypeName <mrpt::math::CMatrixFixedNumeric<T,N,M> > {
static std::string get() { return mrpt::format("CMatrixFixedNumeric<%s,%u,%u>",TTypeName<T>::get().c_str(),(unsigned int)N,(unsigned int)M); }
};
}

} // End of namespace

#endif
15 changes: 3 additions & 12 deletions libs/base/include/mrpt/math/CPolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,14 @@
#ifndef CPOLYGON_H
#define CPOLYGON_H

#include <mrpt/utils/CSerializable.h>
#include <mrpt/math/lightweight_geom_data.h>

namespace mrpt
{
namespace math
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CPolygon, mrpt::utils::CSerializable )

/** A wrapper of a TPolygon2D class, implementing CSerializable.
* \ingroup geometry_grp
*/
class BASE_IMPEXP CPolygon : public mrpt::utils::CSerializable, public mrpt::math::TPolygon2D
class BASE_IMPEXP CPolygon : public mrpt::math::TPolygon2D
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE( CPolygon )

public:
/** Default constructor (empty polygon, 0 vertices) */
CPolygon() : TPolygon2D()
Expand Down Expand Up @@ -61,8 +51,9 @@ namespace math
bool PointIntoPolygon(double x,double y) const {
return TPolygon2D::contains(TPoint2D(x,y));
}
void writeToStream(mrpt::utils::CStream &out, int *version) const;
void readFromStream(mrpt::utils::CStream &in, int version);
};
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE( CPolygon, mrpt::utils::CSerializable )

} // End of namespace
} // End of namespace
Expand Down
15 changes: 4 additions & 11 deletions libs/base/include/mrpt/math/CSplineInterpolator1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,21 @@
#define CSplineInterpolator1D_H

#include <mrpt/utils/utils_defs.h>
#include <mrpt/utils/CSerializable.h>
#include <mrpt/utils/CStream.h>
#include <map>

namespace mrpt
{
namespace math
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CSplineInterpolator1D, mrpt::utils::CSerializable )

/** A (persistent) sequence of (x,y) coordinates, allowing queries of intermediate points through spline interpolation, where possible.
* This class internally relies on mrpt::math::spline. Optionally the y coordinate can be set as wrapped in ]-pi,pi].
* For querying interpolated points, see
* \ sa mrpt::math::spline, mrpt::poses::CPose3DInterpolator
* \ingroup interpolation_grp
*/
class BASE_IMPEXP CSplineInterpolator1D : public mrpt::utils::CSerializable
class BASE_IMPEXP CSplineInterpolator1D
{
// This must be added to any CSerializable derived class:
DEFINE_SERIALIZABLE( CSplineInterpolator1D )

private:
/** The placeholders for the data */
std::map<double,double> m_x2y;
Expand Down Expand Up @@ -102,10 +96,9 @@ namespace mrpt
}
return anyValid;
}

void writeToStream(mrpt::utils::CStream &out, int *version) const;
void readFromStream(mrpt::utils::CStream &in, int version);
};
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE( CSplineInterpolator1D, mrpt::utils::CSerializable )

} // End of namespace
} // End of namespace
#endif
6 changes: 2 additions & 4 deletions libs/base/include/mrpt/math/matrix_serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ namespace mrpt
/** Read operator from a CStream. The format is compatible with that of CMatrix & CMatrixD */
template <size_t NROWS,size_t NCOLS>
mrpt::utils::CStream &operator>>(mrpt::utils::CStream &in, CMatrixFixedNumeric<float,NROWS,NCOLS> & M) {
CMatrix aux;
in.ReadObject(&aux);
CMatrix &aux = boost::get<CMatrix>(in.ReadObject());
ASSERTMSG_(M.cols()==aux.cols() && M.rows()==aux.rows(), format("Size mismatch: deserialized is %ux%u, expected is %ux%u",(unsigned)aux.getRowCount(),(unsigned)aux.getColCount(),(unsigned)NROWS,(unsigned)NCOLS))
M = aux;
return in;
}
/** Read operator from a CStream. The format is compatible with that of CMatrix & CMatrixD */
template <size_t NROWS,size_t NCOLS>
mrpt::utils::CStream &operator>>(mrpt::utils::CStream &in, CMatrixFixedNumeric<double,NROWS,NCOLS> & M) {
CMatrixD aux;
in.ReadObject(&aux);
const CMatrixD &aux = boost::get<CMatrixD>(in.ReadObject());
ASSERTMSG_(M.cols()==aux.cols() && M.rows()==aux.rows(), format("Size mismatch: deserialized is %ux%u, expected is %ux%u",(unsigned)aux.getRowCount(),(unsigned)aux.getColCount(),(unsigned)NROWS,(unsigned)NCOLS))
M = aux;
return in;
Expand Down
135 changes: 0 additions & 135 deletions libs/base/include/mrpt/otherlibs/stlplus/containers_fixes.hpp

This file was deleted.

0 comments on commit 0dbaa3c

Please sign in to comment.