44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
#pragma once
|
|
#include <array>
|
|
#include <atomic>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include "../base/Time_Of_Day.h"
|
|
#include "global.h"
|
|
namespace renderive {
|
|
struct Timeline_Tick {
|
|
Time_Of_Day time;
|
|
int tick{};
|
|
};
|
|
struct LIB_DECL Timeline_Stream_Snapshot {
|
|
std::uint64_t version{};
|
|
bool start_coord_to_end_coord = false;
|
|
int lower{};
|
|
int time_point_size = 1;
|
|
int lower_stream_tick{};
|
|
int upper_stream_tick = -1;
|
|
std::vector<Time_Of_Day> times;
|
|
std::vector<Timeline_Tick> ticks;
|
|
[[nodiscard]] int upper() const;
|
|
[[nodiscard]] bool coord_by_stream_tick(int stream_tick, int& coord) const;
|
|
[[nodiscard]] Time_Of_Day time_by_tick(int tick) const;
|
|
};
|
|
class LIB_DECL Timeline_Stream {
|
|
public:
|
|
Timeline_Stream();
|
|
int push_time(Time_Of_Day time);
|
|
[[nodiscard]] Timeline_Stream_Snapshot capture(int time_point_size, int tick_space, bool start_coord_to_end_coord) const;
|
|
private:
|
|
struct Sample {
|
|
std::uint64_t sequence{};
|
|
int tick{};
|
|
Time_Of_Day time;
|
|
};
|
|
static constexpr std::size_t Max_Buffered_Time_Count = 65536;
|
|
std::array<std::atomic<std::shared_ptr<const Sample>>, Max_Buffered_Time_Count> time_slots;
|
|
std::atomic<std::uint64_t> write_sequence{0};
|
|
std::atomic<int> next_tick_value{0};
|
|
};
|
|
}
|