Main MRPT website > C++ reference for MRPT 1.9.9
metaprogramming_serialization.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 
13 namespace mrpt
14 {
15 namespace serialization
16 {
17 namespace metaprogramming
18 {
19 /** \addtogroup stlext_grp
20  * @{ */
21 
22 /** An object for reading objects from a stream, intended for being used in STL
23  * algorithms. */
25 {
26  private:
28 
29  public:
31  : m_stream(stream)
32  {
33  }
34  // T can be CSerializable::Ptr, CSerializable, or any other class
35  // implementing ">>"
36  template <typename T>
37  inline void operator()(T& obj)
38  {
39  (*m_stream) >> obj;
40  }
41 };
42 
43 template <typename ptr_t>
45 {
46  private:
48 
49  public:
51  : m_stream(stream)
52  {
53  }
54  template <typename ptr2ptr_t>
55  inline void operator()(ptr2ptr_t& obj)
56  {
57  ptr_t p;
58  (*m_stream) >> p;
59  obj = p;
60  }
61 };
62 
63 /** An object for writing objects to a stream, intended for being used in STL
64  * algorithms. */
66 {
67  private:
69 
70  public:
72  : m_stream(stream)
73  {
74  }
75 
76  // T can be CSerializable::Ptr, CSerializable, or any other class
77  // implementing "<<"
78  template <typename T>
79  inline void operator()(const T& ptr)
80  {
81  (*m_stream) << ptr;
82  }
83 };
84 
85 /** @} */ // end of grouping
86 }
87 }
88 }
mrpt::serialization::metaprogramming::ObjectReadFromStream::operator()
void operator()(T &obj)
Definition: metaprogramming_serialization.h:37
mrpt::serialization::metaprogramming::ObjectReadFromStreamToPtrs
Definition: metaprogramming_serialization.h:44
mrpt::serialization::metaprogramming::ObjectReadFromStream
An object for reading objects from a stream, intended for being used in STL algorithms.
Definition: metaprogramming_serialization.h:24
mrpt::serialization::metaprogramming::ObjectReadFromStreamToPtrs::operator()
void operator()(ptr2ptr_t &obj)
Definition: metaprogramming_serialization.h:55
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::serialization::metaprogramming::ObjectReadFromStream::ObjectReadFromStream
ObjectReadFromStream(mrpt::serialization::CArchive *stream)
Definition: metaprogramming_serialization.h:30
p
GLfloat GLfloat p
Definition: glext.h:6305
mrpt::serialization::metaprogramming::ObjectWriteToStream::m_stream
mrpt::serialization::CArchive * m_stream
Definition: metaprogramming_serialization.h:68
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::serialization::metaprogramming::ObjectReadFromStream::m_stream
mrpt::serialization::CArchive * m_stream
Definition: metaprogramming_serialization.h:27
mrpt::serialization::metaprogramming::ObjectWriteToStream::operator()
void operator()(const T &ptr)
Definition: metaprogramming_serialization.h:79
mrpt::serialization::metaprogramming::ObjectWriteToStream::ObjectWriteToStream
ObjectWriteToStream(mrpt::serialization::CArchive *stream)
Definition: metaprogramming_serialization.h:71
mrpt::serialization::metaprogramming::ObjectWriteToStream
An object for writing objects to a stream, intended for being used in STL algorithms.
Definition: metaprogramming_serialization.h:65
serialization_frwds.h
mrpt::serialization::metaprogramming::ObjectReadFromStreamToPtrs::ObjectReadFromStreamToPtrs
ObjectReadFromStreamToPtrs(mrpt::serialization::CArchive *stream)
Definition: metaprogramming_serialization.h:50
mrpt::serialization::metaprogramming::ObjectReadFromStreamToPtrs::m_stream
mrpt::serialization::CArchive * m_stream
Definition: metaprogramming_serialization.h:47



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST