2d-platformer/include/Entities/EntityView.h

58 lines
1.2 KiB
C++

#pragma once
#include "utility.h"
#include <Entities/Entity.h>
class EntityView
{
public:
friend class EntityManager;
EntityView() = delete;
EntityView(EntityIndex, EntityIndex);
class iterator
{
public:
iterator(EntityIndex);
iterator& operator++();
iterator operator++(int);
iterator& operator--();
iterator operator--(int);
Entity operator*();
Entity operator[](int);
bool operator==(iterator);
bool operator!=(iterator);
private:
EntityIndex m_currentEntity;
};
class const_iterator
{
public:
const_iterator(EntityIndex index);
const_iterator& operator++();
const_iterator operator++(int);
const_iterator& operator--();
const_iterator operator--(int);
const Entity operator*();
const Entity operator[](int index);
bool operator==(const_iterator);
bool operator!=(const_iterator);
private:
EntityIndex m_currentEntity;
};
Entity operator[](EntityIndex) const;
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;
};