aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/libservice/include/libservice/service.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.hpp
parentREADME update (diff)
downloadwindows7-drivers-10e1921d30a66db85d8707e554e0eeb5efbb8b00.tar.gz
windows7-drivers-10e1921d30a66db85d8707e554e0eeb5efbb8b00.zip
add service mgmt lib & utils
Diffstat (limited to '')
-rw-r--r--utils/libservice/include/libservice/service.hpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/utils/libservice/include/libservice/service.hpp b/utils/libservice/include/libservice/service.hpp
new file mode 100644
index 0000000..a14f0e2
--- /dev/null
+++ b/utils/libservice/include/libservice/service.hpp
@@ -0,0 +1,69 @@
+/**
+ * \file
+ * \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 "service_manager.hpp"
+
+#include <string>
+#include <utility>
+
+namespace libservice
+{
+ class Service
+ {
+ public:
+ static Service open(const ServiceManager&,
+ const std::string& name);
+ static Service install(const ServiceManager&,
+ const std::string& name,
+ const std::string& bin_path);
+
+ void start() const;
+ void stop() const;
+ void uninstall() const;
+
+ Service(Service&& other) LIBSERVICE_NOEXCEPT
+ {
+ swap(other);
+ }
+
+ Service& operator=(Service other) LIBSERVICE_NOEXCEPT
+ {
+ swap(other);
+ return *this;
+ }
+
+ void swap(Service& other) LIBSERVICE_NOEXCEPT
+ {
+ using std::swap;
+ swap(m_handle, other.m_handle);
+ }
+
+ private:
+ explicit Service(ServiceHandle h)
+ : m_handle(std::move(h))
+ { }
+
+ ServiceHandle m_handle;
+
+ Service(const Service&) = delete;
+ };
+
+ void swap(Service&, Service&) LIBSERVICE_NOEXCEPT;
+}
+
+namespace std
+{
+ template <>
+ void swap<libservice::Service>(
+ libservice::Service&,
+ libservice::Service&) LIBSERVICE_NOEXCEPT;
+}