add mp3 and ogg torrent url info to JamendoAlbum
[amarok.git] / src / engineobserver.h
blob752c527ec957836c927c6282c843f97517878b84
1 /***************************************************************************
2 engineobserver.h - Observer pattern for engine
3 -------------------
4 begin : Mar 14 2003
5 copyright : (C) 2003 by Frederik Holljen
6 email : fh@ez.no
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef AMAROK_ENGINEOBSERVER_H
19 #define AMAROK_ENGINEOBSERVER_H
21 #include "amarok_export.h"
22 #include "engine_fwd.h"
24 #include <QSet>
26 class EngineSubject;
27 class MetaBundle;
28 class QString;
30 /**
31 * if you want to observe the engine, inherit from this class and attach yourself to
32 * the engine with attach
33 * Note that all positional information and times are in milliseconds
35 class AMAROK_EXPORT EngineObserver
37 public:
38 EngineObserver();
39 EngineObserver( EngineSubject* );
40 virtual ~EngineObserver();
41 virtual void engineStateChanged( Engine::State currentState, Engine::State oldState = Engine::Empty );
42 virtual void engineTrackEnded( int finalPosition, int trackLength, const QString &reason );
43 virtual void engineNewTrackPlaying();
44 virtual void engineNewMetaData( const QHash<qint64, QString> &newMetaData, bool trackChanged );
45 virtual void engineVolumeChanged( int percent );
46 virtual void engineTrackPositionChanged( long position , bool userSeek );
47 virtual void engineTrackLengthChanged( long seconds );
49 private:
50 EngineSubject *m_subject;
53 /**
54 * Inherited by EngineController.
55 * Notify observer functionality is captured in this class.
57 class EngineSubject
59 public:
60 void AMAROK_EXPORT attach( EngineObserver *observer );
61 void AMAROK_EXPORT detach( EngineObserver *observer );
63 protected:
64 EngineSubject();
65 virtual ~EngineSubject();
66 void stateChangedNotify( Engine::State /*state*/ );
67 void trackEnded( int /*finalPosition*/, int /*trackLength*/, const QString &reason );
68 void newMetaDataNotify( const QHash<qint64, QString> &newMetaData, bool trackChanged ) const;
69 void volumeChangedNotify( int /*percent*/ );
70 /* userSeek means the position didn't change due to normal playback */
71 void trackPositionChangedNotify( long /*position*/ , bool userSeek=false );
72 void trackLengthChangedNotify( long /*seconds*/ );
73 void newTrackPlaying() const;
75 private:
76 QSet<EngineObserver*> Observers;
77 Engine::State m_oldEngineState;
80 #endif // AMAROK_ENGINEOBSERVER_H