Make LogReader own SimulatedEventLoopFactory
This reduces some code duplication and makes things easier once we start
need to be able to mess with the config from the LogReader.
Change-Id: Ia1c04f37865cfd284c3675ca138d38b3f4b7717f
diff --git a/frc971/analysis/py_log_reader.cc b/frc971/analysis/py_log_reader.cc
index 5a6fce4..6a002df 100644
--- a/frc971/analysis/py_log_reader.cc
+++ b/frc971/analysis/py_log_reader.cc
@@ -43,7 +43,6 @@
// All the objects that we need for managing reading a logfile.
struct LogReaderTools {
std::unique_ptr<aos::logger::LogReader> reader;
- std::unique_ptr<aos::SimulatedEventLoopFactory> event_loop_factory;
// Event loop to use for subscribing to buses.
std::unique_ptr<aos::EventLoop> event_loop;
std::vector<ChannelData> channel_data;
@@ -58,9 +57,6 @@
void LogReader_dealloc(LogReaderType *self) {
LogReaderTools *tools = self->tools;
- if (!tools->processed) {
- tools->reader->Deregister();
- }
delete tools;
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -89,11 +85,10 @@
LogReaderTools *tools = CHECK_NOTNULL(self->tools);
tools->reader = std::make_unique<aos::logger::LogReader>(log_file_name);
- tools->event_loop_factory = std::make_unique<aos::SimulatedEventLoopFactory>(
- tools->reader->configuration());
- tools->reader->Register(tools->event_loop_factory.get());
+ tools->reader->Register();
- tools->event_loop = tools->event_loop_factory->MakeEventLoop("data_fetcher");
+ tools->event_loop =
+ tools->reader->event_loop_factory()->MakeEventLoop("data_fetcher");
tools->event_loop->SkipTimingReport();
return 0;
@@ -199,8 +194,7 @@
tools->processed = true;
- tools->event_loop_factory->Run();
- tools->reader->Deregister();
+ tools->reader->event_loop_factory()->Run();
Py_RETURN_NONE;
}