MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

Queue.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_UPDATE_QUEUE_HXX
21 #define MPD_UPDATE_QUEUE_HXX
22
23 #include "check.h"
24 #include "Compiler.h"
25
26 #include <string>
27 #include <list>
28
29 class SimpleDatabase;
30 class Storage;
31
32 struct UpdateQueueItem {
33 SimpleDatabase *db;
34 Storage *storage;
35
36 std::string path_utf8;
37 unsigned id;
38 bool discard;
39
40 UpdateQueueItem():id(0) {}
41
42 UpdateQueueItem(SimpleDatabase &_db,
43 Storage &_storage,
44 const char *_path, bool _discard,
45 unsigned _id)
46 :db(&_db), storage(&_storage), path_utf8(_path),
47 id(_id), discard(_discard) {}
48
49 bool IsDefined() const {
50 return id != 0;
51 }
52 };
53
54 class UpdateQueue {
55 static constexpr unsigned MAX_UPDATE_QUEUE_SIZE = 32;
56
57 std::list<UpdateQueueItem> update_queue;
58
59 public:
60 gcc_nonnull_all
61 bool Push(SimpleDatabase &db, Storage &storage,
62 const char *path, bool discard, unsigned id);
63
64 UpdateQueueItem Pop();
65
66 void Clear() {
67 update_queue.clear();
68 }
69
70 gcc_nonnull_all
71 void Erase(SimpleDatabase &db);
72
73 gcc_nonnull_all
74 void Erase(Storage &storage);
75 };
76
77 #endif
UpdateQueueItem::id
unsigned id
Definition: Queue.hxx:37
UpdateQueue::Pop
UpdateQueueItem Pop()
check.h
gcc_nonnull_all
#define gcc_nonnull_all
Definition: Compiler.h:122
UpdateQueueItem::IsDefined
bool IsDefined() const
Definition: Queue.hxx:49
UpdateQueue
Definition: Queue.hxx:54
UpdateQueueItem::discard
bool discard
Definition: Queue.hxx:38
UpdateQueueItem
Definition: Queue.hxx:32
Storage
Definition: StorageInterface.hxx:46
UpdateQueueItem::UpdateQueueItem
UpdateQueueItem()
Definition: Queue.hxx:40
Compiler.h
UpdateQueue::Push
gcc_nonnull_all bool Push(SimpleDatabase &db, Storage &storage, const char *path, bool discard, unsigned id)
storage
const Storage & storage
Definition: DatabasePlaylist.hxx:31
UpdateQueue::Erase
gcc_nonnull_all void Erase(SimpleDatabase &db)
SimpleDatabase
Definition: SimpleDatabasePlugin.hxx:38
UpdateQueueItem::path_utf8
std::string path_utf8
Definition: Queue.hxx:36
UpdateQueueItem::UpdateQueueItem
UpdateQueueItem(SimpleDatabase &_db, Storage &_storage, const char *_path, bool _discard, unsigned _id)
Definition: Queue.hxx:42
UpdateQueueItem::db
SimpleDatabase * db
Definition: Queue.hxx:33
UpdateQueue::Clear
void Clear()
Definition: Queue.hxx:66
UpdateQueueItem::storage
Storage * storage
Definition: Queue.hxx:34