HeadCountCfg.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __HEADCOUNT_CFG_H
  2. #define __HEADCOUNT_CFG_H
  3. #include "MAS_AlgoDef.h"
  4. #define NAMESPACE_HEADCOUNT_BEGIN namespace headcount {
  5. #define NAMESPACE_HEADCOUNT_END };
  6. NAMESPACE_MAS_BEGIN
  7. NAMESPACE_HEADCOUNT_BEGIN
  8. struct HeadCountCfg {
  9. TZ_INT TimeThreshold;
  10. HeadCountCfg() : TimeThreshold(60){}
  11. std::string toJson() const
  12. {
  13. tzc::json::JsonDoc document;
  14. document.SetObject();
  15. tzc::json::setFiled(document, "TimeThreshold", TimeThreshold);
  16. return tzc::json::ValueToJson(document);
  17. }
  18. static TZ_BOOL fromJson(const std::string & json, HeadCountCfg & value)
  19. {
  20. tzc::json::JsonDoc document;
  21. document.Parse(json.c_str());
  22. if (document.HasParseError())
  23. {
  24. return false;
  25. }
  26. value.TimeThreshold = tzc::json::getFiled(document, "TimeThreshold", 60);
  27. return true;
  28. }
  29. };
  30. struct HeadCountStrategyExterns {
  31. std::string Description;
  32. HeadCountStrategyExterns() : Description("") {}
  33. std::string toJson() const
  34. {
  35. tzc::json::JsonDoc document;
  36. document.SetObject();
  37. tzc::json::setFiled(document, "Description", Description);
  38. return tzc::json::ValueToJson(document);
  39. }
  40. static TZ_BOOL fromJson(const std::string & json, HeadCountStrategyExterns & value)
  41. {
  42. tzc::json::JsonDoc document;
  43. document.Parse(json.c_str());
  44. if (document.HasParseError())
  45. {
  46. return false;
  47. }
  48. value.Description = tzc::json::getFiled(document, "Description", "");
  49. return true;
  50. }
  51. };
  52. NAMESPACE_HEADCOUNT_END
  53. NAMESPACE_MAS_END
  54. #endif