system_state.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: system_state.h
  5. *
  6. * Description: system_state class definition.
  7. *
  8. * Version: 1.0
  9. * Created: 13/01/2021
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: chenyujie, chenyujie28@jd.com@jd.com
  14. * Company: JD.com, Inc.
  15. *
  16. * =====================================================================================
  17. */
  18. #ifndef SYSTEM_STATE_H_
  19. #define SYSTEM_STATE_H_
  20. // common
  21. #include "algorithm/non_copyable.h"
  22. #include "algorithm/singleton.h"
  23. #include "journal_id.h"
  24. class DTCTableDefinition;
  25. class SystemState : private noncopyable
  26. {
  27. public:
  28. SystemState()
  29. : p_dtc_table_def_(NULL)
  30. , o_journal_id_()
  31. { };
  32. virtual ~SystemState() { };
  33. public:
  34. static SystemState* Instance()
  35. {
  36. return Singleton<SystemState>::instance();
  37. };
  38. static void Destroy()
  39. {
  40. Singleton<SystemState>::destory();
  41. };
  42. public:
  43. void SetDtcTabDef(const DTCTableDefinition* p_dtc_table_def) {
  44. p_dtc_table_def_ = p_dtc_table_def;
  45. };
  46. const DTCTableDefinition* GetDtcTabDef() {
  47. return p_dtc_table_def_;
  48. };
  49. void SetJournalID(const JournalID& o_jour_id) {
  50. o_journal_id_ = o_jour_id;
  51. }
  52. const JournalID& GetJournalID() {
  53. return o_journal_id_;
  54. }
  55. private:
  56. DTCTableDefinition* p_dtc_table_def_;
  57. JournalID o_journal_id_;
  58. };
  59. #endif