// automatically generated by the FlatBuffers compiler, do not modify

#ifndef FLATBUFFERS_GENERATED_DEPTHFRAME_DV_H_
#define FLATBUFFERS_GENERATED_DEPTHFRAME_DV_H_

#include "../external/flatbuffers/flatbuffers.h"

#include <fmt/chrono.h>
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <fmt/ranges.h>

namespace dv {

struct DepthFrameFlatbuffer;
struct DepthFrame;

bool operator==(const DepthFrame &lhs, const DepthFrame &rhs);

inline const flatbuffers::TypeTable *DepthFrameTypeTable();

struct DepthFrame : public flatbuffers::NativeTable {
	typedef DepthFrameFlatbuffer TableType;

	static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
		return "dv.DepthFrame";
	}

	int64_t timestamp;
	int16_t sizeX;
	int16_t sizeY;
	uint16_t minDepth;
	uint16_t maxDepth;
	uint16_t step;
	std::vector<uint16_t> depth;

	DepthFrame() : timestamp(0), sizeX(0), sizeY(0), minDepth(0), maxDepth(65535), step(1) {
	}

	// Generated Constructor
	DepthFrame(int64_t _timestamp, int16_t _sizeX, int16_t _sizeY, uint16_t _minDepth, uint16_t _maxDepth,
		uint16_t _step, const std::vector<uint16_t> &_depth) :
		timestamp{_timestamp},
		sizeX{_sizeX},
		sizeY{_sizeY},
		minDepth{_minDepth},
		maxDepth{_maxDepth},
		step{_step},
		depth{_depth} {
	}

	friend std::ostream &operator<<(std::ostream &os, const DepthFrame &frame) {
		os << fmt::format("DepthFrame with dimensions [{}x{}] at time {}", frame.sizeX, frame.sizeY, frame.timestamp);
		return os;
	}
};

inline bool operator==(const DepthFrame &lhs, const DepthFrame &rhs) {
	return (lhs.timestamp == rhs.timestamp) && (lhs.sizeX == rhs.sizeX) && (lhs.sizeY == rhs.sizeY)
		&& (lhs.minDepth == rhs.minDepth) && (lhs.maxDepth == rhs.maxDepth) && (lhs.step == rhs.step)
		&& (lhs.depth == rhs.depth);
}

/// A frame containing pixel depth values in millimeters.
struct DepthFrameFlatbuffer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
	typedef DepthFrame NativeTableType;
	static FLATBUFFERS_CONSTEXPR const char *identifier = "DFRM";

	static const flatbuffers::TypeTable *MiniReflectTypeTable() {
		return DepthFrameTypeTable();
	}

	static FLATBUFFERS_CONSTEXPR const char *GetFullyQualifiedName() {
		return "dv.DepthFrame";
	}

	enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
		VT_TIMESTAMP = 4,
		VT_SIZEX     = 6,
		VT_SIZEY     = 8,
		VT_MINDEPTH  = 10,
		VT_MAXDEPTH  = 12,
		VT_STEP      = 14,
		VT_DEPTH     = 16
	};

	/// Central timestamp (µs), corresponds to exposure midpoint.
	int64_t timestamp() const {
		return GetField<int64_t>(VT_TIMESTAMP, 0);
	}

	/// Start of Frame (SOF) timestamp.
	int16_t sizeX() const {
		return GetField<int16_t>(VT_SIZEX, 0);
	}

	/// Y axis length in pixels.
	int16_t sizeY() const {
		return GetField<int16_t>(VT_SIZEY, 0);
	}

	/// Minimum valid depth value.
	uint16_t minDepth() const {
		return GetField<uint16_t>(VT_MINDEPTH, 0);
	}

	/// Maximum valid depth value.
	uint16_t maxDepth() const {
		return GetField<uint16_t>(VT_MAXDEPTH, 65535);
	}

	/// Depth step value, minimal depth distance that can be measured by the sensor setup.
	uint16_t step() const {
		return GetField<uint16_t>(VT_STEP, 1);
	}

	/// Depth values, unsigned 16bit integers, millimeters from the camera frame, following the OpenNI standard.
	/// Depth value of 0 should be considered an invalid value.
	const flatbuffers::Vector<uint16_t> *depth() const {
		return GetPointer<const flatbuffers::Vector<uint16_t> *>(VT_DEPTH);
	}

	bool Verify(flatbuffers::Verifier &verifier) const {
		return VerifyTableStart(verifier) && VerifyField<int64_t>(verifier, VT_TIMESTAMP)
			&& VerifyField<int16_t>(verifier, VT_SIZEX) && VerifyField<int16_t>(verifier, VT_SIZEY)
			&& VerifyField<uint16_t>(verifier, VT_MINDEPTH) && VerifyField<uint16_t>(verifier, VT_MAXDEPTH)
			&& VerifyField<uint16_t>(verifier, VT_STEP) && VerifyOffset(verifier, VT_DEPTH)
			&& verifier.VerifyVector(depth()) && verifier.EndTable();
	}

	DepthFrame *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const;
	void UnPackTo(DepthFrame *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const;
	static void UnPackToFrom(
		DepthFrame *_o, const DepthFrameFlatbuffer *_fb, const flatbuffers::resolver_function_t *_resolver = nullptr);
	static flatbuffers::Offset<DepthFrameFlatbuffer> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DepthFrame *_o,
		const flatbuffers::rehasher_function_t *_rehasher = nullptr);
};

struct DepthFrameBuilder {
	flatbuffers::FlatBufferBuilder &fbb_;
	flatbuffers::uoffset_t start_;

	void add_timestamp(int64_t timestamp) {
		fbb_.AddElement<int64_t>(DepthFrameFlatbuffer::VT_TIMESTAMP, timestamp, 0);
	}

	void add_sizeX(int16_t sizeX) {
		fbb_.AddElement<int16_t>(DepthFrameFlatbuffer::VT_SIZEX, sizeX, 0);
	}

	void add_sizeY(int16_t sizeY) {
		fbb_.AddElement<int16_t>(DepthFrameFlatbuffer::VT_SIZEY, sizeY, 0);
	}

	void add_minDepth(uint16_t minDepth) {
		fbb_.AddElement<uint16_t>(DepthFrameFlatbuffer::VT_MINDEPTH, minDepth, 0);
	}

	void add_maxDepth(uint16_t maxDepth) {
		fbb_.AddElement<uint16_t>(DepthFrameFlatbuffer::VT_MAXDEPTH, maxDepth, 65535);
	}

	void add_step(uint16_t step) {
		fbb_.AddElement<uint16_t>(DepthFrameFlatbuffer::VT_STEP, step, 1);
	}

	void add_depth(flatbuffers::Offset<flatbuffers::Vector<uint16_t>> depth) {
		fbb_.AddOffset(DepthFrameFlatbuffer::VT_DEPTH, depth);
	}

	explicit DepthFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
		start_ = fbb_.StartTable();
	}

	DepthFrameBuilder &operator=(const DepthFrameBuilder &);

	flatbuffers::Offset<DepthFrameFlatbuffer> Finish() {
		const auto end = fbb_.EndTable(start_);
		auto o         = flatbuffers::Offset<DepthFrameFlatbuffer>(end);
		return o;
	}
};

inline flatbuffers::Offset<DepthFrameFlatbuffer> CreateDepthFrame(flatbuffers::FlatBufferBuilder &_fbb,
	int64_t timestamp = 0, int16_t sizeX = 0, int16_t sizeY = 0, uint16_t minDepth = 0, uint16_t maxDepth = 65535,
	uint16_t step = 1, flatbuffers::Offset<flatbuffers::Vector<uint16_t>> depth = 0) {
	DepthFrameBuilder builder_(_fbb);
	builder_.add_timestamp(timestamp);
	builder_.add_depth(depth);
	builder_.add_step(step);
	builder_.add_maxDepth(maxDepth);
	builder_.add_minDepth(minDepth);
	builder_.add_sizeY(sizeY);
	builder_.add_sizeX(sizeX);
	return builder_.Finish();
}

inline flatbuffers::Offset<DepthFrameFlatbuffer> CreateDepthFrameDirect(flatbuffers::FlatBufferBuilder &_fbb,
	int64_t timestamp = 0, int16_t sizeX = 0, int16_t sizeY = 0, uint16_t minDepth = 0, uint16_t maxDepth = 65535,
	uint16_t step = 1, const std::vector<uint16_t> *depth = nullptr) {
	auto depth__ = depth ? _fbb.CreateVector<uint16_t>(*depth) : 0;
	return dv::CreateDepthFrame(_fbb, timestamp, sizeX, sizeY, minDepth, maxDepth, step, depth__);
}

flatbuffers::Offset<DepthFrameFlatbuffer> CreateDepthFrame(flatbuffers::FlatBufferBuilder &_fbb, const DepthFrame *_o,
	const flatbuffers::rehasher_function_t *_rehasher = nullptr);

inline DepthFrame *DepthFrameFlatbuffer::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
	auto _o = new DepthFrame();
	UnPackTo(_o, _resolver);
	return _o;
}

inline void DepthFrameFlatbuffer::UnPackTo(DepthFrame *_o, const flatbuffers::resolver_function_t *_resolver) const {
	(void) _o;
	(void) _resolver;
	UnPackToFrom(_o, this, _resolver);
}

inline void DepthFrameFlatbuffer::UnPackToFrom(
	DepthFrame *_o, const DepthFrameFlatbuffer *_fb, const flatbuffers::resolver_function_t *_resolver) {
	(void) _o;
	(void) _fb;
	(void) _resolver;
	{
		auto _e       = _fb->timestamp();
		_o->timestamp = _e;
	};
	{
		auto _e   = _fb->sizeX();
		_o->sizeX = _e;
	};
	{
		auto _e   = _fb->sizeY();
		_o->sizeY = _e;
	};
	{
		auto _e      = _fb->minDepth();
		_o->minDepth = _e;
	};
	{
		auto _e      = _fb->maxDepth();
		_o->maxDepth = _e;
	};
	{
		auto _e  = _fb->step();
		_o->step = _e;
	};
	{
		auto _e = _fb->depth();
		if (_e) {
			_o->depth.resize(_e->size());
			for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) {
				_o->depth[_i] = _e->Get(_i);
			}
		}
	};
}

inline flatbuffers::Offset<DepthFrameFlatbuffer> DepthFrameFlatbuffer::Pack(
	flatbuffers::FlatBufferBuilder &_fbb, const DepthFrame *_o, const flatbuffers::rehasher_function_t *_rehasher) {
	return CreateDepthFrame(_fbb, _o, _rehasher);
}

inline flatbuffers::Offset<DepthFrameFlatbuffer> CreateDepthFrame(
	flatbuffers::FlatBufferBuilder &_fbb, const DepthFrame *_o, const flatbuffers::rehasher_function_t *_rehasher) {
	(void) _rehasher;
	(void) _o;

	struct _VectorArgs {
		flatbuffers::FlatBufferBuilder *__fbb;
		const DepthFrame *__o;
		const flatbuffers::rehasher_function_t *__rehasher;
	} _va = {&_fbb, _o, _rehasher};

	(void) _va;
	auto _timestamp = _o->timestamp;
	auto _sizeX     = _o->sizeX;
	auto _sizeY     = _o->sizeY;
	auto _minDepth  = _o->minDepth;
	auto _maxDepth  = _o->maxDepth;
	auto _step      = _o->step;
	auto _depth     = _o->depth.size() ? _fbb.CreateVector(_o->depth.data(), _o->depth.size()) : 0;
	return dv::CreateDepthFrame(_fbb, _timestamp, _sizeX, _sizeY, _minDepth, _maxDepth, _step, _depth);
}

inline const flatbuffers::TypeTable *DepthFrameTypeTable() {
	static const flatbuffers::TypeCode type_codes[] = {
		{flatbuffers::ET_LONG,   0, -1},
        {flatbuffers::ET_SHORT,  0, -1},
        {flatbuffers::ET_SHORT,  0, -1},
		{flatbuffers::ET_USHORT, 0, -1},
        {flatbuffers::ET_USHORT, 0, -1},
        {flatbuffers::ET_USHORT, 0, -1},
		{flatbuffers::ET_USHORT, 1, -1}
    };
	static const char *const names[]       = {"timestamp", "sizeX", "sizeY", "minDepth", "maxDepth", "step", "depth"};
	static const flatbuffers::TypeTable tt = {flatbuffers::ST_TABLE, 7, type_codes, nullptr, nullptr, names};
	return &tt;
}

inline const dv::DepthFrameFlatbuffer *GetDepthFrame(const void *buf) {
	return flatbuffers::GetRoot<dv::DepthFrameFlatbuffer>(buf);
}

inline const dv::DepthFrameFlatbuffer *GetSizePrefixedDepthFrame(const void *buf) {
	return flatbuffers::GetSizePrefixedRoot<dv::DepthFrameFlatbuffer>(buf);
}

inline const char *DepthFrameIdentifier() {
	return "DFRM";
}

inline bool DepthFrameBufferHasIdentifier(const void *buf) {
	return flatbuffers::BufferHasIdentifier(buf, DepthFrameIdentifier());
}

inline bool VerifyDepthFrameBuffer(flatbuffers::Verifier &verifier) {
	return verifier.VerifyBuffer<dv::DepthFrameFlatbuffer>(DepthFrameIdentifier());
}

inline bool VerifySizePrefixedDepthFrameBuffer(flatbuffers::Verifier &verifier) {
	return verifier.VerifySizePrefixedBuffer<dv::DepthFrameFlatbuffer>(DepthFrameIdentifier());
}

inline void FinishDepthFrameBuffer(
	flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<dv::DepthFrameFlatbuffer> root) {
	fbb.Finish(root, DepthFrameIdentifier());
}

inline void FinishSizePrefixedDepthFrameBuffer(
	flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<dv::DepthFrameFlatbuffer> root) {
	fbb.FinishSizePrefixed(root, DepthFrameIdentifier());
}

inline std::unique_ptr<DepthFrame> UnPackDepthFrame(
	const void *buf, const flatbuffers::resolver_function_t *res = nullptr) {
	return std::unique_ptr<DepthFrame>(GetDepthFrame(buf)->UnPack(res));
}

} // namespace dv

// fmt compatibility for ostream class printing.
template<>
struct fmt::formatter<dv::DepthFrame> : fmt::ostream_formatter {};

#endif // FLATBUFFERS_GENERATED_DEPTHFRAME_DV_H_
