#pragma once

/*
	ApplicationFramework
	by John Ryland
	Copyright (c) 2023
*/

////////////////////////////////////////////////////////////////////////////////////
//	Collection Interface

#include <vector>
#include <memory>
#include <algorithm>
#include <functional>

namespace ApplicationFramework {

template <typename InterfaceType>
class ICollection : public InterfaceType
{
public:
    void AddItem(std::unique_ptr<InterfaceType>&& newItem)
    {
        m_items.emplace_back(std::move(newItem));
    }

    template <typename Function>
    void Apply(Function&& func)
    {
        std::for_each(m_items.begin(), m_items.end(), std::move(func));
    }

    template <typename Function>
    void ApplyReverse(Function&& func)
    {
        std::for_each(m_items.rbegin(), m_items.rend(), std::move(func));
    }

private:
    std::vector<std::unique_ptr<InterfaceType>> m_items;
};

} // ApplicationFramework namespace
