summaryrefslogtreecommitdiffstats
path: root/manager.hpp
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-08-08 07:19:34 -0500
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-08-23 22:35:28 -0500
commitb28990f35e1b9d932a1df83b1606f411ba70c637 (patch)
tree4f133a7b2a7463ab519f6754733048eae81d73c4 /manager.hpp
parent6620e98de4b81e5eadb96cb739b76c8c030418c8 (diff)
downloadphosphor-inventory-manager-b28990f35e1b9d932a1df83b1606f411ba70c637.tar.gz
phosphor-inventory-manager-b28990f35e1b9d932a1df83b1606f411ba70c637.zip
inventory: implement deserialization
Use Cereal to deserialize inventory information persisted in the filesystem and restore that to create inventory d-bus objects. Perform the restore when the app starts. Change-Id: I0f36a9cbdde223e4bfd9e178e33f5677217ba881 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'manager.hpp')
-rw-r--r--manager.hpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/manager.hpp b/manager.hpp
index a94d5ea..e6c60a3 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -94,6 +94,13 @@ struct MakeInterface
*any_ns::any_cast<const std::shared_ptr<T> &>(holder);
cereal::serialize(path, iface, object);
}
+
+ static void deserialize(const std::string& path, const std::string& iface,
+ any_ns::any& holder)
+ {
+ auto& object = *any_ns::any_cast<std::shared_ptr<T> &>(holder);
+ cereal::deserialize(path, iface, object);
+ }
};
/** @class Manager
@@ -152,7 +159,11 @@ class Manager final :
/** @brief Add or update objects on DBus. */
void updateObjects(
- const std::map<sdbusplus::message::object_path, Object>& objs);
+ const std::map<sdbusplus::message::object_path, Object>& objs,
+ bool restoreFromCache = false);
+
+ /** @brief Restore persistent inventory items */
+ void restore();
/** @brief Invoke an sdbusplus server binding method.
*
@@ -201,8 +212,11 @@ class Manager final :
decltype(MakeInterface<int>::assign) >;
using SerializerType = std::add_pointer_t <
decltype(MakeInterface<int>::serialize) >;
+ using DeserializerType = std::add_pointer_t <
+ decltype(MakeInterface<int>::deserialize) >;
using Makers = std::map<std::string,
- std::tuple<MakerType, AssignerType, SerializerType>>;
+ std::tuple<MakerType, AssignerType,
+ SerializerType, DeserializerType>>;
/** @brief Provides weak references to interface holders.
*
@@ -249,7 +263,8 @@ class Manager final :
const sdbusplus::message::object_path& path,
const Object& interfaces,
ObjectReferences::iterator pos,
- bool emitSignals = true);
+ bool emitSignals = true,
+ bool restoreFromCache = false);
/** @brief Provided for testing only. */
volatile bool _shutdown;
OpenPOWER on IntegriCloud