MPD  0.20.6
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 
35 
36  std::string path_utf8;
37  unsigned id;
38  bool discard;
39 
40  UpdateQueueItem():id(0) {}
41 
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:
62  const char *path, bool discard, unsigned id);
63 
65 
66  void Clear() {
67  update_queue.clear();
68  }
69 
71  void Erase(SimpleDatabase &db);
72 
74  void Erase(Storage &storage);
75 };
76 
77 #endif
unsigned id
Definition: Queue.hxx:37
UpdateQueueItem Pop()
#define gcc_nonnull_all
Definition: Compiler.h:122
bool IsDefined() const
Definition: Queue.hxx:49
bool discard
Definition: Queue.hxx:38
gcc_nonnull_all bool Push(SimpleDatabase &db, Storage &storage, const char *path, bool discard, unsigned id)
const Storage & storage
gcc_nonnull_all void Erase(SimpleDatabase &db)
std::string path_utf8
Definition: Queue.hxx:36
UpdateQueueItem(SimpleDatabase &_db, Storage &_storage, const char *_path, bool _discard, unsigned _id)
Definition: Queue.hxx:42
SimpleDatabase * db
Definition: Queue.hxx:33
void Clear()
Definition: Queue.hxx:66
Storage * storage
Definition: Queue.hxx:34