123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- namespace OTSDataType
- {
- public class CSampleHolder : ISlo
- {
- // stage name
- String m_strName;
- // boundary
- CDomain m_poBourary;
- // std
- CDomain m_poSTD;
- // sample holes list
- List<CHole> m_listHoles;
- // constructor
- public CSampleHolder()
- {
- // initialization
- Init();
- }
- // initialization
- public void Init()
- {
- // initialization
- m_strName = "";
- m_poBourary = new CDomain();
- m_poSTD = new CDomain();
- m_listHoles = new List<CHole>();
- }
- public CSampleHolder(CSampleHolder a_poSource)
- {
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
- Duplicate(a_poSource);
- }
- public bool Equals(CSampleHolder a_oSource) // CBSEImg& operator=(const CBSEImg&); // =operator
- {
- // return FASLE, if the two holes list are in different size
- int nSize = m_listHoles.Count;
- if (nSize != a_oSource.m_listHoles.Count)
- {
- return false;
- }
- // return FALSE if any of the pare holes are different
- for (int i = 0; i < nSize; ++i)
- {
- if (m_listHoles[i] != a_oSource.m_listHoles[i])
- {
- return false;
- }
- }
- // members check
- return m_strName == a_oSource.m_strName &&
- m_poBourary == a_oSource.m_poBourary &&
- m_poSTD == a_oSource.m_poSTD;
- }
- // stage name
- public String GetName()
- {
- return m_strName;
- }
- //public int GetBourary() { return 0; }
- public void SetName(String a_strName)
- {
- m_strName = a_strName;
- }
- // boundary
- public CDomain GetBoundary()
- {
- return m_poBourary;
- }
- // boundary
- public void SetBoundary(CDomain a_poBourary)
- {
- m_poBourary = a_poBourary;
- }
- // std
- public CDomain GetSTD()
- {
- return m_poSTD;
- }
- // std
- public void SetSTD(CDomain a_poSTD)
- {
- m_poSTD = new CDomain(a_poSTD);
- }
- // sample holes list
- public List<CHole> GetHoleList()
- {
- return m_listHoles;
- }
- // holes list
- public void SetHoleList(List<CHole> a_listHoles, bool a_bClear /* = TRUE*/)
- {
- // clear holes list if necessary
- if (a_bClear)
- {
- m_listHoles.Clear();
- }
- // copy the list
- foreach (var pHole in a_listHoles)
- {
- CHole pHoleNew = new CHole(pHole);
- m_listHoles.Add(pHoleNew);
- }
- }
- // sample holes list
- public CHole GetHoleByIndex(int a_nIndex)
- {
- if (a_nIndex < 0 || a_nIndex >= (int)m_listHoles.Count)
- {
- // invalid index
- return null;
- }
- return m_listHoles[a_nIndex];
- }
- public CHole GetHoleByName(String a_strHoleName)
- {
- a_strHoleName.Trim();
- if (a_strHoleName == "")
- {
- // invalid hole name
- return null;
- }
- CHole p = new CHole();
- for (int i = 0; i < m_listHoles.Count; i++)
- {
- if (m_listHoles[i].GetName() == a_strHoleName)
- {
- p = m_listHoles[i];
- break;
- }
- }
- return p;
- }
- // duplication
- void Duplicate(CSampleHolder a_oSource)
- {
- Init();
- // copy data over
- m_strName = a_oSource.m_strName;
- m_poBourary = new CDomain(a_oSource.m_poBourary);
- m_poSTD = new CDomain(a_oSource.m_poSTD);
- foreach (var pHole in a_oSource.m_listHoles)
- {
- CHole pHoleNew = new CHole(pHole);
- m_listHoles.Add(pHoleNew);
- }
- }
- public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
- xString xnstrName = new xString();
- Collection<CHole> xHolelist = new Collection<CHole>();
- CDomain x_poBourary = new CDomain();
- CDomain x_poSTD = new CDomain();
- Slo slo = new Slo();
- slo.Register("strName", xnstrName);
- slo.Register("boundary", x_poBourary);
- slo.Register("std", x_poSTD);
- slo.Register("Holes", xHolelist);
- if (isStoring)
- {
- xnstrName.AssignValue(m_strName);
- x_poBourary.SetPolygonPoint(m_poBourary.GetPolygonPoint());
- x_poBourary.SetRectDomain(m_poBourary.GetDomainRect());
- x_poBourary.SetShape(m_poBourary.GetShape());
- x_poSTD.SetPolygonPoint(m_poSTD.GetPolygonPoint());
- x_poSTD.SetRectDomain(m_poSTD.GetDomainRect());
- x_poSTD.SetShape(m_poSTD.GetShape());
- xHolelist.Clear();
- for (int i = 0; i < m_listHoles.Count; i++)
- {
- xHolelist.addItem(m_listHoles[i]);
- }
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- m_strName = xnstrName.value();
- m_poBourary = x_poBourary;
- m_poSTD = x_poSTD;
- m_listHoles.Clear();
- for (int i = 0; i < xHolelist.size(); i++)
- {
- m_listHoles.Add(xHolelist.getItem(i));
- }
- }
- }
- }
- }
|