summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2019-05-13 07:37:33 -0700
committerPatrick Venture <venture@google.com>2019-05-13 07:37:33 -0700
commit2fe4c652c5b49364e507677e43f2ac05ab8ce79a (patch)
treeb209e741f581bc26acc5eca38f139c470865a805
parent15bba880aaa07634cceaec97b8b4440ee328b7cc (diff)
downloadipmi-blob-tool-2fe4c652c5b49364e507677e43f2ac05ab8ce79a.tar.gz
ipmi-blob-tool-2fe4c652c5b49364e507677e43f2ac05ab8ce79a.zip
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>
-rw-r--r--src/ipmiblob/ipmi_handler.cpp6
-rw-r--r--src/ipmiblob/ipmi_handler.hpp6
2 files changed, 12 insertions, 0 deletions
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 @@ namespace ipmiblob
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){};
OpenPOWER on IntegriCloud