#pragma once

#include "utility.h"
#include <Entities/Entity.h>

class EntityView;

class EntityViewIterator
{
	friend class EntityView;

	EntityViewIterator(EntityIndex);

	EntityViewIterator& operator++();

	EntityViewIterator operator++(int);

	EntityViewIterator& operator--();

	EntityViewIterator operator--(int);

	Entity operator*();

	Entity operator[](int);

	bool operator==(EntityViewIterator);
	bool operator!=(EntityViewIterator);

private:
	EntityIndex m_currentEntity;
};

class EntityViewConstIterator
{
	friend class EntityView;
	
	EntityViewConstIterator(EntityIndex index);

	EntityViewConstIterator& operator++();

	EntityViewConstIterator operator++(int);

	EntityViewConstIterator& operator--();

	EntityViewConstIterator operator--(int);

	const Entity operator*();

	const Entity operator[](int index);


	bool operator==(EntityViewConstIterator);
	bool operator!=(EntityViewConstIterator);

private:
	EntityIndex m_currentEntity;
};

class EntityView
{
public:
	friend class EntityManager;
	EntityView() = delete;
	EntityView(EntityIndex, EntityIndex);

	using iterator = EntityViewIterator;
	using const_iterator = EntityViewConstIterator;

	iterator begin() { return iterator(m_start); }
	iterator end()   { return iterator(m_start + m_size); }

	const_iterator cbegin() const { return const_iterator(m_start); }
	const_iterator cend()   const { return const_iterator(m_start + m_size); }
private:
	EntityIndex m_start;
	EntityIndex m_size;
};

