mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-07-04 02:01:58 +00:00
Extract into library
This commit is contained in:
44
src/library/service_handle.cpp
Normal file
44
src/library/service_handle.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "std_include.hpp"
|
||||
#include "service_handle.hpp"
|
||||
|
||||
service_handle::service_handle()
|
||||
: service_handle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
service_handle::service_handle(const SC_HANDLE handle)
|
||||
: handle_{handle}
|
||||
{
|
||||
}
|
||||
|
||||
service_handle::~service_handle()
|
||||
{
|
||||
if (this->handle_)
|
||||
{
|
||||
CloseServiceHandle(this->handle_);
|
||||
this->handle_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
service_handle::service_handle(service_handle&& obj) noexcept
|
||||
: service_handle()
|
||||
{
|
||||
this->operator=(std::move(obj));
|
||||
}
|
||||
|
||||
service_handle& service_handle::operator=(service_handle&& obj) noexcept
|
||||
{
|
||||
if (this != &obj)
|
||||
{
|
||||
this->~service_handle();
|
||||
this->handle_ = obj.handle_;
|
||||
obj.handle_ = nullptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
service_handle::operator SC_HANDLE() const
|
||||
{
|
||||
return this->handle_;
|
||||
}
|
Reference in New Issue
Block a user