#pragma once
#include "../vector/vector.h"
#include "../domain/trench.h"

class Repository {
    private:
        Vector<Trench*>* _data;

    public:

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

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

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

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

        /*
        * 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);

        /*
        * 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);

        /*
        * 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);

        /*
        * 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);

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

        /*
        * Returns an iterator to the beginning of the repository
        * Input: -
        * Output: iterator to the beginning of the repository
        */
        Trench** begin();

        /*
        * Returns an iterator to the end of the repository
        * Input: -
        * Output: iterator to the end of the repository
        */
        Trench** end();

};