/*
Copyright (C) 2006 - 2009 Evan Teran
                   eteran@alum.rit.edu

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef REGISTER_200100329_H_
#define REGISTER_200100329_H_

#include "Types.h"
#include "API.h"
#include <QString>

class EDB_EXPORT Register {
public:
	enum Type{		
		// groups, these catagories should remain as portable as possible
		TYPE_GPR	= 0x0001,
		TYPE_IP		= 0x0002,
		TYPE_SEG	= 0x0004,
		TYPE_COND	= 0x0008,
		TYPE_FPU	= 0x0010,
		TYPE_ANY	= -1	// it can never be one of these
	};
	
public:
	Register();
	Register(const QString &name, edb::reg_t value, Type type, edb::address_t segmentBase = 0);
	Register(const Register &other);
	Register &operator=(const Register &rhs);
	
public:
	bool operator==(const Register &rhs) const;
	bool operator!=(const Register &rhs) const;
	
public:
	bool valid() const					{ return m_Valid; }
	QString name() const				{ return m_Name; }
	edb::reg_t value() const			{ return m_Value; }
	bool isType(quint32 mask) const		{ return (m_Type & mask) != 0; }
	edb::address_t segmentBase() const	{ return m_SegmentBase; } // this only makes sense for TYPE_SEG

private:
	bool			m_Valid;
	QString			m_Name;
	edb::reg_t		m_Value;
	Type			m_Type;
	edb::address_t	m_SegmentBase;
};

#endif
