#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; } }