dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
InotifyWatcher.hpp
1// SPDX-FileCopyrightText: 2025 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <functional>
13
14// Project includes
15#include "PollerFd.hpp"
16#include <dfx-utilities/FileSystem.hpp>
18
19namespace dfx::FdWatch
20{
21class Poller;
22
35{
36 DFX_PRIVATE_STATE(InotifyWatcher, DFX_FDWATCH_LOGGER())
37
38public:
43 using Callback = std::move_only_function<void (fs::path, uint32_t)>;
44
45public:
50
51public:
63 int addWatch(fs::path const & path, uint32_t mask, Callback cb);
64
68 void rmWatch(int idx) noexcept;
69
70public:
78 static std::vector<std::string> maskToString(uint32_t mask);
79};
80} // !namespace dfx::Utils
Macros to implement the Private State (PIMPL-like) idiom with value semantics.
#define DFX_PRIVATE_STATE(Class, logger)
Declare a private implementation state for a class.
Definition PrivateState.hpp:52
#define DFX_PRIVATE_STATE_DECLARE_RULE_OF_5(Class)
Declare Rule-of-5 special member functions using the private state pattern.
Definition PrivateState.hpp:82
void rmWatch(int idx) noexcept
Removes a previously added watch.
static std::vector< std::string > maskToString(uint32_t mask)
Converts an inotify mask to a list of human-readable flag names.
int addWatch(fs::path const &path, uint32_t mask, Callback cb)
Adds an inotify watch for path with the provided mask.
InotifyWatcher(Poller &poller)
Constructs an inotify watcher and registers its FD into poller.
std::move_only_function< void(fs::path, uint32_t)> Callback
Callback invoked when a watched path produces an inotify event.
Definition InotifyWatcher.hpp:43
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Definition SocketClient.hpp:23