Lely core libraries 2.3.4
dev.hpp
Go to the documentation of this file.
1
24#ifndef LELY_IO2_DEV_HPP_
25#define LELY_IO2_DEV_HPP_
26
27#include <lely/ev/exec.hpp>
28#include <lely/io2/ctx.hpp>
29#include <lely/io2/dev.h>
30
31namespace lely {
32namespace io {
33
35class Device {
36 public:
37 explicit Device(io_dev_t* dev_) noexcept : dev(dev_) {}
38
39 operator io_dev_t*() const noexcept { return dev; }
40
44 return ContextBase(io_dev_get_ctx(*this));
45 }
46
52
54 bool
55 cancel(ev_task& task) noexcept {
56 return io_dev_cancel(*this, &task) != 0;
57 }
58
60 ::std::size_t
62 return io_dev_cancel(*this, nullptr);
63 }
64
66 bool
67 abort(ev_task& task) noexcept {
68 return io_dev_abort(*this, &task) != 0;
69 }
70
72 ::std::size_t
74 return io_dev_abort(*this, nullptr);
75 }
76
77 protected:
78 io_dev_t* dev{nullptr};
79};
80
81} // namespace io
82} // namespace lely
83
84#endif // !LELY_IO2_DEV_HPP_
A CANopen value.
Definition val.hpp:42
An abstract task executor. This class is a wrapper around #ev_exec_t*.
Definition exec.hpp:38
A refence to an I/O context. This class is a wrapper around #io_ctx_t*.
Definition ctx.hpp:49
An abstract I/O device. This class is a wrapper around #io_dev_t*.
Definition dev.hpp:35
::std::size_t abort_all() noexcept
Definition dev.hpp:73
ContextBase get_ctx() const noexcept
Definition dev.hpp:43
ev::Executor get_executor() const noexcept
Definition dev.hpp:49
bool cancel(ev_task &task) noexcept
Definition dev.hpp:55
bool abort(ev_task &task) noexcept
Definition dev.hpp:67
::std::size_t cancel_all() noexcept
Definition dev.hpp:61
This header file is part of the I/O library; it contains the C++ interface for the I/O context.
This header file is part of the event library; it contains the C++ interface for the abstract task ex...
This header file is part of the I/O library; it contains the abstract I/O device interface.
size_t io_dev_abort(io_dev_t *dev, struct ev_task *task)
Aborts the asynchronous operation submitted to *dev, if its task has not yet been submitted to its ex...
Definition dev.h:98
const struct io_dev_vtbl *const io_dev_t
An abstract I/O device.
Definition dev.h:35
io_ctx_t * io_dev_get_ctx(const io_dev_t *dev)
Returns a pointer to the I/O context with which the I/O device is registered.
Definition dev.h:80
size_t io_dev_cancel(io_dev_t *dev, struct ev_task *task)
Cancels the asynchronous operation submitted to *dev, if its task has not yet been submitted to its e...
Definition dev.h:92
ev_exec_t * io_dev_get_exec(const io_dev_t *dev)
Returns a pointer to the executor used by the I/O device to execute asynchronous tasks.
Definition dev.h:86
An executable task.
Definition task.h:41