#ifndef _LIVOX_GEN1_FRAME_ASSEMBLY_DESC_H
#define _LIVOX_GEN1_FRAME_ASSEMBLY_DESC_H

#include <cstddef>
#include <cstdint>
#include <vector>
#include <string>
#include <sstream>

namespace smo {
namespace stim_buff {

class FrameAssemblyDesc
{
public:
	struct SlotDesc
	{
		size_t offsetBytes;      // offset from frame base
		uint8_t* vaddr;          // direct pointer into StagingBuffer memory
		size_t nBytes;           // slot capacity in bytes
	};

public:	
	FrameAssemblyDesc() = default;

	FrameAssemblyDesc(
		size_t n, size_t slotSize,
		size_t frameStride,
		std::vector<SlotDesc> slotList)
		: numSlots(n), slotSizeBytes(slotSize),
		frameStrideBytes(frameStride),
		slots(std::move(slotList)) {}

	inline std::string stringify() const {
		std::ostringstream oss;
		oss << "FrameAssemblyDesc{"
			<< "numSlots=" << numSlots
			<< ", slotSizeBytes=" << slotSizeBytes
			<< ", frameStrideBytes=" << frameStrideBytes
			<< ", slots=[";
		const size_t preview = slots.size() < 4 ? slots.size() : 4;
		for (size_t i = 0; i < preview; ++i) {
			oss << "{off=" << slots[i].offsetBytes
				<< ", nBytes=" << slots[i].nBytes
				<< ", vaddr=" << (const void*)slots[i].vaddr << "}";
			if (i + 1 < preview) oss << ",";
		}
		if (slots.size() > preview) oss << ", ...";
		oss << "]}";
		return oss.str();
	}

public:
	size_t numSlots;
	size_t slotSizeBytes;
	size_t frameStrideBytes;
	std::vector<SlotDesc> slots;
};

} // namespace stim_buff
} // namespace smo

#endif // _LIVOX_GEN1_FRAME_ASSEMBLY_DESC_H

