MaxEDSRule.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "MaxEDSRule.h"
  4. #include "XMLSerialization.h"
  5. #include "OTSFileSys.h"
  6. #include "Element.h"
  7. using namespace OTSTools;
  8. using namespace OTSDATA;
  9. using namespace xmls;
  10. void MaxEDSRule::Serialize(bool isStoring, tinyxml2::XMLDocument* classDoc, tinyxml2::XMLElement* rootNode)
  11. {
  12. xmls::xString xElementListStr;
  13. xmls::xString xUsingConstants;
  14. xmls::xString xImgPropertyListStr;
  15. xmls::xString xOtherPropertyListStr;
  16. xmls::xString xExpstr;
  17. xmls::xDouble xEdsTime;
  18. xmls::Slo slo;
  19. slo.Register("EDSTime", &xEdsTime);
  20. slo.Register("UsingElementList", &xElementListStr);
  21. slo.Register("UsingConstants", &xUsingConstants);
  22. slo.Register("UsingImgPropertyList", &xImgPropertyListStr);
  23. slo.Register("UsingOtherPropertyList", &xOtherPropertyListStr);
  24. slo.Register("Expression", &xExpstr);
  25. if (isStoring)
  26. {
  27. xEdsTime = m_MaxEDSTime;
  28. CString s = "";
  29. for (auto poElement : m_elementList)
  30. {
  31. s += poElement->GetName() + ",";
  32. }
  33. s = s.TrimRight(",");
  34. xElementListStr = s;
  35. for (auto pName : m_ImgPropertyList)
  36. {
  37. s += pName.c_str();
  38. s += ",";
  39. }
  40. s = s.TrimRight(",");
  41. xImgPropertyListStr = s;
  42. for (auto pName : m_OtherpropertyList)
  43. {
  44. s += pName.c_str();
  45. s += ",";
  46. }
  47. s = s.TrimRight(",");
  48. xOtherPropertyListStr = s;
  49. slo.Serialize(true, classDoc, rootNode);
  50. }
  51. else
  52. {
  53. slo.Serialize(false, classDoc, rootNode);
  54. m_expressionStr = xExpstr.value();
  55. m_MaxEDSTime = xEdsTime.value();
  56. std::vector<string> eles;
  57. std::string elements = xElementListStr.c_str();
  58. xmls::SplitString(elements, eles, ",");
  59. for (int i = 0; i < eles.size(); ++i)
  60. {
  61. CString ss = eles[i].c_str();
  62. m_elementList.push_back(CElementPtr(new CElement(ss)));
  63. }
  64. std::string propertynames = xImgPropertyListStr.value();
  65. xmls::SplitString(propertynames, m_ImgPropertyList, ",");
  66. std::string otherPropertynames = xOtherPropertyListStr.value();
  67. xmls::SplitString(otherPropertynames, m_OtherpropertyList, ",");
  68. xmls::SplitString(xUsingConstants.value(), m_usingConstants, ",");
  69. }
  70. }