diff options
Diffstat (limited to 'um/service/include/libservice/service_manager.hpp')
-rw-r--r-- | um/service/include/libservice/service_manager.hpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/um/service/include/libservice/service_manager.hpp b/um/service/include/libservice/service_manager.hpp new file mode 100644 index 0000000..80e6f12 --- /dev/null +++ b/um/service/include/libservice/service_manager.hpp @@ -0,0 +1,63 @@ +// Copyright (c) 2015 Egor Tensin <Egor.Tensin@gmail.com> +// This file is part of the "Windows 7 drivers" project. +// For details, see https://github.com/egor-tensin/windows7-drivers. +// Distributed under the MIT License. + +#pragma once + +#include "common.hpp" +#include "service_handle.hpp" + +#include <Windows.h> + +#include <utility> + +namespace libservice +{ + class ServiceManager + { + public: + static ServiceManager open(); + + ServiceManager(ServiceManager&& other) LIBSERVICE_NOEXCEPT + { + swap(other); + } + + ServiceManager& operator=(ServiceManager other) LIBSERVICE_NOEXCEPT + { + swap(other); + return *this; + } + + void swap(ServiceManager& other) LIBSERVICE_NOEXCEPT + { + using std::swap; + swap(handle, other.handle); + } + + operator SC_HANDLE() const + { + return handle; + } + + private: + ServiceManager(ServiceHandle handle) + : handle(std::move(handle)) + { } + + ServiceHandle handle; + + ServiceManager(const ServiceManager&) = delete; + }; + + void swap(ServiceManager& a, ServiceManager& b) LIBSERVICE_NOEXCEPT; +} + +namespace std +{ + template <> + void swap<libservice::ServiceManager>( + libservice::ServiceManager&, + libservice::ServiceManager&) LIBSERVICE_NOEXCEPT; +} |