38 #ifndef PI_PROPERTIES_TABLEHEADER_SERIALIZER 39 #define PI_PROPERTIES_TABLEHEADER_SERIALIZER 41 #include <rtt/Property.hpp> 42 #include <rtt/base/PropertyIntrospection.hpp> 43 #include <rtt/marsh/StreamProcessor.hpp> 54 template<
typename o_stream>
56 :
public marsh::MarshallInterface,
public marsh::StreamProcessor<o_stream>
60 std::vector<std::string> header;
62 typedef o_stream output_stream;
63 typedef o_stream OutputStream;
66 marsh::StreamProcessor<o_stream>(os), level(0), line(1)
69 header.push_back(std::string(
""));
74 virtual void serialize(base::PropertyBase* v)
76 Property<PropertyBag>* bag =
dynamic_cast< Property<PropertyBag>*
>( v );
78 this->serialize( *bag );
80 store( v->getName() );
84 virtual void serialize(
const PropertyBag &v)
105 PropertyBag::const_iterator i = v.getProperties().begin();
106 i != v.getProperties().end();
121 if ( line ==
int(header.size()) )
124 header.push_back(std::string(
""));
126 header[line-1] += std::string(
" | ") + s;
128 return header[line-1].length();
133 if ( line ==
int(header.size() ) )
134 header.push_back(std::string(
""));
138 if (
int(header[line-1].length()) -
int(header[line].length()) > 0 )
141 header[line] += std::string(
" | ");
143 if (
int(header[line-1].length()) -
int(header[line].length()) > 0 )
144 header[line] += std::string( header[line-1].length() - header[line].length() ,
' ');
151 std::string name = v.getName();
152 if ( v.value().getType() !=
"type_less")
153 name+= std::string(
" <") + v.value().getType() + std::string(
">");
160 if ( v.value().getProperties().empty() )
161 store( std::string(
"<empty>") );
163 serialize(v.value());
169 if (
int(header[line].length()) - int(header[line -1].length()) > 0)
170 header[line-1] += std::string( header[line].length() - header[line-1].length(),
' ');
175 for (std::vector<std::string>::iterator it = header.begin(); it != header.end(); ++it)
177 *this->s << *it <<std::string(
" |")<<std::endl;
182 header.push_back(std::string(
""));