aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/libservice/include/libservice/service_manager.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-05-10 23:00:08 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-05-10 23:00:08 +0300
commit10e1921d30a66db85d8707e554e0eeb5efbb8b00 (patch)
tree4ceb7ceb63a54a3c7d63120ba23cd7d04b6237ce /utils/libservice/include/libservice/service_manager.hpp
parentREADME update (diff)
downloadwindows7-drivers-10e1921d30a66db85d8707e554e0eeb5efbb8b00.tar.gz
windows7-drivers-10e1921d30a66db85d8707e554e0eeb5efbb8b00.zip
add service mgmt lib & utils
Diffstat (limited to 'utils/libservice/include/libservice/service_manager.hpp')
-rw-r--r--utils/libservice/include/libservice/service_manager.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/utils/libservice/include/libservice/service_manager.hpp b/utils/libservice/include/libservice/service_manager.hpp
new file mode 100644
index 0000000..a2bb268
--- /dev/null
+++ b/utils/libservice/include/libservice/service_manager.hpp
@@ -0,0 +1,65 @@
+/**
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#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(m_handle, other.m_handle);
+ }
+
+ explicit operator SC_HANDLE() const
+ {
+ return static_cast<SC_HANDLE>(m_handle);
+ }
+
+ private:
+ explicit ServiceManager(ServiceHandle h)
+ : m_handle(std::move(h))
+ { }
+
+ ServiceHandle m_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;
+}