/*
    knetd, KDE Network Daemon

    Copyright (c) 2005 by Engin AYDOGAN		<engin @ bzzzt.biz>

    *************************************************************************
    *                                                                       *
    * 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.                                   *
    *                                                                       *
    *************************************************************************
*/

#ifndef ATTRIBUTE_H_
#define ATTRIBUTE_H_

#include <qmap.h>

#include "sysfs_global.h"

/**
 * This class represents one attribute of a device
 */
class Attribute
{
public:
	Attribute();
	/**
	 * Constructs the attribute. Builds Qt types of attribute data.
	 * @param attr pointer to sysfs_attribute object
	 */
	Attribute( sysfs_attribute* attr );

	/**
	 * Rereads the attribute data.
	 */
	void
	reRead();

	/**
	 * @return true if the attribute is writable
	 */
	bool
	isWritable() const;

	/**
	 * @return true if the attribute is readable
	 */
	bool
	isReadable() const;

	/**
	 * Assigns value val to the attribute if writeable. No error checking
	 * is done.
	 * @param val new value to assign to the attribute
	 * @return reference to this attribute itself
	 */
	Attribute&
	operator= ( const QString& val );

	/**
	 * @return true if the values match
	 */
	bool
	operator== ( const QString& val ) const;

	/**
	 * @return name of the attribute, i.e. key.
	 */
	QString
	name() const;

	/**
	 * @return value of the attribute
	 */
	QString
	value() const;
private:
	QString m_name;
	QString m_path;
	QString m_value;
	unsigned short m_method;
};

typedef QMap<QString,Attribute> AttributeList;

#endif
