tsdb.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #ifndef TSDB_CPP_HPP
  3. #define TSDB_CPP_HPP
  4. #include <cstdio>
  5. #include <cstring>
  6. #include <memory>
  7. #include <string_view>
  8. #include <vector>
  9. #ifdef _WIN32
  10. #define TSDB_EXPORT __declspec(dllexport)
  11. #else
  12. #define TSDB_EXPORT
  13. #endif
  14. TSDB_EXPORT void tsdb();
  15. TSDB_EXPORT void tsdb_print_vector(const std::vector<std::string>& strings);
  16. namespace tsdb_cpp {
  17. /// @brief A point in time series database.
  18. struct point {
  19. const std::string& name_;
  20. double value_;
  21. long long nanoseconds_;
  22. point(const std::string& name, double value, long long nanoseconds) : name_(name), value_(value), nanoseconds_(nanoseconds) {}
  23. };
  24. struct tsdb_entry_impl;
  25. /// @brief A time series database.
  26. struct tsdb_entry {
  27. tsdb_entry(std::string_view remote);
  28. ~tsdb_entry();
  29. tsdb_entry(tsdb_entry&& other);
  30. void close();
  31. void create_table();
  32. void create_memory_table();
  33. void drop_table();
  34. void drop_memory_table();
  35. void set_active_table(std::string_view table_name);
  36. void set_metric_name(std::string_view metric_name);
  37. void insert_point(const point& p);
  38. void insert_points(const std::vector<point>& points);
  39. private:
  40. std::unique_ptr<tsdb_entry_impl> impl_;
  41. };
  42. } // namespace tsdb_cpp
  43. #endif // TSDB_CPP_HPP