using Machinations.FromFlash.machinations.model;

namespace Machinations.Status
{
    public class RegisterStatus : IElementStatus
    {
        private int m_value;
        private Register m_register;
        private readonly int m_step;

        public RegisterStatus(Register register, int step)
        {
            m_register = register;
            m_step = step;
            m_value = register.Value;
        }

        public int Step
        {
            get { return m_step; }
        }

        public void Restore()
        {
            m_register.Value = m_value;
            m_register.OnChanged("Status restored");
        }

        public bool NeedNewStatus()
        {
            return !m_value.Equals(m_register.Value);
        }
    }
}