// ElementRange.cpp : implementation file // #include "stdafx.h" //#include "OTSData.h" #include "ElementRange.h" namespace OTSDATA { // CElementRange // constructor CElementRange::CElementRange() { // initialization Init(); } // copy constructor CElementRange::CElementRange(const CElementRange& a_oSource) { // can't copy itself if (&a_oSource == this) { return; } // copy data over Duplicate(a_oSource); } // copy constructor CElementRange::CElementRange(CElementRange* 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 CElementRange& CElementRange::operator=(const CElementRange& a_oSource) { // cleanup Cleanup(); // copy the class data over Duplicate(a_oSource); // return class return *this; } // ==operator BOOL CElementRange::operator==(const CElementRange& a_oSource) { return *(m_poElement.get()) == *(a_oSource.m_poElement.get()) && *(m_poRange.get()) == *(a_oSource.m_poRange.get()); } // destructor CElementRange::~CElementRange() { // cleanup Cleanup(); } // CElementRange member functions // public // serialization void CElementRange::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode) { xmls::Slo slo; slo.Register("Element", m_poElement.get()); slo.Register("Range", m_poRange.get()); if (isStoring) { slo.Serialize(true, classDoc, rootNode); } else { slo.Serialize(false, classDoc, rootNode); } } // element void CElementRange::SetElement(CElementPtr a_poElement) { ASSERT(a_poElement); if(!a_poElement) { m_poElement = CElementPtr(new CElement()); } else { m_poElement = a_poElement; } } // % x 100 range void CElementRange::SetRange(CIntRangePtr a_poRange) { ASSERT(a_poRange); if(!a_poRange) { m_poRange = CIntRangePtr(new CIntRange()); } else { m_poRange = a_poRange; } } // protected // cleanup void CElementRange::Cleanup() { // need to do nothing at the moment } // initialization void CElementRange::Init() { // initialization m_poElement = CElementPtr(new CElement()); m_poRange = CIntRangePtr(new CIntRange()); } // duplication void CElementRange::Duplicate(const CElementRange& a_oSource) { // initialization Init(); // copy data over m_poElement = CElementPtr(a_oSource.m_poElement); m_poRange = CIntRangePtr(a_oSource.m_poRange); } }