MPD  0.20.6
Object.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_UPNP_OBJECT_HXX
21 #define MPD_UPNP_OBJECT_HXX
22 
23 #include "tag/Tag.hxx"
24 #include "Compiler.h"
25 
26 #include <string>
27 
34 public:
35  enum class Type {
36  UNKNOWN,
37  ITEM,
38  CONTAINER,
39  };
40 
41  // There are actually several kinds of containers:
42  // object.container.storageFolder, object.container.person,
43  // object.container.playlistContainer etc., but they all seem to
44  // behave the same as far as we're concerned. Otoh, musicTrack
45  // items are special to us, and so should playlists, but I've not
46  // seen one of the latter yet (servers seem to use containers for
47  // playlists).
48  enum class ItemClass {
49  UNKNOWN,
50  MUSIC,
51  PLAYLIST,
52  };
53 
57  std::string id;
58 
62  std::string parent_id;
63 
64  std::string url;
65 
69  std::string name;
70 
73 
75 
76  UPnPDirObject() = default;
77  UPnPDirObject(UPnPDirObject &&) = default;
78 
80 
81  UPnPDirObject &operator=(UPnPDirObject &&) = default;
82 
83  void Clear() {
84  id.clear();
85  parent_id.clear();
86  url.clear();
87  type = Type::UNKNOWN;
88  item_class = ItemClass::UNKNOWN;
89  tag.Clear();
90  }
91 
92  gcc_pure
93  bool Check() const {
94  return !id.empty() && !parent_id.empty() && !name.empty() &&
95  (type != UPnPDirObject::Type::ITEM ||
96  item_class != UPnPDirObject::ItemClass::UNKNOWN);
97  }
98 };
99 
100 #endif /* _UPNPDIRCONTENT_H_X_INCLUDED_ */
UPnPDirObject & operator=(UPnPDirObject &&)=default
void Clear()
Clear everything, as if this was a new Tag object.
std::string parent_id
Parent's ObjectId.
Definition: Object.hxx:62
The meta information about a song file.
Definition: Tag.hxx:34
void Clear()
Definition: Object.hxx:83
ItemClass item_class
Definition: Object.hxx:72
std::string name
A copy of "dc:title" sanitized as a file name.
Definition: Object.hxx:69
std::string url
Definition: Object.hxx:64
gcc_pure bool Check() const
Definition: Object.hxx:93
std::string id
ObjectId.
Definition: Object.hxx:57
UpnP Media Server directory entry, converted from XML data.
Definition: Object.hxx:33
#define gcc_pure
Definition: Compiler.h:116
UPnPDirObject()=default