#pragma once
#include "../domain/trench.h"
#include <vector>
#include "Repository.h"

class MemoryRepository : public Repository {

    public:

        /*
        * Constructor for the Repository class
        * Input: -
        * Output: repository object
        */
        MemoryRepository();

        /*
        * Destructor for the Repository class
        * Input: -
        * Output: -
        */
        ~MemoryRepository();

        /*
        * Adds a trench to the repository
        * Input: trench - trench object
        * Output: -
        * Throws: RepoException if trench already exists
        */
        void add(Trench trench) override;

        /*
        * Removes a trench from the repository
        * Input: trench - trench object
        * Output: -
        * Throws: RepoException if trench does not exist
        */
        void remove(Trench trench) override;

        /*
        * Removes a trench from the repository
        * Input: index - index of the trench
        * Output: -
        * Throws: RepoException if index is out of bounds
        */
        void remove(int index) override;

        /*
        * Returns the index of a trench in the repository
        * Input: trench - trench object
        * Output: index of the trench. -1 if trench does not exist
        */
        int get(Trench trench) override;

        /*
        * Returns a trench from the repository
        * Input: index - index of the trench
        * Output: trench object
        * Throws: RepoException if index is out of bounds
        */
        Trench& operator[](int index) override;

        /*
        * Updates a trench from the repository
        * Input: index - index of the trench
        *       price - new price
        *      quantity - new quantity
        * Output: -
        * Throws: RepoException if index is out of bounds
        */
        void update(int index, int price, int quantity) override;

        /*
        * Returns the size of the repository
        * Input: -
        * Output: size of the repository
        */
        int size() override;

        /*
        * Returns an iterator to the beginning of the repository
        * Input: -
        * Output: iterator to the beginning of the repository
        */
        std::vector<Trench>::iterator begin() override;

        /*
        * Returns an iterator to the end of the repository
        * Input: -
        * Output: iterator to the end of the repository
        */
        std::vector<Trench>::iterator end() override;

};