/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#pragma once

#include <source_location>

#include <ox/std/error.hpp>

namespace studio {

class NoChangesException: public ox::Exception {
	public:
		explicit NoChangesException(std::source_location sloc = std::source_location::current()):
				ox::Exception(1, "Command makes no changes.", sloc) {}
};

class UndoCommand {
	private:
		bool m_obsolete{};
	public:
		virtual ~UndoCommand() noexcept = default;
		virtual ox::Error redo() noexcept = 0;
		virtual ox::Error undo() noexcept = 0;
		[[nodiscard]]
		virtual int commandId() const noexcept = 0;
		virtual bool mergeWith(UndoCommand &cmd) noexcept;
		constexpr void setObsolete(bool obsolete) noexcept {
			m_obsolete = obsolete;
		}
		[[nodiscard]]
		constexpr bool isObsolete() const noexcept {
			return m_obsolete;
		}
};

}
