Instance.hxx 2.67 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright (C) 2003-2015 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * http://www.musicpd.org
 *
 * 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 MPD_INSTANCE_HXX
#define MPD_INSTANCE_HXX

#include "check.h"
24
#include "Compiler.h"
25

26 27 28 29 30
#ifdef ENABLE_NEIGHBOR_PLUGINS
#include "neighbor/Listener.hxx"
class NeighborGlue;
#endif

31 32
#ifdef ENABLE_DATABASE
#include "db/DatabaseListener.hxx"
33
class Database;
34
class Storage;
35
class UpdateService;
36 37
#endif

38
class EventLoop;
39
class Error;
40 41 42
class ClientList;
struct Partition;

43
struct Instance final
44 45 46 47 48
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
	:
#endif
#ifdef ENABLE_DATABASE
	public DatabaseListener
49
#ifdef ENABLE_NEIGHBOR_PLUGINS
50 51 52 53 54
	,
#endif
#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
	public NeighborListener
55 56
#endif
{
57 58
	EventLoop *event_loop;

59 60 61 62
#ifdef ENABLE_NEIGHBOR_PLUGINS
	NeighborGlue *neighbors;
#endif

63
#ifdef ENABLE_DATABASE
64 65
	Database *database;

66 67 68 69
	/**
	 * This is really a #CompositeStorage.  To avoid heavy include
	 * dependencies, we declare it as just #Storage.
	 */
70
	Storage *storage;
71

72
	UpdateService *update;
73
#endif
74

75 76 77 78
	ClientList *client_list;

	Partition *partition;

79 80
	Instance() {
#ifdef ENABLE_DATABASE
81
		storage = nullptr;
82 83 84 85
		update = nullptr;
#endif
	}

86
#ifdef ENABLE_DATABASE
87 88 89 90 91 92
	/**
	 * Returns the global #Database instance.  May return nullptr
	 * if this MPD configuration has no database (no
	 * music_directory was configured).
	 */
	Database *GetDatabase(Error &error);
93 94
#endif

95
	/**
96 97
	 * A tag in the play queue has been modified by the player
	 * thread.  Propagate the change to all subsystems.
98 99 100 101 102 103 104
	 */
	void TagModified();

	/**
	 * Synchronize the player with the play queue.
	 */
	void SyncWithPlayer();
105 106

private:
107
#ifdef ENABLE_DATABASE
108 109
	virtual void OnDatabaseModified() override;
	virtual void OnDatabaseSongRemoved(const LightSong &song) override;
110
#endif
111 112 113 114 115 116

#ifdef ENABLE_NEIGHBOR_PLUGINS
	/* virtual methods from class NeighborListener */
	virtual void FoundNeighbor(const NeighborInfo &info) override;
	virtual void LostNeighbor(const NeighborInfo &info) override;
#endif
117 118 119
};

#endif