CElementRange.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace OTSDataType
  7. {
  8. // CElementRange command target
  9. public class CElementRange
  10. {
  11. // element
  12. protected CElement m_poElement = new CElement();
  13. // % x 100 range
  14. protected CIntRange m_poRange = new CIntRange();
  15. public CElementRange()
  16. {
  17. // initialization
  18. Init();
  19. }
  20. public CElementRange(CElementRange a_oSource) // copy constructor
  21. {
  22. // input check
  23. //ASSERT(a_oSource);
  24. if (a_oSource==null)
  25. {
  26. return;
  27. }
  28. // can't copy itself
  29. if (a_oSource == this)
  30. {
  31. return;
  32. }
  33. // copy data over
  34. Duplicate(a_oSource);
  35. }
  36. // ==operator
  37. public bool Equals(CElementRange a_oSource)
  38. {
  39. return m_poElement.Equals(a_oSource.m_poElement)&& m_poRange.Equals(a_oSource.m_poRange);
  40. }
  41. //无实际操作 virtual ~CElementRange(); // destructor
  42. // serialization
  43. //void Serialize(CArchive& ar);
  44. //void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  45. // element
  46. public CElement GetElement()
  47. {
  48. return m_poElement;
  49. }
  50. // element
  51. public void SetElement(CElement a_poElement)
  52. {
  53. //Debug.Assert(a_poElement);
  54. if (a_poElement == null)
  55. {
  56. m_poElement = new CElement();
  57. }
  58. else
  59. {
  60. m_poElement=new CElement(a_poElement);
  61. }
  62. }
  63. // % x 100 range
  64. public CIntRange GetRange()
  65. {
  66. return m_poRange;
  67. }
  68. public void SetRange(CIntRange a_poRange)
  69. {
  70. //Debug.Assert(a_poRange);
  71. if (a_poRange == null)
  72. {
  73. m_poRange = new CIntRange();
  74. }
  75. else
  76. {
  77. m_poRange = new CIntRange(a_poRange);
  78. }
  79. }
  80. // cleanup
  81. //protected void Cleanup()
  82. //{
  83. // // need to do nothing at the moment
  84. //}
  85. // initialization
  86. protected void Init()
  87. {
  88. // initialization
  89. m_poElement = new CElement();
  90. m_poRange = new CIntRange();
  91. }
  92. // duplication
  93. protected void Duplicate(CElementRange a_oSource)
  94. {
  95. m_poElement = new CElement(a_oSource.m_poElement);
  96. m_poRange = new CIntRange(a_oSource.m_poRange);
  97. }
  98. }
  99. }