Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
reporting
NiceHeaderMarshaller.hpp
Go to the documentation of this file.
1
/***************************************************************************
2
tag: Peter Soetens Mon Jan 19 14:11:20 CET 2004 NiceHeaderMarshaller.hpp
3
4
NiceHeaderMarshaller.hpp - description
5
-------------------
6
begin : Mon January 19 2004
7
copyright : (C) 2004 Peter Soetens
8
email : peter.soetens@mech.kuleuven.ac.be
9
10
***************************************************************************
11
* This library is free software; you can redistribute it and/or *
12
* modify it under the terms of the GNU General Public *
13
* License as published by the Free Software Foundation; *
14
* version 2 of the License. *
15
* *
16
* As a special exception, you may use this file as part of a free *
17
* software library without restriction. Specifically, if other files *
18
* instantiate templates or use macros or inline functions from this *
19
* file, or you compile this file and link it with other files to *
20
* produce an execunice, this file does not by itself cause the *
21
* resulting execunice to be covered by the GNU General Public *
22
* License. This exception does not however invalidate any other *
23
* reasons why the execunice file might be covered by the GNU General *
24
* Public License. *
25
* *
26
* This library is distributed in the hope that it will be useful, *
27
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
28
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29
* Lesser General Public License for more details. *
30
* *
31
* You should have received a copy of the GNU General Public *
32
* License along with this library; if not, write to the Free Software *
33
* Foundation, Inc., 59 Temple Place, *
34
* Suite 330, Boston, MA 02111-1307 USA *
35
* *
36
***************************************************************************/
37
38
#ifndef PI_PROPERTIES_NICEHEADER_SERIALIZER
39
#define PI_PROPERTIES_NICEHEADER_SERIALIZER
40
41
#include <
rtt/Property.hpp
>
42
#include <
rtt/marsh/StreamProcessor.hpp
>
43
#include <
rtt/marsh/MarshallInterface.hpp
>
44
45
namespace
RTT
46
{
54
template
<
typename
o_stream>
55
class
NiceHeaderMarshaller
56
:
public
marsh::MarshallInterface
,
public
marsh::StreamProcessor
<o_stream>
57
{
58
bool
did_comment
;
59
int
nameless_counter
;
60
std::string
prefix
;
61
public
:
62
typedef
o_stream
output_stream
;
63
typedef
o_stream
OutputStream
;
64
65
NiceHeaderMarshaller
(output_stream &os) :
66
marsh::
StreamProcessor
<o_stream>(os),
67
did_comment(false), nameless_counter(0)
68
{
69
}
70
71
virtual
~NiceHeaderMarshaller
() {}
72
73
virtual
void
serialize
(
base::PropertyBase
* v)
74
{
75
Property<PropertyBag>
* bag =
dynamic_cast<
Property<PropertyBag>
*
>
( v );
76
if
( bag )
77
this->
serialize
( *bag );
78
else
79
store
( v->
getName
() );
80
}
81
82
83
virtual
void
serialize
(
const
PropertyBag
&v)
84
{
85
// start with a comment sign.
86
if
(did_comment ==
false
)
87
*this->
s
<<
""
;
88
did_comment =
true
;
89
90
for
(
91
PropertyBag::const_iterator
i = v.
getProperties
().begin();
92
i != v.
getProperties
().end();
93
i++ )
94
{
95
this->
serialize
(*i);
96
}
97
}
98
102
void
store
(
const
std::string& name)
103
{
104
if
( name.empty() )
105
++nameless_counter;
106
else
107
nameless_counter = 0;
108
if
( !prefix.empty() )
109
*this->
s
<<
' '
<< prefix <<
'.'
;
110
else
111
*this->
s
<<
' '
;
112
if
( nameless_counter )
113
*this->
s
<<
nameless_counter
;
114
else
115
*this->
s
<< name;
116
}
117
118
virtual
void
serialize
(
const
Property<PropertyBag>
&v)
119
{
120
if
( v.
rvalue
().empty() )
121
store
( v.
getName
() +
"[0]"
);
122
else
{
123
std::string oldpref =
prefix
;
124
if
( prefix.empty() )
125
prefix = v.
getName
();
126
else
127
prefix +=
'.'
+ v.
getName
();
128
129
serialize
(v.
rvalue
());
130
131
prefix = oldpref;
132
nameless_counter = 0;
133
}
134
}
135
136
virtual
void
flush
()
137
{
138
did_comment =
false
;
139
nameless_counter = 0;
140
*this->
s
<< std::endl;
141
this->
s
->flush();
142
143
}
144
};
145
}
146
#endif
RTT::NiceHeaderMarshaller::nameless_counter
int nameless_counter
Definition:
NiceHeaderMarshaller.hpp:59
RTT::marsh::MarshallInterface
RTT::base::PropertyBase
StreamProcessor.hpp
RTT::NiceHeaderMarshaller::~NiceHeaderMarshaller
virtual ~NiceHeaderMarshaller()
Definition:
NiceHeaderMarshaller.hpp:71
RTT::NiceHeaderMarshaller::NiceHeaderMarshaller
NiceHeaderMarshaller(output_stream &os)
Definition:
NiceHeaderMarshaller.hpp:65
RTT::NiceHeaderMarshaller::serialize
virtual void serialize(base::PropertyBase *v)
Definition:
NiceHeaderMarshaller.hpp:73
Property< PropertyBag >::rvalue
const_reference_t rvalue() const
RTT::NiceHeaderMarshaller::output_stream
o_stream output_stream
Definition:
NiceHeaderMarshaller.hpp:62
MarshallInterface.hpp
RTT::PropertyBag
RTT::NiceHeaderMarshaller::did_comment
bool did_comment
Definition:
NiceHeaderMarshaller.hpp:58
RTT::NiceHeaderMarshaller::serialize
virtual void serialize(const PropertyBag &v)
Definition:
NiceHeaderMarshaller.hpp:83
Property< PropertyBag >
RTT::marsh::StreamProcessor< o_stream >::s
o_stream * s
Property.hpp
RTT::PropertyBag::getProperties
Properties & getProperties()
RTT::PropertyBag::const_iterator
Properties::const_iterator const_iterator
RTT::marsh::StreamProcessor
RTT::NiceHeaderMarshaller
Definition:
NiceHeaderMarshaller.hpp:55
RTT::NiceHeaderMarshaller::flush
virtual void flush()
Definition:
NiceHeaderMarshaller.hpp:136
RTT::NiceHeaderMarshaller::store
void store(const std::string &name)
Definition:
NiceHeaderMarshaller.hpp:102
RTT::base::PropertyBase::getName
const std::string & getName() const
RTT::NiceHeaderMarshaller::prefix
std::string prefix
Definition:
NiceHeaderMarshaller.hpp:60
RTT::marsh::StreamProcessor< o_stream >::StreamProcessor
StreamProcessor(o_stream &_s)
RTT
RTT::NiceHeaderMarshaller::serialize
virtual void serialize(const Property< PropertyBag > &v)
Definition:
NiceHeaderMarshaller.hpp:118
RTT::NiceHeaderMarshaller::OutputStream
o_stream OutputStream
Definition:
NiceHeaderMarshaller.hpp:63
ocl
Author(s): OCL Development Team
autogenerated on Wed Jun 26 2019 19:26:27