From ada6a066fe2f0e743401f8436932e8d17b00e46c Mon Sep 17 00:00:00 2001 From: Roland Jax Date: Sun, 16 Nov 2014 14:25:23 +0100 Subject: [PATCH] documentation for class Daemon added. --- src/lib/utils/daemon.cpp | 4 ++-- src/lib/utils/daemon.h | 46 ++++++++++++++++++++++++++++++++++------ src/lib/utils/logger.h | 2 +- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/lib/utils/daemon.cpp b/src/lib/utils/daemon.cpp index 18c35a3e..36ecd155 100644 --- a/src/lib/utils/daemon.cpp +++ b/src/lib/utils/daemon.cpp @@ -32,10 +32,10 @@ Daemon& Daemon::Instance() return instance; } -void Daemon::run(const char* file) +void Daemon::run(const char* pidfile) { m_status = false; - m_pidfile = file; + m_pidfile = pidfile; m_pidfd = 0; pid_t pid; diff --git a/src/lib/utils/daemon.h b/src/lib/utils/daemon.h index ac01d42b..4ce8780a 100644 --- a/src/lib/utils/daemon.h +++ b/src/lib/utils/daemon.h @@ -20,27 +20,59 @@ #ifndef LIBUTILS_DAEMON_H_ #define LIBUTILS_DAEMON_H_ +/** + * @brief class to daemonize a process. + */ class Daemon { public: + /** + * @brief create an daemon instance and return the reference. + * @return the reference to instance. + */ static Daemon& Instance(); - ~Daemon() {} - void run(const char* file); + /** + * @brief daemonize act process. + * @param pidfile the name of the pid file. + */ + void run(const char* pidfile); + + /** + * @brief stop daemon and delete the pid file. + */ void stop() { pidfile_close(); } + + /** + * @brief show actual status if daemonize. + * @return true if process is a daemon. + */ bool status() { return m_status; } private: - bool m_status; - const char* m_pidfile; - int m_pidfd; - + /** private constructor - singleton pattern */ Daemon() {} Daemon(const Daemon&); - Daemon& operator= (const Daemon&); + Daemon& operator=(const Daemon&); + /** status of process; true if we are a daemon */ + bool m_status; + /** name of the pid file*/ + const char* m_pidfile; + /** file descriptor of the pid file */ + int m_pidfd; + + /** + * @brief creates a pid file for process. + * @return true if success. + */ bool pidfile_open(); + + /** + * @brief close and delete the pid file. + * @return true if success. + */ bool pidfile_close(); }; diff --git a/src/lib/utils/logger.h b/src/lib/utils/logger.h index f8ac4b39..adae3738 100644 --- a/src/lib/utils/logger.h +++ b/src/lib/utils/logger.h @@ -155,7 +155,7 @@ public: private: LogInstance() {} LogInstance(const LogInstance&); - LogInstance& operator= (const LogInstance&); + LogInstance& operator=(const LogInstance&); typedef std::vector sink_t; typedef std::vector::iterator sinkCI_t;