/**
 * @file setup_configuration.cpp
 * @author Jan Holáň, xholan11 (xholan11@vutbr.cz)
 * @brief translated with gcc version 12.2.1
 * @version 0.1
 * @date 2023-05-01
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#include "WarehousePickingOpt.h"

void BoxConfiguration::addBox(Box b, long count)
{
    this->box_types_count_vect.push_back({b, count});
    this->box_types_vect.push_back(b);
}

vector<pair<Box, int>> BoxConfiguration::getBoxesWCountVector()
{
    return this->box_types_count_vect;
}

vector<Box> BoxConfiguration::getBoxesVector()
{
    return this->box_types_vect;
}

Box BoxConfiguration::getFirstBox()
{
    return this->box_types_count_vect.size() == 0 ? Box() : this->box_types_vect[0];
}

SolverConfiguration::SolverConfiguration(
    BPAlgorithms _bp_alg,
    GroupingCustomersAlgorithms _grouping_customers_alg,
    ShortestPathAlgorithms _shortest_path_alg)
    : bp_algorithm(_bp_alg),
      grouping_customers_algorithm(_grouping_customers_alg),
      shortest_path_algorithm(_shortest_path_alg) {}

BPAlgorithms SolverConfiguration::getBPAlgorithm()
{
    return this->bp_algorithm;
}

GroupingCustomersAlgorithms SolverConfiguration::getGroupingCustomerAlgorithm()
{
    return this->grouping_customers_algorithm;
}

ShortestPathAlgorithms SolverConfiguration::getShortestPathAlgorithm()
{
    return this->shortest_path_algorithm;
}

CartConfiguration::CartConfiguration(float _cart_width, float _cart_height, float _cart_depth, float _usable_capacity, int _number_of_shelves)
    : cart_width(_cart_width),
      cart_height(_cart_height),
      cart_depth(_cart_depth),
      usable_capacity(_usable_capacity),
      number_of_shelves(_number_of_shelves)
{

    // create vector of shelves
    vector<CartShelf> cart_shelf_vect;
    for (int i = 0; i < number_of_shelves; i++)
    {
        cart_shelf_vect.push_back(CartShelf(cart_width, cart_height / number_of_shelves, cart_depth));
    }

    // create cart
    this->cart_pattern.push_back(Cart(cart_shelf_vect));
}

Cart CartConfiguration::getCartPattern()
{
    return this->cart_pattern[0];
}

void CartConfiguration::removeCartShelves()
{
    this->cart_shelf_vect.clear();
}

void CartConfiguration::addCartShelf(float _shelf_width, float _shelf_height, float _shelf_depth, float _usable_capacity)
{
    // TODO use usable_capacity of shelf
    (void)_usable_capacity;
    this->cart_shelf_vect.push_back(CartShelf(_shelf_width, _shelf_height, _shelf_depth));

    // rebuild the cart
    this->cart_pattern.push_back(Cart(cart_shelf_vect));
}

