OTSPeak.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #include "stdafx.h"
  2. #include "OTSPeak.h"
  3. // CIntRange
  4. namespace OTSDATA
  5. {
  6. // constructor
  7. COTSPeak::COTSPeak()
  8. {
  9. // initialization
  10. Init();
  11. }
  12. // copy constructor
  13. COTSPeak::COTSPeak(const COTSPeak& a_oSource)
  14. {
  15. // can't copy itself
  16. if (&a_oSource == this)
  17. {
  18. return;
  19. }
  20. // copy data over
  21. Duplicate(a_oSource);
  22. }
  23. // copy constructor
  24. COTSPeak::COTSPeak(COTSPeak* a_poSource)
  25. {
  26. // input check
  27. ASSERT(a_poSource);
  28. if (!a_poSource)
  29. {
  30. return;
  31. }
  32. // can't copy itself
  33. if (a_poSource == this)
  34. {
  35. return;
  36. }
  37. // copy data over
  38. Duplicate(*a_poSource);
  39. }
  40. // =operator
  41. COTSPeak& COTSPeak::operator=(const COTSPeak& a_oSource)
  42. {
  43. // cleanup
  44. Cleanup();
  45. // copy the class data over
  46. Duplicate(a_oSource);
  47. // return class
  48. return *this;
  49. }
  50. // ==operator
  51. BOOL COTSPeak::operator==(const COTSPeak& a_oSource)
  52. {
  53. // return test result
  54. return m_nPosition == a_oSource.m_nPosition &&
  55. m_nHeight == a_oSource.m_nHeight &&
  56. m_oRange == a_oSource.m_oRange;
  57. }
  58. // detractor
  59. COTSPeak::~COTSPeak()
  60. {
  61. Cleanup();
  62. }
  63. // COTSPeak member functions
  64. // public
  65. // serialization
  66. void COTSPeak::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  67. {
  68. xmls::xLong xnPosition;
  69. xmls::xLong xnHeight;
  70. xmls::Slo slo;
  71. slo.Register("Position", &xnPosition);
  72. slo.Register("Height", &xnHeight);
  73. // this->Register("Range", m_oRange.getClassName());
  74. if (isStoring)
  75. {
  76. xnPosition = m_nPosition;
  77. xnHeight = m_nHeight;
  78. slo.Serialize(true, classDoc, rootNode);
  79. }
  80. else
  81. {
  82. slo.Serialize(false, classDoc, rootNode);
  83. m_nPosition = xnPosition.value();
  84. m_nHeight = xnHeight.value();
  85. }
  86. }
  87. // protected
  88. // cleanup
  89. void COTSPeak::Cleanup()
  90. {
  91. // nothing needs to be done at the moment
  92. }
  93. // initialization
  94. void COTSPeak::Init()
  95. {
  96. m_nPosition = 0;
  97. m_nHeight = 0;
  98. m_oRange = CIntRange();
  99. }
  100. // duplication
  101. void COTSPeak::Duplicate(const COTSPeak& a_oSource)
  102. {
  103. // initialization
  104. Init();
  105. // copy data over
  106. m_nPosition = a_oSource.m_nPosition;
  107. m_nHeight = a_oSource.m_nHeight;
  108. m_oRange = a_oSource.m_oRange;
  109. }
  110. }