RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
Component.hpp
1#pragma once
2#include <string_view>
3
4#include "RaidZeroLib/api/Runtime/Task.hpp"
5
6namespace rz {
7
21class Component {
22 public:
23 Component(const Component&) = delete;
24 Component& operator=(const Component&) = delete;
25 Component(Component&&) = delete;
27 virtual ~Component();
28
30 [[nodiscard]] std::string_view name() const noexcept { return name_; }
31
34 [[nodiscard]] static Task<> runAll();
35
36 protected:
37 explicit Component(std::string_view name);
38
40 [[nodiscard]] virtual Task<> loop() = 0;
41
42 private:
43 std::string_view name_;
44 Component* nextComponent = nullptr; // intrusive list of all components, in construction order
45};
46
47} // namespace rz
virtual ~Component()
Component & operator=(const Component &)=delete
Component & operator=(Component &&)=delete
static Task runAll()
Runs the loop of every component constructed so far, in construction order, until cancelled....
Component(Component &&)=delete
Component(std::string_view name)
std::string_view name() const noexcept
Used in log and error messages.
Definition Component.hpp:30
Component(const Component &)=delete
virtual Task loop()=0
Runs for the whole program; never returns.
corral::Task< T > Task
Lazy: nothing runs until it is co_awaited.
Definition Task.hpp:17
Definition DriverControl.hpp:11