/***************************************************************************
 * chordanalyzer.h: implementation of ChordAnalyzer class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KGuitar development team <mrgwen@gmail.com>
 * copyright (C) 2002-2003 the KGuitar development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#ifndef CHORDANALYZER_H
#define CHORDANALYZER_H

#include <QString>

class ChordAnalyzer {
public:
	/**
		Construct the chord analyser.
		\param name of the chord.
	*/
	ChordAnalyzer(const QString& name);
	
	~ChordAnalyzer();

	/**
		Check if the chord is correct.
		\return true if it's correct
	*/
	bool analyze();
	
	/**
		Get the error message.
		\return the error message
	*/
	QString message() const;
	
	/**
		Get the chord information.
		\param i the step number
		\return the step information (contains the chord decoded)
	*/
	int getStep(uchar i) const;
	
	/**
		Get the tonic of the chord.
		\return the tonic
	*/
	int getTonic() const;
private:
	/**
		Checks if the sample string comes next in the line of analyze
	*/
	bool checkNext(const QString& sample);
	
	/**
		Sets and fixes the step "index" to value "value", if still not
		fixed. If already fixed, bails out complaining about "reason"
	*/
	bool setStep(int step, int value, const QString& reason);
	
	QString mName;
	bool mFixed[6];
	int mPos;
	int mTonic;
	int mStep[6];
	QString mMessage;
};

#endif
