position.hxx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // file : examples/inheritance/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. class position
  10. {
  11. public:
  12. // Constructors as well as accessor and modifiers not shown.
  13. // XML persistence.
  14. //
  15. public:
  16. position (xml::parser&);
  17. void
  18. serialize (xml::serializer&) const;
  19. private:
  20. float lat_;
  21. float lon_;
  22. };
  23. class object
  24. {
  25. public:
  26. typedef std::vector<position> positions_type;
  27. // Constructors as well as accessor and modifiers not shown.
  28. // XML persistence.
  29. //
  30. public:
  31. object (xml::parser&);
  32. void
  33. serialize_attributes (xml::serializer&) const;
  34. void
  35. serialize_content (xml::serializer&) const;
  36. void
  37. serialize (xml::serializer& s) const
  38. {
  39. serialize_attributes (s);
  40. serialize_content (s);
  41. }
  42. private:
  43. std::string name_;
  44. unsigned int id_;
  45. positions_type positions_;
  46. };
  47. class elevation
  48. {
  49. public:
  50. // Constructors as well as accessor and modifiers not shown.
  51. // XML persistence.
  52. //
  53. public:
  54. elevation (xml::parser&);
  55. void
  56. serialize (xml::serializer&) const;
  57. private:
  58. float value_;
  59. };
  60. class elevated_object: public object
  61. {
  62. public:
  63. typedef std::vector<elevation> elevations_type;
  64. // Constructors as well as accessor and modifiers not shown.
  65. // XML persistence.
  66. //
  67. public:
  68. elevated_object (xml::parser&);
  69. void
  70. serialize_attributes (xml::serializer&) const;
  71. void
  72. serialize_content (xml::serializer&) const;
  73. void
  74. serialize (xml::serializer& s) const
  75. {
  76. serialize_attributes (s);
  77. serialize_content (s);
  78. }
  79. private:
  80. std::string units_;
  81. elevations_type elevations_;
  82. };
  83. class objects
  84. {
  85. public:
  86. typedef std::vector<object> simple_objects_type;
  87. typedef std::vector<elevated_object> elevated_objects_type;
  88. // Constructors as well as accessor and modifiers not shown.
  89. // XML persistence.
  90. //
  91. public:
  92. objects (xml::parser&);
  93. void
  94. serialize (xml::serializer&) const;
  95. private:
  96. simple_objects_type simple_objects_;
  97. elevated_objects_type elevated_objects_;
  98. };
  99. #endif // POSITION_HXX