001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.util.datalog;
006
007/** Log entry base class. */
008public class DataLogEntry {
009  protected DataLogEntry(DataLog log, String name, String type, String metadata, long timestamp) {
010    m_log = log;
011    m_entry = log.start(name, type, metadata, timestamp);
012  }
013
014  protected DataLogEntry(DataLog log, String name, String type, String metadata) {
015    this(log, name, type, metadata, 0);
016  }
017
018  protected DataLogEntry(DataLog log, String name, String type) {
019    this(log, name, type, "");
020  }
021
022  /**
023   * Updates the metadata for the entry.
024   *
025   * @param metadata New metadata for the entry
026   * @param timestamp Time stamp (0 to indicate now)
027   */
028  public void setMetadata(String metadata, long timestamp) {
029    m_log.setMetadata(m_entry, metadata, timestamp);
030  }
031
032  /**
033   * Updates the metadata for the entry.
034   *
035   * @param metadata New metadata for the entry
036   */
037  public void setMetadata(String metadata) {
038    setMetadata(metadata, 0);
039  }
040
041  /**
042   * Finishes the entry.
043   *
044   * @param timestamp Time stamp (0 to indicate now)
045   */
046  public void finish(long timestamp) {
047    m_log.finish(m_entry, timestamp);
048  }
049
050  /** Finishes the entry. */
051  public void finish() {
052    finish(0);
053  }
054
055  protected final DataLog m_log;
056  protected final int m_entry;
057}