summaryrefslogtreecommitdiffstats
path: root/watch.hpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-09-14 14:42:34 -0500
committerRatan K Gupta <ratagupt@linux.vnet.ibm.com>2018-09-15 00:47:14 -0400
commit57d9c5066e2fc28d3e89b1bd9fd3ee98e27c4c48 (patch)
treef232adeab7b6a89cd392d4300be70451d335d14f /watch.hpp
parentce26282763be6a9d7fa21fcc93d5da8682d3a021 (diff)
downloadphosphor-networkd-57d9c5066e2fc28d3e89b1bd9fd3ee98e27c4c48.tar.gz
phosphor-networkd-57d9c5066e2fc28d3e89b1bd9fd3ee98e27c4c48.zip
clang-format: Update to match docs repo
Update the .clang-format file and run clang-format-6.0. This .clang-format matches the example one in https://github.com/openbmc/docs/blob/master/cpp-style-and-conventions.md#clang-formatting Change-Id: Ia331c9a5b040e1a3c45a0ebf1b8d776d93b05ae5 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'watch.hpp')
-rw-r--r--watch.hpp145
1 files changed, 70 insertions, 75 deletions
diff --git a/watch.hpp b/watch.hpp
index 6a274aa..bffed3e 100644
--- a/watch.hpp
+++ b/watch.hpp
@@ -1,8 +1,8 @@
#pragma once
#include "dns_updater.hpp"
-#include "util.hpp"
#include "types.hpp"
+#include "util.hpp"
#include <sys/inotify.h>
#include <systemd/sd-event.h>
@@ -31,82 +31,77 @@ using UserCallBack = std::function<void(const std::string&)>;
*/
class Watch
{
- public:
- Watch() = delete;
- Watch(const Watch&) = delete;
- Watch& operator=(const Watch&) = delete;
- Watch(Watch&&) = delete;
- Watch& operator=(Watch&&) = delete;
-
- /** @brief Hooks inotify watch with sd-event
- *
- * @param[in] eventPtr - Reference to sd_event wrapped in unique_ptr
- * @param[in] path - File path to be watched
- * @param[in] userFunc - User specific callback function on events
- * @param[in] flags - Flags to be supplied to inotify
- * @param[in] mask - Mask of events to be supplied to inotify
- * @param[in] events - Events to be watched
- */
- Watch(phosphor::network::EventPtr& eventPtr,
- const fs::path path,
- UserCallBack userFunc,
- int flags = IN_NONBLOCK,
- uint32_t mask = IN_CLOSE_WRITE,
- uint32_t events = EPOLLIN);
-
- /** @brief Remove inotify watch and close fd's */
- ~Watch()
+ public:
+ Watch() = delete;
+ Watch(const Watch&) = delete;
+ Watch& operator=(const Watch&) = delete;
+ Watch(Watch&&) = delete;
+ Watch& operator=(Watch&&) = delete;
+
+ /** @brief Hooks inotify watch with sd-event
+ *
+ * @param[in] eventPtr - Reference to sd_event wrapped in unique_ptr
+ * @param[in] path - File path to be watched
+ * @param[in] userFunc - User specific callback function on events
+ * @param[in] flags - Flags to be supplied to inotify
+ * @param[in] mask - Mask of events to be supplied to inotify
+ * @param[in] events - Events to be watched
+ */
+ Watch(phosphor::network::EventPtr& eventPtr, const fs::path path,
+ UserCallBack userFunc, int flags = IN_NONBLOCK,
+ uint32_t mask = IN_CLOSE_WRITE, uint32_t events = EPOLLIN);
+
+ /** @brief Remove inotify watch and close fd's */
+ ~Watch()
+ {
+ if ((fd() >= 0) && (wd >= 0))
{
- if ((fd() >= 0) && (wd >= 0))
- {
- inotify_rm_watch(fd(), wd);
- }
+ inotify_rm_watch(fd(), wd);
}
-
- private:
- /** @brief Callback invoked when inotify event fires
- *
- * @details On a matching event, calls back into user supplied
- * function if there is one registered
- *
- * @param[in] eventSource - Event source
- * @param[in] fd - Inotify fd
- * @param[in] retEvents - Events that matched for fd
- * @param[in] userData - Pointer to Watch object
- *
- * @returns 0 on success, -1 on fail
- */
- static int processEvents(sd_event_source* eventSource,
- int fd,
- uint32_t retEvents,
- void* userData);
-
- /** @brief Initializes an inotify instance
- *
- * @return Descriptor on success, -1 on failure
- */
- int inotifyInit();
-
- /** @brief File path to be watched */
- const fs::path path;
-
- /** @brief User callback function */
- UserCallBack userFunc;
-
- /** @brief Inotify flags */
- int flags;
-
- /** @brief Mask of events */
- uint32_t mask;
-
- /** @brief Events to be watched */
- uint32_t events;
-
- /** @brief Watch descriptor */
- int wd = -1;
-
- /** @brief File descriptor manager */
- phosphor::Descriptor fd;
+ }
+
+ private:
+ /** @brief Callback invoked when inotify event fires
+ *
+ * @details On a matching event, calls back into user supplied
+ * function if there is one registered
+ *
+ * @param[in] eventSource - Event source
+ * @param[in] fd - Inotify fd
+ * @param[in] retEvents - Events that matched for fd
+ * @param[in] userData - Pointer to Watch object
+ *
+ * @returns 0 on success, -1 on fail
+ */
+ static int processEvents(sd_event_source* eventSource, int fd,
+ uint32_t retEvents, void* userData);
+
+ /** @brief Initializes an inotify instance
+ *
+ * @return Descriptor on success, -1 on failure
+ */
+ int inotifyInit();
+
+ /** @brief File path to be watched */
+ const fs::path path;
+
+ /** @brief User callback function */
+ UserCallBack userFunc;
+
+ /** @brief Inotify flags */
+ int flags;
+
+ /** @brief Mask of events */
+ uint32_t mask;
+
+ /** @brief Events to be watched */
+ uint32_t events;
+
+ /** @brief Watch descriptor */
+ int wd = -1;
+
+ /** @brief File descriptor manager */
+ phosphor::Descriptor fd;
};
} // namespace inotify
OpenPOWER on IntegriCloud