diff options
author | Matt Spinler <spinler@us.ibm.com> | 2018-07-11 10:37:12 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2018-08-06 14:56:16 -0500 |
commit | 81957841962362be620339dd30573030d54475df (patch) | |
tree | 5b4794b6934fb086af40ae91639cb290347c835e /chassis_state_manager.cpp | |
parent | e6710b7ecef38eef8f927fd7fec6ad433bb00ce2 (diff) | |
download | phosphor-state-manager-81957841962362be620339dd30573030d54475df.tar.gz phosphor-state-manager-81957841962362be620339dd30573030d54475df.zip |
Minor power on hours serialization changes
In preparation for the chassis manager class persisting
another data member, some changes need to be made to the
POH serialization code to make it consistent with saving
individual data members in separate files.
1) Remove the load()/save() functions from the Chassis class.
Cereal only requires those when archiving a custom object,
like when the Host class uses oarchive(*this).
2) Remove the Cereal version define from the Chassis class.
That is also only used when a custom object is serialized,
and in fact the version wasn't being stored in the serialized
data anyway.
3) Rename the POH serialization/deserialization functions to be
specifically for the POH counter.
These don't affect how or where POH value is persisted.
Tested: Verify the POH value still increments and survives
reboots.
Change-Id: I065e1a24e018b66f284c6a00f9a34d24eaaedc36
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'chassis_state_manager.cpp')
-rw-r--r-- | chassis_state_manager.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp index 03dd176..a723d8f 100644 --- a/chassis_state_manager.cpp +++ b/chassis_state_manager.cpp @@ -9,9 +9,6 @@ #include "config.h" #include <experimental/filesystem> -// Register class version with Cereal -CEREAL_CLASS_VERSION(phosphor::state::manager::Chassis, CLASS_VERSION); - namespace phosphor { namespace state @@ -269,7 +266,7 @@ uint32_t Chassis::pOHCounter(uint32_t value) if (value != pOHCounter()) { ChassisInherit::pOHCounter(value); - serialize(); + serializePOH(); } return pOHCounter(); } @@ -277,7 +274,7 @@ uint32_t Chassis::pOHCounter(uint32_t value) void Chassis::restorePOHCounter() { uint32_t counter; - if (!deserialize(POH_COUNTER_PERSIST_PATH, counter)) + if (!deserializePOH(POH_COUNTER_PERSIST_PATH, counter)) { // set to default value pOHCounter(0); @@ -288,7 +285,7 @@ void Chassis::restorePOHCounter() } } -fs::path Chassis::serialize(const fs::path& path) +fs::path Chassis::serializePOH(const fs::path& path) { std::ofstream os(path.c_str(), std::ios::binary); cereal::JSONOutputArchive oarchive(os); @@ -296,7 +293,7 @@ fs::path Chassis::serialize(const fs::path& path) return path; } -bool Chassis::deserialize(const fs::path& path, uint32_t& pOHCounter) +bool Chassis::deserializePOH(const fs::path& path, uint32_t& pOHCounter) { try { |