123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #include "stdafx.h"
- #include "Hole.h"
- namespace OTSDATA {
- //// CHole
- //IMPLEMENT_SERIAL(CHole, CDomain, 1)
- // constructor
- CHole::CHole()
- {
- // initialization
- Init();
- }
- CHole::CHole(CString a_strName, DOMAIN_SHAPE a_nShape, CRect a_rectDomain)
- {
- // initialization
- Init();
- // assign class members
- m_strName = a_strName;
- m_nShape = a_nShape;
- m_rectDomain = a_rectDomain;
- }
- // copy constructor
- CHole::CHole(const CHole& a_oSource)
- {
- // can't copy itself
- if (&a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- // copy constructor
- CHole::CHole(CHole* a_poSource)
- {
- // input check
- ASSERT(a_poSource);
- if (!a_poSource)
- {
- return;
- }
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(*a_poSource);
- }
- // =operator
- CHole& CHole::operator=(const CHole& a_oSource)
- {
- // cleanup
- Cleanup();
- // copy the class data over
- Duplicate(a_oSource);
- // return class
- return *this;
- }
- // ==operator
- BOOL CHole::operator==(const CHole& a_oSource)
- {
- return m_strName.Compare(a_oSource.m_strName) == 0 && m_nShape == a_oSource.m_nShape && m_rectDomain == a_oSource.m_rectDomain;
- }
- // destructor
- CHole::~CHole()
- {
- // cleanup
- Cleanup();
-
- }
- // CDomain functions
- // public
- // serialization
- //void CHole::Serialize(CArchive& ar)
- //{
- // // store?
- // if (ar.IsStoring())
- // {
- // // store
- // ar << m_strName;
- // }
- // else
- // {
- // // load
- // ar >> m_strName;
- // }
- // // base object serialization
- // CDomain::Serialize(ar);
- //}
- void CHole::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
- {
- xmls::xString xnstrName;
- xmls::Slo slo;
- slo.Register("HoleName", &xnstrName);
- if (isStoring)
- {
- xnstrName = m_strName;
- slo.Serialize(true, classDoc, rootNode);
- CDomain::Serialize(true, classDoc, rootNode);
- }
- else
- {
- CDomain::Serialize(false, classDoc, rootNode);
- slo.Serialize(false, classDoc, rootNode);
- //We only need to care about the field data property.
- //All the inherited property and all the member objects and collections needn't to handle here just like the CObject.
- //Because we have registered the object to the slo's vector,but we didn't register the field property to the vector directly.
- //We register the x**** property insdead.
- //* We may make the mistake that handle all the property here or part of the inherited propery here.then we get the queer effect.
- m_strName = xnstrName.value().c_str();
- }
- }
- // cleanup
- void CHole::Cleanup()
- {
- // base class cleanup
- CDomain::Cleanup();
- }
- // initialization
- void CHole::Init()
- {
- // base class initialization
- CDomain::Init();
- // initialization
- m_strName = _T("");
- }
- // duplication
- void CHole::Duplicate(const CHole& a_oSource)
- {
- // initialization
- Init();
- // base class duplication
- CDomain::Duplicate(a_oSource);
- // copy data over
- m_strName = a_oSource.m_strName;
- }
- }
|