sdk.cc 1.3 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 32 33 34 35
#include <google/protobuf/text_format.h>
#include "visualdl/backend/logic/sdk.h"

namespace visualdl {

#define IMPL_ENTRY_SET_OR_ADD(method__, ctype__, dtype__, opr__)               \
  template <> void Entry<ctype__>::method__(ctype__ v) {                       \
    entry->set_dtype(storage::DataType::dtype__);                              \
    entry->opr__(v);                                                           \
  }

IMPL_ENTRY_SET_OR_ADD(Set, int32_t, kInt32, set_i32);
IMPL_ENTRY_SET_OR_ADD(Set, int64_t, kInt64, set_i64);
IMPL_ENTRY_SET_OR_ADD(Set, bool, kBool, set_b);
IMPL_ENTRY_SET_OR_ADD(Set, float, kFloat, set_f);
IMPL_ENTRY_SET_OR_ADD(Set, double, kDouble, set_d);
IMPL_ENTRY_SET_OR_ADD(Add, int32_t, kInt32s, add_i32s);
IMPL_ENTRY_SET_OR_ADD(Add, int64_t, kInt64s, add_i64s);
IMPL_ENTRY_SET_OR_ADD(Add, bool, kBools, add_bs);
IMPL_ENTRY_SET_OR_ADD(Add, float, kFloats, add_fs);
IMPL_ENTRY_SET_OR_ADD(Add, double, kDoubles, add_ds);

std::string StorageHelper::human_readable_buffer() const {
  std::string buffer;
  google::protobuf::TextFormat::PrintToString(*data_, &buffer);
  return buffer;
}

std::string TabletHelper::human_readable_buffer() const {
  std::string buffer;
  google::protobuf::TextFormat::PrintToString(*data_, &buffer);
  return buffer;
}

} // namespace visualdl