50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#include "HalMakePtr.h"
|
|
#include "Hal.h"
|
|
#include "HalCpp.h"
|
|
#include "ILog.h"
|
|
StatusCode create_hal_module(void)
|
|
{
|
|
IHal *hal = NULL;
|
|
StatusCode code = HalMakePtr::GetInstance()->CreateHalPtr(&hal);
|
|
if (IsCodeOK(code))
|
|
{
|
|
LogInfo("Create Hal instance ok.\n");
|
|
ResetHalImpl((IHal *)hal);
|
|
}
|
|
else
|
|
{
|
|
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
|
}
|
|
auto instance = std::make_shared<IHalCpp>();
|
|
StatusCode code2 = HalMakePtr::GetInstance()->CreateHalSharePtr(instance);
|
|
if (IsCodeOK(code2))
|
|
{
|
|
LogInfo("IHal manager instance is ok.\n");
|
|
IHalCpp::GetInstance(&instance);
|
|
}
|
|
return code2;
|
|
}
|
|
StatusCode destroy_hal_module(void)
|
|
{
|
|
ResetHalImpl(nullptr);
|
|
return CreateStatusCode(STATUS_CODE_OK);
|
|
}
|
|
std::shared_ptr<HalMakePtr> &HalMakePtr::GetInstance(std::shared_ptr<HalMakePtr> *impl)
|
|
{
|
|
static auto instance = std::make_shared<HalMakePtr>();
|
|
if (impl)
|
|
{
|
|
instance = *impl;
|
|
}
|
|
return instance;
|
|
}
|
|
StatusCode HalMakePtr::CreateHalPtr(IHal **hal)
|
|
{
|
|
return NewHal((Hal **)hal);
|
|
}
|
|
StatusCode HalMakePtr::CreateHalSharePtr(std::shared_ptr<IHalCpp> &impl)
|
|
{
|
|
LogInfo("HalMakePtr make ptr.\n");
|
|
impl = std::make_shared<HalCpp>();
|
|
return CreateStatusCode(STATUS_CODE_OK);
|
|
} |