CElementRange.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. // element
  42. public CElement GetElement()
  43. {
  44. return m_poElement;
  45. }
  46. // element
  47. public void SetElement(CElement a_poElement)
  48. {
  49. //Debug.Assert(a_poElement);
  50. if (a_poElement == null)
  51. {
  52. m_poElement = new CElement();
  53. }
  54. else
  55. {
  56. m_poElement=new CElement(a_poElement);
  57. }
  58. }
  59. // % x 100 range
  60. public CIntRange GetRange()
  61. {
  62. return m_poRange;
  63. }
  64. public void SetRange(CIntRange a_poRange)
  65. {
  66. //Debug.Assert(a_poRange);
  67. if (a_poRange == null)
  68. {
  69. m_poRange = new CIntRange();
  70. }
  71. else
  72. {
  73. m_poRange = new CIntRange(a_poRange);
  74. }
  75. }
  76. // initialization
  77. protected void Init()
  78. {
  79. // initialization
  80. m_poElement = new CElement();
  81. m_poRange = new CIntRange();
  82. }
  83. // duplication
  84. protected void Duplicate(CElementRange a_oSource)
  85. {
  86. m_poElement = new CElement(a_oSource.m_poElement);
  87. m_poRange = new CIntRange(a_oSource.m_poRange);
  88. }
  89. }
  90. }