ReportProjFile.cpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. #include "stdafx.h"
  2. #include "ReportProjFile.h"
  3. namespace OTSMODEL {
  4. // CReportProjFile
  5. // constructor
  6. CReportProjFile::CReportProjFile()
  7. {
  8. // initialization
  9. Init();
  10. }
  11. // copy constructor
  12. CReportProjFile::CReportProjFile(const CReportProjFile& a_oSource)
  13. {
  14. // can't copy itself
  15. if (&a_oSource == this)
  16. {
  17. return;
  18. }
  19. // copy data over
  20. Duplicate(a_oSource);
  21. }
  22. // copy constructor
  23. CReportProjFile::CReportProjFile(CReportProjFile* a_poSource)
  24. {
  25. // input check
  26. ASSERT(a_poSource);
  27. if (!a_poSource)
  28. {
  29. return;
  30. }
  31. // can't copy itself
  32. if (a_poSource == this)
  33. {
  34. return;
  35. }
  36. // copy data over
  37. Duplicate(*a_poSource);
  38. }
  39. // =operator
  40. CReportProjFile& CReportProjFile::operator=(const CReportProjFile& a_oSource)
  41. {
  42. // cleanup
  43. Cleanup();
  44. // copy the class data over
  45. Duplicate(a_oSource);
  46. // return class
  47. return *this;
  48. }
  49. // destructor
  50. CReportProjFile::~CReportProjFile()
  51. {
  52. // cleanup
  53. Cleanup();
  54. }
  55. // ==operator
  56. BOOL CReportProjFile::operator==(const CReportProjFile& a_oSource)
  57. {
  58. std::vector<CString> listSmplMsrResultFilePathNames = a_oSource.m_listSmplMsrResultFilePathNames;
  59. if ((int)listSmplMsrResultFilePathNames.size() != (int)m_listSmplMsrResultFilePathNames.size())
  60. {
  61. return FALSE;
  62. }
  63. for(int i= 0; i< (int)listSmplMsrResultFilePathNames.size(); i++)
  64. {
  65. CString strName = listSmplMsrResultFilePathNames[i];
  66. if (strName.Compare(m_listSmplMsrResultFilePathNames[i]) != 0)
  67. {
  68. return FALSE;
  69. }
  70. }
  71. return m_strVersion.Compare(a_oSource.m_strVersion) == 0 &&
  72. *(m_pPartSTDData.get()) == *(a_oSource.m_pPartSTDData.get()) &&
  73. *(m_pTriTemp.get()) == *(a_oSource.m_pTriTemp.get()) &&
  74. (m_dScale == a_oSource.m_dScale );
  75. }
  76. // CReportProjFile member functions
  77. // public
  78. // serialization
  79. void CReportProjFile::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  80. {
  81. xmls::xInt xnFileMark;
  82. xmls::xString xstrVersion;
  83. xmls::xString xstrSizeFileFolder;
  84. xmls::xDouble xdScale;
  85. xmls::Slo slo;
  86. //xmls::Collection
  87. xmls::xString xstrAddresses;
  88. slo.Register("FileMark", &xnFileMark);
  89. slo.Register("Version", &xstrVersion);
  90. slo.Register("SizeFileFolder", &xstrSizeFileFolder);
  91. slo.Register("Scale", &xdScale);
  92. slo.Register("PartSTDData", m_pPartSTDData.get());
  93. //slo.Register("PartSize", m_pPartSize.get());
  94. slo.Register("TriTemp", m_pTriTemp.get());
  95. slo.Register("Addresses", &xstrAddresses);
  96. if (isStoring)
  97. {
  98. xnFileMark = REPORT_PROJRCT_FILE_MARK;
  99. xstrVersion = m_strVersion;
  100. //xstrSizeFileFolder = m_strSizeFileFolder;
  101. xdScale = m_dScale;
  102. CString strAddresses = "";
  103. for (int i = 0; i < m_listSmplMsrResultFilePathNames.size()-1; i++)
  104. {
  105. strAddresses = strAddresses + m_listSmplMsrResultFilePathNames[i] + ";";
  106. }
  107. if (m_listSmplMsrResultFilePathNames.size() > 0)
  108. {
  109. strAddresses = strAddresses + m_listSmplMsrResultFilePathNames[m_listSmplMsrResultFilePathNames.size()-1];
  110. }
  111. xstrAddresses = strAddresses;
  112. slo.Serialize(true, classDoc, rootNode);
  113. }
  114. else
  115. {
  116. slo.Serialize(false, classDoc, rootNode);
  117. // REPORT_PROJRCT_FILE_MARK = xnFileMark.value();
  118. m_strVersion = xstrVersion.value().c_str();
  119. //m_strSizeFileFolder = xstrSizeFileFolder.value().c_str();
  120. m_dScale = xdScale.value();
  121. CString strAddresses = xstrAddresses.value().c_str();
  122. m_listSmplMsrResultFilePathNames.clear();
  123. int pos = 0;
  124. int pre_pos = 0;
  125. while (-1 != pos) {
  126. pre_pos = pos;
  127. pos = strAddresses.Find(_T(";"), (pos + 1));
  128. m_listSmplMsrResultFilePathNames.push_back(strAddresses.Mid(pre_pos, (pos - pre_pos)));
  129. }
  130. }
  131. }
  132. void CReportProjFile::SetPartSTDData(CPartSTDDataPtr a_pPartSTDData)
  133. {
  134. ASSERT(a_pPartSTDData);
  135. if (!a_pPartSTDData)
  136. {
  137. return;
  138. }
  139. //m_pPartSTDData = CPartSTDDataPtr(new CPartSTDData(*a_pPartSTDData.get()));
  140. m_pPartSTDData = a_pPartSTDData;
  141. }
  142. // triangle template file
  143. void CReportProjFile::SetTriTemp(CTriTempFilePtr a_pTriTemp)
  144. {
  145. ASSERT(a_pTriTemp);
  146. if (!a_pTriTemp)
  147. {
  148. return;
  149. }
  150. m_pTriTemp = a_pTriTemp;
  151. }
  152. // sample measure result file pathname strings
  153. void CReportProjFile::SetSmplMsrResultFilePathNames(std::vector<CString> a_listSmplMsrResultFilePathNames)
  154. {
  155. m_listSmplMsrResultFilePathNames.clear();
  156. for (auto strName : a_listSmplMsrResultFilePathNames)
  157. {
  158. m_listSmplMsrResultFilePathNames.push_back(strName);
  159. }
  160. }
  161. // cleanup
  162. void CReportProjFile::Cleanup()
  163. {
  164. // need to do nothing at the moment
  165. m_listSmplMsrResultFilePathNames.clear();
  166. }
  167. // initialization
  168. void CReportProjFile::Init()
  169. {
  170. m_strVersion = _T("");
  171. m_pPartSTDData = CPartSTDDataPtr(new CPartSTDData());
  172. /*m_pPartSize = CPartSizeFilePtr(new CPartSizeFile());
  173. m_strSizeFileFolder = _T(""); */
  174. m_pTriTemp = CTriTempFilePtr(new CTriTempFile());
  175. m_listSmplMsrResultFilePathNames.clear();
  176. m_dScale = 1.0;
  177. }
  178. // duplication
  179. void CReportProjFile::Duplicate(const CReportProjFile& a_oSource)
  180. {
  181. // initialization
  182. Init();
  183. m_listSmplMsrResultFilePathNames.clear();
  184. // copy data over
  185. m_strVersion = a_oSource.m_strVersion;
  186. m_pPartSTDData = CPartSTDDataPtr(new CPartSTDData(*a_oSource.m_pPartSTDData.get()));
  187. /*m_pPartSize = CPartSizeFilePtr(new CPartSizeFile(*a_oSource.m_pPartSize.get()));
  188. m_strSizeFileFolder = a_oSource.m_strSizeFileFolder;*/
  189. m_pTriTemp = CTriTempFilePtr(new CTriTempFile(*a_oSource.m_pTriTemp.get()));
  190. m_dScale = 1.0;
  191. for (auto strPathName : a_oSource.m_listSmplMsrResultFilePathNames)
  192. {
  193. m_listSmplMsrResultFilePathNames.push_back(strPathName);
  194. }
  195. }
  196. }