#include "operation.hh"
#include <sstream>

Operation::Operation(OperationKind kind, char element, unsigned short transactionID) :
	theKind(kind), theElement(element), theTransactionID(transactionID) {}

Operation::Operation(const Operation& operation) : theKind(operation.theKind),
	theElement(operation.theElement), theTransactionID(operation.theTransactionID){}

Operation::~Operation(){}

std::string Operation::getText() const
{
	std::stringstream result;
	if(theKind==READ)
		result<<"r"<<theTransactionID<<"["<<theElement<<"]";
	else if(theKind==WRITE)
		result<<"w"<<theTransactionID<<"["<<theElement<<"]";
	else if(theKind==COMMIT)
		result<<"c"<<theTransactionID;
	else if(theKind==ABORT)
		result<<"a"<<theTransactionID;

	return result.str();
}

