/*  This file is part of the KDE project
    Copyright (C) 2007 Matthias Kretz <kretz@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License version 2 as published by the Free Software Foundation.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

*/

#ifndef PHONON_MIXERCONTROL_P_H
#define PHONON_MIXERCONTROL_P_H

#include "mixercontrol.h"
#include "mixercontrolset.h"
#include "mixer_p.h"
#include "alsaclasses.h"

#include <QtCore/QExplicitlySharedDataPointer>
#include <QtCore/QObject>
#include <QtCore/QSharedData>

class QStringList;
class QString;
class QVariant;

namespace Phonon
{
namespace Mixer
{

class MixerControlSharedData : public QObject, public QSharedData
{
    friend class MixerControl;
    friend class MixerControlPrivate;
    friend class MixerSharedData;
    friend class Mixer;
    Q_OBJECT
    public:
        MixerControlSharedData(const MixerSharedData::Ptr &mixer, const AlsaElementId &id);
        typedef QExplicitlySharedDataPointer<MixerControlSharedData> Ptr;

        ~MixerControlSharedData() {}

        virtual void valueChangeEvent() = 0;
        virtual void extraInfoChangeEvent();

    protected:
        bool operator<(const MixerControlSharedData &rhs) const;
        bool isValid() const;
        int id() const;

        AlsaElementId m_id;
        mutable AlsaElementValue m_value;
        MixerControl::Type m_type;
        unsigned int m_index;
        MixerSharedData::Ptr m_mixer;
        bool m_isVolatile;
        MixerControlSet m_controlSet;
        QString m_extraInfo;
};

class MixerControlPrivate
{
    friend class MixerSharedData;
    friend class Mixer;
    Q_DECLARE_PUBLIC(MixerControl)
    K_DECLARE_SHARED(MixerControl)
    protected:
        MixerControl *q_ptr;
        virtual ~MixerControlPrivate() {}

        MixerControlSharedData::Ptr s_ptr;

    public:
        MixerControlPrivate(const MixerControlSharedData::Ptr &);
        void invalidate();
};

} // namespace Mixer
} // namespace Phonon

#endif // PHONON_MIXERCONTROL_P_H
