diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-10-10 10:01:01 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-10-19 00:13:47 +0200 |
| commit | dad0aaa9b33a5a217ac115334a94fe299dce9e08 (patch) | |
| tree | baeffb1e3ef6a6e100bc2f255581d77c4b9a45d3 /src/unique_pipe.hh | |
| parent | 86ec0b5386fc2078891a829026844d2ec21ea7db (diff) | |
Add bluetooth module
Can't really do anything yet, but finds the bluetooth adapter
and registers an agent to make it pairable.
Diffstat (limited to 'src/unique_pipe.hh')
| -rw-r--r-- | src/unique_pipe.hh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/unique_pipe.hh b/src/unique_pipe.hh new file mode 100644 index 0000000..c133018 --- /dev/null +++ b/src/unique_pipe.hh @@ -0,0 +1,42 @@ +#ifndef UNIQUE_PIPE_HH +#define UNIQUE_PIPE_HH + +#include "unique_fd.hh" + +#include <cstddef> + +class unique_pipe { + public: + unique_pipe(); + unique_pipe(unique_pipe&& fd); + unique_pipe(unique_pipe const&) = delete; + unique_pipe& operator=(unique_pipe const&) = delete; + + ~unique_pipe() = default; + + unique_pipe& operator=(unique_pipe&& fd); + + [[nodiscard]] + int reader() const { + return fd_[0].get(); + } + [[nodiscard]] + int writer() const { + return fd_[1].get(); + } + + [[nodiscard]] + explicit operator bool() const { + return fd_[0] || fd_[1]; + } + + void reset(); + + unique_fd release_reader(); + unique_fd release_writer(); + + private: + unique_fd fd_[2]; +}; + +#endif // UNIQUE_PIPE_HH |
