#ifndef HISTORY
#define HISTORY

#include <string>
#include <vector>
#include "operation.hh"

/**
 * A History represents a history of transactions. It consists of a sequence of Operations that
 * are involved in this particular history.
 */
class History
{
	public:
		typedef std::vector<Operation>::const_iterator Iterator;

		History();
		~History();
		History(const std::string& text);

		/**
		 * Returns an iterator pointing at the first Operation in the history (if any).
		 * @return an iterator
		 * @see class Operation
		 */
		Iterator begin() const;

		/**
		 * Returns an iterator pointing to the position after the last element in the history.
		 * @return an iterator
		 * @see class Operation
		 */
		Iterator end() const;

		/**
		 * Parses an input string an sets the current History according to the input string.
		 * All previous content is removed from the History.
		 * @param text a textual representation of the history (e.g. r1[x],r2[x],c1,c2)
		 */
		void buildFromText(const std::string& text);

	private:
		std::vector<Operation> theOperations;
};

/**
 * Serializes the history to a textual representation
 * @param ostream the stream to write the History to
 * @param H the history to serialize
 */
std::ostream& operator<<(std::ostream& ostream, const History& H);

#endif
