| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- #include "stdafx.h"
- #include "ReportProjFile.h"
- namespace OTSMODEL {
- // CReportProjFile
-
- // constructor
- CReportProjFile::CReportProjFile()
- {
- // initialization
- Init();
- }
- // copy constructor
- CReportProjFile::CReportProjFile(const CReportProjFile& a_oSource)
- {
- // can't copy itself
- if (&a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- // copy constructor
- CReportProjFile::CReportProjFile(CReportProjFile* 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
- CReportProjFile& CReportProjFile::operator=(const CReportProjFile& a_oSource)
- {
- // cleanup
- Cleanup();
- // copy the class data over
- Duplicate(a_oSource);
- // return class
- return *this;
- }
- // destructor
- CReportProjFile::~CReportProjFile()
- {
- // cleanup
- Cleanup();
- }
- // ==operator
- BOOL CReportProjFile::operator==(const CReportProjFile& a_oSource)
- {
- std::vector<CString> listSmplMsrResultFilePathNames = a_oSource.m_listSmplMsrResultFilePathNames;
- if ((int)listSmplMsrResultFilePathNames.size() != (int)m_listSmplMsrResultFilePathNames.size())
- {
- return FALSE;
- }
- for(int i= 0; i< (int)listSmplMsrResultFilePathNames.size(); i++)
- {
- CString strName = listSmplMsrResultFilePathNames[i];
- if (strName.Compare(m_listSmplMsrResultFilePathNames[i]) != 0)
- {
- return FALSE;
- }
- }
- return m_strVersion.Compare(a_oSource.m_strVersion) == 0 &&
- *(m_pPartSTDData.get()) == *(a_oSource.m_pPartSTDData.get()) &&
- *(m_pTriTemp.get()) == *(a_oSource.m_pTriTemp.get()) &&
- (m_dScale == a_oSource.m_dScale );
- }
- // CReportProjFile member functions
- // public
- // serialization
-
- void CReportProjFile::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
- {
- xmls::xInt xnFileMark;
- xmls::xString xstrVersion;
- xmls::xString xstrSizeFileFolder;
- xmls::xDouble xdScale;
- xmls::Slo slo;
- //xmls::Collection
- xmls::xString xstrAddresses;
- slo.Register("FileMark", &xnFileMark);
- slo.Register("Version", &xstrVersion);
- slo.Register("SizeFileFolder", &xstrSizeFileFolder);
- slo.Register("Scale", &xdScale);
- slo.Register("PartSTDData", m_pPartSTDData.get());
- //slo.Register("PartSize", m_pPartSize.get());
- slo.Register("TriTemp", m_pTriTemp.get());
- slo.Register("Addresses", &xstrAddresses);
- if (isStoring)
- {
- xnFileMark = REPORT_PROJRCT_FILE_MARK;
- xstrVersion = m_strVersion;
- //xstrSizeFileFolder = m_strSizeFileFolder;
- xdScale = m_dScale;
- CString strAddresses = "";
- for (int i = 0; i < m_listSmplMsrResultFilePathNames.size()-1; i++)
- {
- strAddresses = strAddresses + m_listSmplMsrResultFilePathNames[i] + ";";
- }
- if (m_listSmplMsrResultFilePathNames.size() > 0)
- {
- strAddresses = strAddresses + m_listSmplMsrResultFilePathNames[m_listSmplMsrResultFilePathNames.size()-1];
- }
- xstrAddresses = strAddresses;
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- // REPORT_PROJRCT_FILE_MARK = xnFileMark.value();
- m_strVersion = xstrVersion.value().c_str();
- //m_strSizeFileFolder = xstrSizeFileFolder.value().c_str();
- m_dScale = xdScale.value();
- CString strAddresses = xstrAddresses.value().c_str();
- m_listSmplMsrResultFilePathNames.clear();
- int pos = 0;
- int pre_pos = 0;
- while (-1 != pos) {
- pre_pos = pos;
- pos = strAddresses.Find(_T(";"), (pos + 1));
- m_listSmplMsrResultFilePathNames.push_back(strAddresses.Mid(pre_pos, (pos - pre_pos)));
- }
- }
- }
- void CReportProjFile::SetPartSTDData(CPartSTDDataPtr a_pPartSTDData)
- {
- ASSERT(a_pPartSTDData);
- if (!a_pPartSTDData)
- {
- return;
- }
- //m_pPartSTDData = CPartSTDDataPtr(new CPartSTDData(*a_pPartSTDData.get()));
- m_pPartSTDData = a_pPartSTDData;
- }
- // triangle template file
- void CReportProjFile::SetTriTemp(CTriTempFilePtr a_pTriTemp)
- {
- ASSERT(a_pTriTemp);
- if (!a_pTriTemp)
- {
- return;
- }
- m_pTriTemp = a_pTriTemp;
- }
- // sample measure result file pathname strings
- void CReportProjFile::SetSmplMsrResultFilePathNames(std::vector<CString> a_listSmplMsrResultFilePathNames)
- {
- m_listSmplMsrResultFilePathNames.clear();
- for (auto strName : a_listSmplMsrResultFilePathNames)
- {
- m_listSmplMsrResultFilePathNames.push_back(strName);
- }
- }
- // cleanup
- void CReportProjFile::Cleanup()
- {
- // need to do nothing at the moment
- m_listSmplMsrResultFilePathNames.clear();
- }
- // initialization
- void CReportProjFile::Init()
- {
- m_strVersion = _T("");
- m_pPartSTDData = CPartSTDDataPtr(new CPartSTDData());
- /*m_pPartSize = CPartSizeFilePtr(new CPartSizeFile());
- m_strSizeFileFolder = _T(""); */
- m_pTriTemp = CTriTempFilePtr(new CTriTempFile());
- m_listSmplMsrResultFilePathNames.clear();
- m_dScale = 1.0;
- }
- // duplication
- void CReportProjFile::Duplicate(const CReportProjFile& a_oSource)
- {
- // initialization
- Init();
- m_listSmplMsrResultFilePathNames.clear();
- // copy data over
- m_strVersion = a_oSource.m_strVersion;
- m_pPartSTDData = CPartSTDDataPtr(new CPartSTDData(*a_oSource.m_pPartSTDData.get()));
- /*m_pPartSize = CPartSizeFilePtr(new CPartSizeFile(*a_oSource.m_pPartSize.get()));
- m_strSizeFileFolder = a_oSource.m_strSizeFileFolder;*/
- m_pTriTemp = CTriTempFilePtr(new CTriTempFile(*a_oSource.m_pTriTemp.get()));
- m_dScale = 1.0;
- for (auto strPathName : a_oSource.m_listSmplMsrResultFilePathNames)
- {
- m_listSmplMsrResultFilePathNames.push_back(strPathName);
- }
- }
- }
|