summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2019-05-13 09:06:24 -0700
committerPatrick Venture <venture@google.com>2019-05-13 09:07:04 -0700
commit22fcc84469975fe5ca3597f78fe8103e8a8bbc52 (patch)
tree37f3291bdc872cf8953016460267f6cd6a6674bf
parent786a541caadfc0f05e6ff714881cde7b7f483c94 (diff)
downloadipmi-blob-tool-22fcc84469975fe5ca3597f78fe8103e8a8bbc52.tar.gz
ipmi-blob-tool-22fcc84469975fe5ca3597f78fe8103e8a8bbc52.zip
blob_handler: provide a convenience static factory
Provide a static factory for convenience to get a unique_ptr to the base object. Change-Id: I058e7a28a6bc30182ed9ada5ea479a317d071893 Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--src/ipmiblob/blob_handler.cpp8
-rw-r--r--src/ipmiblob/blob_handler.hpp9
2 files changed, 17 insertions, 0 deletions
diff --git a/src/ipmiblob/blob_handler.cpp b/src/ipmiblob/blob_handler.cpp
index 7a688bf..77fcb6c 100644
--- a/src/ipmiblob/blob_handler.cpp
+++ b/src/ipmiblob/blob_handler.cpp
@@ -19,9 +19,11 @@
#include "blob_errors.hpp"
#include "crc.hpp"
#include "ipmi_errors.hpp"
+#include "ipmi_interface.hpp"
#include <array>
#include <cstring>
+#include <memory>
namespace ipmiblob
{
@@ -31,6 +33,12 @@ namespace
const std::array<std::uint8_t, 3> ipmiPhosphorOen = {0xcf, 0xc2, 0x00};
}
+std::unique_ptr<BlobInterface>
+ BlobHandler::CreateBlobHandler(std::unique_ptr<IpmiInterface> ipmi)
+{
+ return std::make_unique<BlobHandler>(std::move(ipmi));
+}
+
std::vector<std::uint8_t>
BlobHandler::sendIpmiPayload(BlobOEMCommands command,
const std::vector<std::uint8_t>& payload)
diff --git a/src/ipmiblob/blob_handler.hpp b/src/ipmiblob/blob_handler.hpp
index 6c4ba7a..0b6db17 100644
--- a/src/ipmiblob/blob_handler.hpp
+++ b/src/ipmiblob/blob_handler.hpp
@@ -26,6 +26,15 @@ class BlobHandler : public BlobInterface
bmcBlobWriteMeta = 10,
};
+ /**
+ * Create a BlobInterface pointer for use given an ipmi handler.
+ *
+ * @note This is a convenience method.
+ * @return a BlobHandler wrapped as a BlobInterface pointer.
+ */
+ static std::unique_ptr<BlobInterface>
+ CreateBlobHandler(std::unique_ptr<IpmiInterface> ipmi);
+
explicit BlobHandler(std::unique_ptr<IpmiInterface> ipmi) :
ipmi(std::move(ipmi)){};
OpenPOWER on IntegriCloud