ipmi_handler: provide unique creator

Ideally ipmi handler objects should not be shared between objects,
therefore provide a convenient unique creator.

Change-Id: Iaaf9b4b37676699f0a7ecf6d2550b07e1080742e
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/src/ipmiblob/ipmi_handler.cpp b/src/ipmiblob/ipmi_handler.cpp
index 0735004..568b86c 100644
--- a/src/ipmiblob/ipmi_handler.cpp
+++ b/src/ipmiblob/ipmi_handler.cpp
@@ -26,6 +26,7 @@
 #include <array>
 #include <cstdint>
 #include <cstring>
+#include <memory>
 #include <sstream>
 #include <string>
 #include <vector>
@@ -33,6 +34,11 @@
 namespace ipmiblob
 {
 
+std::unique_ptr<IpmiInterface> IpmiHandler::CreateIpmiHandler()
+{
+    return std::make_unique<IpmiHandler>();
+}
+
 void IpmiHandler::open()
 {
     const int device = 0;
diff --git a/src/ipmiblob/ipmi_handler.hpp b/src/ipmiblob/ipmi_handler.hpp
index 4a1ed9f..34177ae 100644
--- a/src/ipmiblob/ipmi_handler.hpp
+++ b/src/ipmiblob/ipmi_handler.hpp
@@ -3,6 +3,7 @@
 #include "internal/sys.hpp"
 #include "ipmi_interface.hpp"
 
+#include <memory>
 #include <vector>
 
 namespace ipmiblob
@@ -11,6 +12,11 @@
 class IpmiHandler : public IpmiInterface
 {
   public:
+    /* Create an IpmiHandler object with default inputs. It is ill-advised to
+     * share IpmiHandlers between objects.
+     */
+    static std::unique_ptr<IpmiInterface> CreateIpmiHandler();
+
     explicit IpmiHandler(const internal::Sys* sys = &internal::sys_impl) :
         sys(sys){};