diff options
author | Patrick Venture <venture@google.com> | 2019-05-13 07:37:33 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-05-13 07:37:33 -0700 |
commit | 2fe4c652c5b49364e507677e43f2ac05ab8ce79a (patch) | |
tree | b209e741f581bc26acc5eca38f139c470865a805 | |
parent | 15bba880aaa07634cceaec97b8b4440ee328b7cc (diff) | |
download | ipmi-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.cpp | 6 | ||||
-rw-r--r-- | src/ipmiblob/ipmi_handler.hpp | 6 |
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){}; |