//
// C++ Interface: kalvaprofile
//
// Description: 
//
//
// Author: Andreas Silberstorff <ml@andreas-silberstorff.de>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef PROPERTYLOADER_H
#define PROPERTYLOADER_H
#include "libkalva_export.h"
#include <QMap>
#include <QString>

class QString;
class QStringList;

namespace KalvaUtil {

static const QString CHANNELLIST_TYPE = "chlst";
static const QString HARDWARE_PROFILE_TYPE = "hwprofile";
static const QString QUALITY_PROFILE_TYPE = "qprofile";

class Value
{
public:
	Value() {}
        Value( const QString& cat, const QString& val )
            : m_category(cat), m_value(val)
        { }

        inline const QString getCategory() const { return m_category; }
        inline const QString getValue() const { return m_value; }
        inline void setCategory( const QString cat ) { m_category = cat; }
        inline void setValue( const QString val )  { m_value = val; }

//private:
        QString m_category;
        QString m_value;
};

/**
represents a profile. provides getters and setters for profile data fields and read and write methods

@author Andreas Silberstorff
*/
class KALVALIB_EXPORT PropertyLoader
{
public:
	PropertyLoader( const QString& name )
	: m_type(name) {}

	virtual ~PropertyLoader() {};

	QString getDir() const;
	QString getFilename() const;
	QString getFilename( QString basename );

	QStringList readDir() const;
	bool read( const QString& filename );
	bool write( const QString& filename );

	QString getCategory( const QString& key ) const;
        Value getValue( const QString& key ) const;
	QString getValueString( const QString& key ) const;
	int getValueInt( const QString& key ) const;
	double getValueDouble( const QString& key ) const;
	float getValueFloat( const QString& key ) const;
	bool getValueBoolean( const QString& key ) const;
	void setValue( const QString& key, const QString& cat, const QString& val );

private:
	QString m_filename;
	QString m_type;
	typedef QMap<QString, Value> profileDataMap;
	profileDataMap m_profileData;
};

}

#endif
