2013-04-17 22:58:33 +02:00
|
|
|
/*
|
2015-01-01 19:48:13 +01:00
|
|
|
* Copyright (C) 2003-2015 The Music Player Daemon Project
|
2013-04-17 22:58:33 +02:00
|
|
|
* 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"
|
2014-01-11 01:01:54 +01:00
|
|
|
#include "Compiler.h"
|
2013-04-17 22:58:33 +02:00
|
|
|
|
2014-01-18 16:36:42 +01:00
|
|
|
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
|
|
|
#include "neighbor/Listener.hxx"
|
|
|
|
class NeighborGlue;
|
|
|
|
#endif
|
|
|
|
|
2014-01-30 20:29:48 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
|
|
|
#include "db/DatabaseListener.hxx"
|
2014-02-01 00:26:34 +01:00
|
|
|
class Database;
|
2014-02-06 07:19:12 +01:00
|
|
|
class Storage;
|
2014-01-29 20:16:43 +01:00
|
|
|
class UpdateService;
|
2014-01-30 20:29:48 +01:00
|
|
|
#endif
|
|
|
|
|
2014-02-04 23:58:03 +01:00
|
|
|
class EventLoop;
|
2014-02-01 00:26:34 +01:00
|
|
|
class Error;
|
2013-04-17 22:58:33 +02:00
|
|
|
class ClientList;
|
|
|
|
struct Partition;
|
|
|
|
|
2014-01-18 16:36:42 +01:00
|
|
|
struct Instance final
|
2014-01-30 20:29:48 +01:00
|
|
|
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
|
|
|
|
:
|
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_DATABASE
|
|
|
|
public DatabaseListener
|
2014-01-18 16:36:42 +01:00
|
|
|
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
2014-01-30 20:29:48 +01:00
|
|
|
,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
|
|
|
public NeighborListener
|
2014-01-18 16:36:42 +01:00
|
|
|
#endif
|
|
|
|
{
|
2014-02-04 23:58:03 +01:00
|
|
|
EventLoop *event_loop;
|
|
|
|
|
2014-01-18 16:36:42 +01:00
|
|
|
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
|
|
|
NeighborGlue *neighbors;
|
|
|
|
#endif
|
|
|
|
|
2014-01-30 20:29:48 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
2014-02-01 00:26:34 +01:00
|
|
|
Database *database;
|
|
|
|
|
2014-02-09 07:44:07 +01:00
|
|
|
/**
|
|
|
|
* This is really a #CompositeStorage. To avoid heavy include
|
|
|
|
* dependencies, we declare it as just #Storage.
|
|
|
|
*/
|
2014-02-06 07:19:12 +01:00
|
|
|
Storage *storage;
|
2014-02-05 17:50:04 +01:00
|
|
|
|
2014-01-29 20:16:43 +01:00
|
|
|
UpdateService *update;
|
2014-01-30 20:29:48 +01:00
|
|
|
#endif
|
2014-01-29 20:16:43 +01:00
|
|
|
|
2013-04-17 22:58:33 +02:00
|
|
|
ClientList *client_list;
|
|
|
|
|
|
|
|
Partition *partition;
|
|
|
|
|
2014-02-04 10:09:09 +01:00
|
|
|
Instance() {
|
|
|
|
#ifdef ENABLE_DATABASE
|
2014-02-05 17:50:04 +01:00
|
|
|
storage = nullptr;
|
2014-02-04 10:09:09 +01:00
|
|
|
update = nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-01-30 20:29:48 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
2014-02-01 00:26:34 +01:00
|
|
|
/**
|
|
|
|
* Returns the global #Database instance. May return nullptr
|
|
|
|
* if this MPD configuration has no database (no
|
|
|
|
* music_directory was configured).
|
|
|
|
*/
|
|
|
|
Database *GetDatabase(Error &error);
|
2014-01-30 20:29:48 +01:00
|
|
|
#endif
|
|
|
|
|
2013-04-17 22:58:33 +02:00
|
|
|
/**
|
2013-10-21 23:22:16 +02:00
|
|
|
* A tag in the play queue has been modified by the player
|
|
|
|
* thread. Propagate the change to all subsystems.
|
2013-04-17 22:58:33 +02:00
|
|
|
*/
|
|
|
|
void TagModified();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Synchronize the player with the play queue.
|
|
|
|
*/
|
|
|
|
void SyncWithPlayer();
|
2014-01-11 01:01:54 +01:00
|
|
|
|
|
|
|
private:
|
2014-01-30 20:29:48 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
2014-02-04 19:16:30 +01:00
|
|
|
virtual void OnDatabaseModified() override;
|
|
|
|
virtual void OnDatabaseSongRemoved(const LightSong &song) override;
|
2014-01-30 20:29:48 +01:00
|
|
|
#endif
|
2014-01-18 16:36:42 +01:00
|
|
|
|
|
|
|
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
|
|
|
/* virtual methods from class NeighborListener */
|
|
|
|
virtual void FoundNeighbor(const NeighborInfo &info) override;
|
|
|
|
virtual void LostNeighbor(const NeighborInfo &info) override;
|
|
|
|
#endif
|
2013-04-17 22:58:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|