position.hxx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // file : examples/persistence/position.hxx
  2. // copyright : not copyrighted - public domain
  3. #ifndef POSITION_HXX
  4. #define POSITION_HXX
  5. #include <string>
  6. #include <vector>
  7. #include <iosfwd>
  8. #include <xml/forward> // xml::{parser,serializer} forward declarations.
  9. enum object_type {building, mountain};
  10. // XML parser and serializer will use these operators to convert
  11. // object_type to/from a string representation unless we provide
  12. // an xml::value_traits specialization.
  13. //
  14. std::ostream&
  15. operator<< (std::ostream&, object_type);
  16. std::istream&
  17. operator>> (std::istream&, object_type&);
  18. class position
  19. {
  20. public:
  21. // Constructors as well as accessor and modifiers not shown.
  22. // XML persistence.
  23. //
  24. public:
  25. position (xml::parser&);
  26. void
  27. serialize (xml::serializer&) const;
  28. private:
  29. float lat_;
  30. float lon_;
  31. };
  32. class object
  33. {
  34. public:
  35. typedef std::vector<position> positions_type;
  36. // Constructors as well as accessor and modifiers not shown.
  37. // XML persistence.
  38. //
  39. public:
  40. object (xml::parser&);
  41. void
  42. serialize (xml::serializer&) const;
  43. private:
  44. std::string name_;
  45. object_type type_;
  46. unsigned int id_;
  47. positions_type positions_;
  48. };
  49. #endif // POSITION_HXX