Hole.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #include "stdafx.h"
  2. #include "Hole.h"
  3. namespace OTSDATA {
  4. //// CHole
  5. //IMPLEMENT_SERIAL(CHole, CDomain, 1)
  6. // constructor
  7. CHole::CHole()
  8. {
  9. // initialization
  10. Init();
  11. }
  12. CHole::CHole(CString a_strName, DOMAIN_SHAPE a_nShape, CRect a_rectDomain)
  13. {
  14. // initialization
  15. Init();
  16. // assign class members
  17. m_strName = a_strName;
  18. m_nShape = a_nShape;
  19. m_rectDomain = a_rectDomain;
  20. }
  21. // copy constructor
  22. CHole::CHole(const CHole& a_oSource)
  23. {
  24. // can't copy itself
  25. if (&a_oSource == this)
  26. {
  27. return;
  28. }
  29. // copy data over
  30. Duplicate(a_oSource);
  31. }
  32. // copy constructor
  33. CHole::CHole(CHole* a_poSource)
  34. {
  35. // input check
  36. ASSERT(a_poSource);
  37. if (!a_poSource)
  38. {
  39. return;
  40. }
  41. // can't copy itself
  42. if (a_poSource == this)
  43. {
  44. return;
  45. }
  46. // copy data over
  47. Duplicate(*a_poSource);
  48. }
  49. // =operator
  50. CHole& CHole::operator=(const CHole& a_oSource)
  51. {
  52. // cleanup
  53. Cleanup();
  54. // copy the class data over
  55. Duplicate(a_oSource);
  56. // return class
  57. return *this;
  58. }
  59. // ==operator
  60. BOOL CHole::operator==(const CHole& a_oSource)
  61. {
  62. return m_strName.Compare(a_oSource.m_strName) == 0 && m_nShape == a_oSource.m_nShape && m_rectDomain == a_oSource.m_rectDomain;
  63. }
  64. // destructor
  65. CHole::~CHole()
  66. {
  67. // cleanup
  68. Cleanup();
  69. }
  70. // CDomain functions
  71. // public
  72. // serialization
  73. //void CHole::Serialize(CArchive& ar)
  74. //{
  75. // // store?
  76. // if (ar.IsStoring())
  77. // {
  78. // // store
  79. // ar << m_strName;
  80. // }
  81. // else
  82. // {
  83. // // load
  84. // ar >> m_strName;
  85. // }
  86. // // base object serialization
  87. // CDomain::Serialize(ar);
  88. //}
  89. void CHole::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  90. {
  91. xmls::xString xnstrName;
  92. xmls::Slo slo;
  93. slo.Register("HoleName", &xnstrName);
  94. if (isStoring)
  95. {
  96. xnstrName = m_strName;
  97. slo.Serialize(true, classDoc, rootNode);
  98. CDomain::Serialize(true, classDoc, rootNode);
  99. }
  100. else
  101. {
  102. CDomain::Serialize(false, classDoc, rootNode);
  103. slo.Serialize(false, classDoc, rootNode);
  104. //We only need to care about the field data property.
  105. //All the inherited property and all the member objects and collections needn't to handle here just like the CObject.
  106. //Because we have registered the object to the slo's vector,but we didn't register the field property to the vector directly.
  107. //We register the x**** property insdead.
  108. //* We may make the mistake that handle all the property here or part of the inherited propery here.then we get the queer effect.
  109. m_strName = xnstrName.value().c_str();
  110. }
  111. }
  112. // cleanup
  113. void CHole::Cleanup()
  114. {
  115. // base class cleanup
  116. CDomain::Cleanup();
  117. }
  118. // initialization
  119. void CHole::Init()
  120. {
  121. // base class initialization
  122. CDomain::Init();
  123. // initialization
  124. m_strName = _T("");
  125. }
  126. // duplication
  127. void CHole::Duplicate(const CHole& a_oSource)
  128. {
  129. // initialization
  130. Init();
  131. // base class duplication
  132. CDomain::Duplicate(a_oSource);
  133. // copy data over
  134. m_strName = a_oSource.m_strName;
  135. }
  136. }