Track which types of data are stored in which files

This sets us up to pre-load timestamps but not data when sorting log
files by recording the types of messages in each log file.  The goal is
to be able to load all timestamps and remote timestamps completely into
RAM at the beginning if they are in separate files, and then reduce our
data buffers to something small.  By loading all timestamps into RAM at
the beginning efficiently, we should be able to solve the entire class
of frozen bugs.

Change-Id: Ib21f9d3b39356abad6b912dd5108f971a9ed12ce
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/log_namer.h b/aos/events/logging/log_namer.h
index 34484c4..6a18997 100644
--- a/aos/events/logging/log_namer.h
+++ b/aos/events/logging/log_namer.h
@@ -41,7 +41,8 @@
   NewDataWriter(LogNamer *log_namer, const Node *node, const Node *logger_node,
                 std::function<void(NewDataWriter *)> reopen,
                 std::function<void(NewDataWriter *)> close,
-                size_t max_message_size);
+                size_t max_message_size,
+                std::initializer_list<StoredDataType> types);
 
   void UpdateMaxMessageSize(size_t new_size) {
     if (new_size > max_message_size_) {
@@ -74,11 +75,20 @@
                     bool reliable,
                     monotonic_clock::time_point monotonic_timestamp_time =
                         monotonic_clock::min_time);
+
   // Coppies a message with the provided boot UUID.
-  void CopyMessage(DataEncoder::Copier *coppier,
-                   const UUID &source_node_boot_uuid,
-                   aos::monotonic_clock::time_point now,
-                   aos::monotonic_clock::time_point message_time);
+  void CopyDataMessage(DataEncoder::Copier *copier,
+                       const UUID &source_node_boot_uuid,
+                       aos::monotonic_clock::time_point now,
+                       aos::monotonic_clock::time_point message_time);
+  void CopyTimestampMessage(DataEncoder::Copier *copier,
+                            const UUID &source_node_boot_uuid,
+                            aos::monotonic_clock::time_point now,
+                            aos::monotonic_clock::time_point message_time);
+  void CopyRemoteTimestampMessage(
+      DataEncoder::Copier *copier, const UUID &source_node_boot_uuid,
+      aos::monotonic_clock::time_point now,
+      aos::monotonic_clock::time_point message_time);
 
   // Updates the current boot for the source node.  This is useful when you want
   // to queue a message that may trigger a reboot rotation, but then need to
@@ -144,6 +154,11 @@
   // Signals that a node has rebooted.
   void Reboot(const UUID &source_node_boot_uuid);
 
+  void CopyMessage(DataEncoder::Copier *copier,
+                   const UUID &source_node_boot_uuid,
+                   aos::monotonic_clock::time_point now,
+                   aos::monotonic_clock::time_point message_time);
+
   void QueueHeader(
       aos::SizePrefixedFlatbufferDetachedBuffer<LogFileHeader> &&header);
 
@@ -182,6 +197,11 @@
   // Since the messages can be logged out of order, this helps determine if
   // max out of order duration was violated.
   monotonic_clock::time_point newest_message_time_ = monotonic_clock::min_time;
+
+  // An array with a bool for each value of StoredDataType representing if that
+  // data type is allowed to be logged by this object.
+  std::array<bool, static_cast<size_t>(StoredDataType::MAX) + 1>
+      allowed_data_types_;
 };
 
 // Interface describing how to name, track, and add headers to log file parts.
@@ -302,7 +322,9 @@
   aos::SizePrefixedFlatbufferDetachedBuffer<LogFileHeader> MakeHeader(
       size_t node_index, const std::vector<NewDataWriter::State> &state,
       const UUID &parts_uuid, int parts_index,
-      std::chrono::nanoseconds max_out_of_order_duration);
+      std::chrono::nanoseconds max_out_of_order_duration,
+      const std::array<bool, static_cast<size_t>(StoredDataType::MAX) + 1>
+          &allowed_data_types);
 
   EventLoop *event_loop_;
   const Configuration *const configuration_;