im.h 1.2 KB
Newer Older
S
superjom 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#ifndef VISUALDL_BACKEND_LOGIC_IM_H
#define VISUALDL_BACKEND_LOGIC_IM_H

#include <string>

#include "visualdl/backend/storage/storage.h"

namespace visualdl {

/*
 * Maintain the Storage singleton in memory, pre-compute some the statical
 * information to help visualizaton.
 */
class InformationMaintainer final {
public:
  InformationMaintainer() {}

  static InformationMaintainer &Global() {
    static InformationMaintainer *x = new InformationMaintainer();
    return *x;
  }

  /*
   * Set the disk path to store the Storage object.
   */
  void SetPersistDest(const std::string &path);

  storage::Tablet *AddTablet(const std::string &tag, int num_samples);

  /*
   * @tag: tag of the target Tablet.
S
superjom 已提交
32
   * @record: a record
S
superjom 已提交
33 34 35 36
   *
   * NOTE pass in the serialized protobuf message will trigger copying, but
   * simpler to support different Tablet data formats.
   */
S
superjom 已提交
37
  void AddRecord(const std::string &tag, const storage::Record &record);
S
superjom 已提交
38

S
superjom 已提交
39 40 41 42 43
  /*
   * delete all the information.
   */
  void Clear();

S
superjom 已提交
44 45 46 47 48 49 50 51 52 53 54
  /*
   * Save the Storage Protobuf to disk.
   */
  void PersistToDisk();

  Storage &storage() { return storage_; }

private:
  Storage storage_;
};

Q
Qiao Longfei 已提交
55
}  // namespace visualdl
S
superjom 已提交
56

Q
Qiao Longfei 已提交
57
#endif  // VISUALDL_BACKEND_LOGIC_IM_H