SEMDataGnr.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // SEMDataGnr.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. //#include "OTSData.h"
  5. #include "SEMDataGnr.h"
  6. namespace OTSDATA {
  7. // CSEMDataGnr
  8. // constructor
  9. CSEMDataGnr::CSEMDataGnr()
  10. {
  11. // initialization
  12. Init();
  13. }
  14. // copy constructor
  15. CSEMDataGnr::CSEMDataGnr(const CSEMDataGnr& a_oSource)
  16. {
  17. // can't copy itself
  18. if (&a_oSource == this)
  19. {
  20. return;
  21. }
  22. // copy data over
  23. Duplicate(a_oSource);
  24. }
  25. // copy constructor
  26. CSEMDataGnr::CSEMDataGnr(CSEMDataGnr* a_poSource)
  27. {
  28. // can't copy itself
  29. if (a_poSource == this)
  30. {
  31. return;
  32. }
  33. // copy data over
  34. Duplicate(*a_poSource);
  35. }
  36. // =operator
  37. CSEMDataGnr& CSEMDataGnr::operator=(const CSEMDataGnr& a_oSource)
  38. {
  39. // cleanup
  40. Cleanup();
  41. // copy the class data over
  42. Duplicate(a_oSource);
  43. // return class
  44. return *this;
  45. }
  46. // destructor
  47. CSEMDataGnr::~CSEMDataGnr()
  48. {
  49. // cleanup
  50. Cleanup();
  51. }
  52. // ==operator
  53. BOOL CSEMDataGnr::operator==(const CSEMDataGnr& a_oSource)
  54. {
  55. return abs(m_dKV - a_oSource.m_dKV) < MIN_DOUBLE_VALUE &&
  56. abs(m_dBrightness - a_oSource.m_dBrightness) < MIN_DOUBLE_VALUE &&
  57. abs(m_dContrast - a_oSource.m_dContrast) < MIN_DOUBLE_VALUE;
  58. }
  59. // CSEMDataMsr member functions
  60. // public
  61. // serialization
  62. void CSEMDataGnr::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  63. {
  64. xmls::xDouble xdKV;
  65. xmls::xDouble xdBrightness;
  66. xmls::xDouble xdConstrast;
  67. xmls::Slo slo;
  68. slo.Register("KV", &xdKV);
  69. slo.Register("Brightness", &xdBrightness);
  70. slo.Register("Constrast", &xdConstrast);
  71. if (isStoring)
  72. {
  73. xdKV = m_dKV;
  74. xdBrightness = m_dBrightness;
  75. xdConstrast = m_dContrast;
  76. slo.Serialize(true, classDoc, rootNode);
  77. }
  78. else
  79. {
  80. slo.Serialize(false, classDoc, rootNode);
  81. m_dKV = xdKV.value();
  82. m_dBrightness = xdBrightness.value();
  83. m_dContrast = xdConstrast.value();
  84. }
  85. }
  86. // protected
  87. // cleanup
  88. void CSEMDataGnr::Cleanup()
  89. {
  90. // need to do nothing at the moment
  91. }
  92. // initialization
  93. void CSEMDataGnr::Init()
  94. {
  95. m_dKV = MIN_DOUBLE_VALUE;
  96. m_dBrightness = MIN_DOUBLE_VALUE;
  97. m_dContrast = MIN_DOUBLE_VALUE;
  98. }
  99. // duplication
  100. void CSEMDataGnr::Duplicate(const CSEMDataGnr& a_oSource)
  101. {
  102. // initialization
  103. Init();
  104. // copy data over
  105. m_dKV = a_oSource.m_dKV;
  106. m_dBrightness = a_oSource.m_dBrightness;
  107. m_dContrast = a_oSource.m_dContrast;
  108. }
  109. }