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