From 707cc94fe52463870a9c6c8e2e66eaaa389e601d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 24 Feb 2009 15:16:26 +0200 Subject: Start tracking XSD/e with git after version 3.0.0 --- examples/cxx/hybrid/streaming/object-simpl.cxx | 69 ++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 examples/cxx/hybrid/streaming/object-simpl.cxx (limited to 'examples/cxx/hybrid/streaming/object-simpl.cxx') diff --git a/examples/cxx/hybrid/streaming/object-simpl.cxx b/examples/cxx/hybrid/streaming/object-simpl.cxx new file mode 100644 index 0000000..f23e0d4 --- /dev/null +++ b/examples/cxx/hybrid/streaming/object-simpl.cxx @@ -0,0 +1,69 @@ +// file : examples/cxx/hybrid/streaming/object-simpl.cxx +// author : Boris Kolpackov +// copyright : not copyrighted - public domain + +// Include position-simpl.hxx (which includes object-simpl.hxx) +// instead of object-simpl.hxx. +// +#include "position-simpl.hxx" + +// Position measurement instrument interface. +// +struct measurements +{ + float lat; + float lon; +}; + +measurements test_measurements [8] = +{ + {-33.8569F, 18.5083F}, + {-33.8568F, 18.5083F}, + {-33.8568F, 18.5082F}, + {-33.8570F, 18.5083F}, + {-33.8569F, 18.5084F}, + {-33.8570F, 18.5084F}, + {-33.8570F, 18.5082F}, + {-33.8569F, 18.5082F} +}; + +static void +measure_position (unsigned int n, float& lat, float& lon) +{ + // Call the instrument to measure the position. + // + lat = test_measurements[n].lat; + lon = test_measurements[n].lon; +} + +// Serializer implementation. +// +void object_simpl:: +pre (const object& obj) +{ + // Cache the object id and determine how many position measuremenets + // we need to take. + // + id_ = obj.id (); + count_ = 8; +} + +unsigned int object_simpl:: +id () +{ + return id_; +} + +bool object_simpl:: +position_next () +{ + return count_ > 0; +} + +const position& object_simpl:: +position () +{ + count_--; + measure_position (count_, cur_pos_.lat (), cur_pos_.lon ()); + return cur_pos_; +} -- cgit v1.1