1 #ifndef PI_PROPERTIES_NETCDFTABLESERIALIZER 2 #define PI_PROPERTIES_NETCDFTABLESERIALIZER 6 #include <boost/lexical_cast.hpp> 34 ncid ( ncid ) {index=0;}
96 std::string oldpref = prefix;
107 nameless_counter = 0;
117 signed char value = v->
rvalue();
118 std::string sname = composeName(v->
getName());
123 retval = nc_inq_varid(ncid, sname.c_str(), &varid);
125 log(
Error) <<
"Could not get variable id of " << sname <<
", error " << retval <<endlog();
130 retval = nc_put_var1_schar(ncid, varid, &index, &value);
132 log(
Error) <<
"Could not write variable " << sname <<
", error " << retval <<endlog();
143 short value = v->
rvalue();
144 std::string sname = composeName(v->
getName());
149 retval = nc_inq_varid(ncid, sname.c_str(), &varid);
151 log(
Error) <<
"Could not get variable id of " << sname <<
", error " << retval <<endlog();
156 retval = nc_put_var1_short(ncid, varid, &index, &value);
158 log(
Error) <<
"Could not write variable " << sname <<
", error " << retval <<endlog();
169 std::string sname = composeName(v->
getName());
174 retval = nc_inq_varid(ncid, sname.c_str(), &varid);
176 log(
Error) <<
"Could not get variable id of " << sname <<
", error " << retval <<endlog();
181 retval = nc_put_var1_int(ncid, varid, &index, &value);
183 log(
Error) <<
"Could not write variable " << sname <<
", error " << retval <<endlog();
193 float value = v->
rvalue();
194 std::string sname = composeName(v->
getName());
199 retval = nc_inq_varid(ncid, sname.c_str(), &varid);
201 log(
Error) <<
"Could not get variable id of " << sname <<
", error " << retval <<endlog();
206 retval = nc_put_var1_float(ncid, varid, &index, &value);
208 log(
Error) <<
"Could not write variable " << sname <<
", error " << retval <<endlog();
219 double value = v->
rvalue();
220 std::string sname = composeName(v->
getName());
225 retval = nc_inq_varid(ncid, sname.c_str(), &varid);
227 log(
Error) <<
"Could not get variable id of " << sname <<
", error " << retval <<endlog();
232 retval = nc_put_var1_double(ncid, varid, &index, &value);
234 log(
Error) <<
"Could not write variable " << sname <<
", error " << retval <<endlog();
244 const char *name = v->getName().c_str();
245 size_t start[2], count[2];
250 start[0] = index; start[1] = 0;
254 count[0] = 1; count[1] = v->rvalue().size();
256 retval = nc_inq_varid(ncid, name, &varid);
258 log(
Error) <<
"Could not get variable id of " << name <<
", error " << retval <<endlog();
260 retval = nc_put_vara_double(ncid, varid, start, count, &(v->rvalue().front()));
262 log(
Error) <<
"Could not write variable " << name <<
", error " << retval <<endlog();
268 std::string last_name;
270 if( propertyName.empty() ) {
272 last_name = boost::lexical_cast<std::string>( nameless_counter );
275 nameless_counter = 0;
276 last_name = propertyName;
278 if ( prefix.empty() )
281 return prefix +
"." + last_name;
void store(Property< int > *v)
virtual void serialize(base::PropertyBase *v)
void store(Property< double > *v)
const_reference_t rvalue() const
NetcdfMarshaller(int ncid)
std::string composeName(std::string propertyName)
void store(Property< float > *v)
Properties & getProperties()
Properties::const_iterator const_iterator
void store(Property< char > *v)
const std::string & getName() const
void serialize(Archive &a, RTT::ConnPolicy &c, unsigned int)
void store(Property< short > *v)
virtual void serialize(const Property< PropertyBag > &v)
virtual void serialize(const PropertyBag &v)
void store(Property< std::vector< double > > *v)
virtual ~NetcdfMarshaller()