/*****************************************************************//**
 * \file   Constraint.h
 * \brief  A generic constraint interface to store the specific constraint wheither it is a branching constraint or a cut constraint.
 *
 * \author Matteo Petris
 * \date   February 2023
 *********************************************************************/
#ifndef ARCBRANCHCONSTRAINT_H
#define ARCBRANCHCONSTRAINT_H

#include "Constraint.h"

template<class Type>
class ArcBranchConstraint: public Constraint<Type> {

protected:

	pair<int, int> items;

public:
	/**
	 * Constructor by default.
	 *
	 */
	ArcBranchConstraint() :Constraint<Type>(), items() {
	}


	/**
	 * Constructor with the left hand side, the right hand side and the operator of the constraint.
	 *
	 * \param variables_indexes: vector<int>&
	 * \param rhs: double
	 * \param _operator: const string&
	 */
	ArcBranchConstraint(double rhs, const string& _operator, const pair<int,int>& items, const string& name = "") :
		Constraint<Type>(rhs, _operator, name), items(items) {
	}

	/**
	 * Destructor.
	 *
	 */
	virtual ~ArcBranchConstraint() {
	}

	/**
	 * Get method of items.
	 *
	 * \return items: const pair<int, int>&
	 */
	const pair<int, int>& get_items() const {
		return this->items;
	}

	/**
	 * Get method of items.
	 *
	 * \return items: const pair<int, int>&
	 */
	void set_name(const pair<int, int>& new_items) const {
		this->items = new_items;
	}

	string to_string() const {
		stringstream mystring;
		mystring << "(" << this->items.first << "," << this->items.second << "), ";
		mystring << Constraint<Type>::to_string();
		return mystring.str();
	}

	string toString() const {
		string mystring;
		mystring += "ARC (" + std::to_string(this->items.first) + "," + std::to_string(this->items.second) + "), RHS " + std::to_string(this->rhs) + "\n";
		return mystring;
	}

	/**
	*  \brief	 Get a string for debug output.
	*  \param    out : ostream
	*  \param    constraint : const ArcBranchConstraint<Type>&
	*  \return   The stream with the message ID added : ostream
	*/
	friend ostream& operator<<(ostream& out, const ArcBranchConstraint<Type>& constraint) {
		out << constraint.to_string();
		return out;
	}
};
#endif //ARCBRANCHCONSTRAINT_H
