#include <stdexcept>
#include <string>
#include <componentThread.h>

namespace smo {

std::string getThreadName(sscl::ThreadId id)
{
	// Cast ThreadId to SmoThreadId for validation and lookup
	smo::SmoThreadId smoId = static_cast<smo::SmoThreadId>(id);
	if (static_cast<int>(smoId) >= static_cast<int>(smo::SmoThreadId::N_ITEMS))
	{
		throw std::runtime_error(std::string(__func__)
			+ ": Invalid thread ID");
	}

	// Use function-local static to ensure proper construction order.
	static const std::string threadNames[static_cast<int>(smo::SmoThreadId::N_ITEMS)]
	= {
		"mrntt",
		"director",
		"simulator",
		"subconscious",
		"body",
		"world"
	};

	return threadNames[static_cast<int>(smoId)];
}

} // namespace smo
