#ifndef WAREHOUSE_H
#define WAREHOUSE_H
#include <vector>
#include <mutex>
#include <iostream>
#include "../Ask1/Product.h"
using namespace std;

class Warehouse{
	private:
		vector<Product> secureStorage;
		mutex doorLock;
	public:
		Warehouse();
		void storeFinishedProduct(Product p, string threadName);
		void printFinalInventory();
};

Warehouse::Warehouse(){
	cout<<"[WAREHOUSE] Central storage facility is officially open."<<endl;
}

void Warehouse::storeFinishedProduct(Product p, string threadName){
	lock_guard<mutex> guard(doorLock);
	secureStorage.push_back(p);
	cout<<"[WAREHOUSE LOG] "<<threadName<<" securely deposited Product ID: "<<p.getId()<<" into central storage."<<endl;
}

void Warehouse::printFinalInventory(){
	cout<<"\n========================================"<<endl;
	cout<<"       FINAL WAREHOUSE INVENTORY       "<<endl;
	cout<<"Total Products Secured: "<<secureStorage.size()<<endl;
	cout<<"========================================"<<endl;
}





#endif
