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
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
}
83
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
obj
GLsizei GLsizei GLuint * obj
Definition:
glext.h:4070
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:52
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
p
GLfloat GLfloat p
Definition:
glext.h:6305
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 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020