Flatbuffer housekeeping in EventLoop.
We should probably use configuration() to be more flexible instead of
configuration_, and now is a good time to add a
Flatbuffer<Configuration> constructor to ShmEventLoop to prevent a bunch
of copy-paste code.
Change-Id: Ic32e131fdb9a68bc9305dd5a48eaf3101dd796b3
diff --git a/aos/events/event_loop.h b/aos/events/event_loop.h
index dc458e7..9dac88b 100644
--- a/aos/events/event_loop.h
+++ b/aos/events/event_loop.h
@@ -488,7 +488,7 @@
// Returns true if the channel exists in the configuration.
template <typename T>
bool HasChannel(const std::string_view channel_name) {
- return configuration::GetChannel(configuration_, channel_name,
+ return configuration::GetChannel(configuration(), channel_name,
T::GetFullyQualifiedName(), name(),
node()) != nullptr;
}
@@ -502,7 +502,7 @@
template <typename T>
Fetcher<T> MakeFetcher(const std::string_view channel_name) {
const Channel *channel =
- configuration::GetChannel(configuration_, channel_name,
+ configuration::GetChannel(configuration(), channel_name,
T::GetFullyQualifiedName(), name(), node());
CHECK(channel != nullptr)
<< ": Channel { \"name\": \"" << channel_name << "\", \"type\": \""
@@ -523,13 +523,13 @@
template <typename T>
Sender<T> MakeSender(const std::string_view channel_name) {
const Channel *channel =
- configuration::GetChannel(configuration_, channel_name,
+ configuration::GetChannel(configuration(), channel_name,
T::GetFullyQualifiedName(), name(), node());
CHECK(channel != nullptr)
<< ": Channel { \"name\": \"" << channel_name << "\", \"type\": \""
<< T::GetFullyQualifiedName() << "\" } not found in config for "
<< name()
- << (configuration::MultiNode(configuration_)
+ << (configuration::MultiNode(configuration())
? absl::StrCat(" on node ", node()->name()->string_view())
: ".");
diff --git a/aos/events/shm_event_loop.h b/aos/events/shm_event_loop.h
index a204a30..148a206 100644
--- a/aos/events/shm_event_loop.h
+++ b/aos/events/shm_event_loop.h
@@ -34,6 +34,8 @@
// destructors are called back in one thread again)
class ShmEventLoop : public EventLoop {
public:
+ ShmEventLoop(const Flatbuffer<Configuration> &configuration)
+ : ShmEventLoop(&configuration.message()) {}
ShmEventLoop(const Configuration *configuration);
~ShmEventLoop() override;