/*
Copyright (C) 2006 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 SYMBOLMANAGER_20060814_H_
#define SYMBOLMANAGER_20060814_H_

#include <QString>
#include <QMap>
#include <QList>
#include <QSet>
#include "types.h"

class SymbolManager {
public:
	SymbolManager(const QString &symbolDirectory);

	struct Symbol {
		QString					file;
		QString					name;
		BaseTypes::address_t	address;
		uint32_t				size;
	};
	
	const Symbol *findSymbol(const QString &name) const;
	const Symbol *findSymbol(BaseTypes::address_t address) const;
	const Symbol *findNearSymbol(BaseTypes::address_t address) const;
	
	void loadSymbolFile(const QString &filename, BaseTypes::address_t base);
	
private:
	bool processSymbolFile(const QString &f, BaseTypes::address_t base);
	
private:
	QString m_SymbolDirectory;

	QSet<QString>								m_SymbolFiles;
	QList<Symbol>								m_Symbols;
	QMap<BaseTypes::address_t, const Symbol *>	m_SymbolsByAddress;
	QMap<QString, const Symbol *>				m_SymbolsByName;
};

#endif

