libmpd++
DASH MPD parsing and manipulation library
 
Loading...
Searching...
No Matches
Descriptor.hh
Go to the documentation of this file.
1#ifndef _BBC_PARSE_DASH_MPD_DESCRIPTOR_HH_
2#define _BBC_PARSE_DASH_MPD_DESCRIPTOR_HH_
3/*****************************************************************************
4 * DASH MPD parsing library in C++: Descriptor class
5 *****************************************************************************
6 * Copyright: (C) 2025 British Broadcasting Corporation
7 * Author(s): David Waring <david.waring2@bbc.co.uk>
8 * License: LGPLv3
9 *
10 * For full license terms please see the LICENSE file distributed with this
11 * library or refer to: https://www.gnu.org/licenses/lgpl-3.0.txt.
12 */
13#include <iostream>
14#include <optional>
15#include <string>
16
17#include "macros.hh"
18#include "URI.hh"
19
22// Forward declarations for types only used by pointer or reference
23namespace xmlpp {
24 class Element;
25 class Node;
26}
29
31
32class MPD;
33class Period;
34
42public:
43
50 Descriptor() = delete;
51
64 Descriptor(const URI &scheme_id, const std::optional<std::string> &value = std::nullopt, const std::optional<std::string> &id = std::nullopt)
65 :m_schemeIdUri(scheme_id)
66 ,m_value(value)
67 {};
68 Descriptor(URI &&scheme_id, const std::optional<std::string> &value = std::nullopt, const std::optional<std::string> &id = std::nullopt)
69 :m_schemeIdUri(scheme_id)
70 ,m_value(value)
71 {};
72
73
74
82 Descriptor(const Descriptor &other)
83 :m_schemeIdUri(other.m_schemeIdUri)
84 ,m_value(other.m_value)
85 ,m_id(other.m_id)
86 {};
87
96 :m_schemeIdUri(std::move(other.m_schemeIdUri))
97 ,m_value(std::move(other.m_value))
98 ,m_id(std::move(other.m_id))
99 {};
100
104 virtual ~Descriptor() {};
105
115 m_schemeIdUri = other.m_schemeIdUri;
116 m_value = other.m_value;
117 m_id = other.m_id;
118 return *this;
119 };
120
130 m_schemeIdUri = std::move(other.m_schemeIdUri);
131 m_value = std::move(other.m_value);
132 m_id = std::move(other.m_id);
133 return *this;
134 };
135
141 bool operator==(const Descriptor &other) const {
142 if (m_schemeIdUri != other.m_schemeIdUri) return false;
143 if (m_value.has_value() != other.m_value.has_value()) return false;
144 if (m_value.has_value() && m_value.value() != other.m_value.value()) return false;
145 if (m_id.has_value() != other.m_id.has_value()) return false;
146 if (m_id.has_value() && m_id.value() != other.m_id.value()) return false;
147 return true;
148 }
149
155 const URI &schemeId() const { return m_schemeIdUri; };
156 URI &schemeId() { return m_schemeIdUri; };
158
165 Descriptor &schemeId(const URI &scheme_id) { m_schemeIdUri = scheme_id; return *this; };
166 Descriptor &schemeId(URI &&scheme_id) { m_schemeIdUri = std::move(scheme_id); return *this; };
168
173 bool has_value() const { return m_value.has_value(); };
174
180 const std::optional<std::string> &value() const { return m_value; };
181 std::optional<std::string> &value() { return m_value; };
183
188 Descriptor &value(const std::nullopt_t&) { m_value.reset(); return *this; };
189
196 Descriptor &value(const std::string &val) { m_value = val; return *this; };
197 Descriptor &value(std::string &&val) { m_value = std::move(val); return *this; };
199
204 bool has_id() const { return m_id.has_value(); };
205
206
212 const std::optional<std::string> &id() const { return m_id; };
213 std::optional<std::string> &id() { return m_id; };
215
220 Descriptor &id(const std::nullopt_t&) { m_id.reset(); return *this; };
221
228 Descriptor &id(const std::string &id) { m_id = id; return *this; };
229 Descriptor &id(std::string &&id) { m_id = std::move(id); return *this; };
231
233protected:
234 friend class AdaptationSet;
235 friend class MPD;
236 friend class Period;
237 friend class Representation;
238 friend class RepresentationBase;
239
247 Descriptor(xmlpp::Node &node);
248
256 void setXMLElement(xmlpp::Element &element) const;
258
259private:
260 // Attributes
261 URI m_schemeIdUri; //< @@schemeIdUri attribute value
262 std::optional<std::string> m_value; //< The optional @@value attribute value
263 std::optional<std::string> m_id; //< The optional @@id attribute value
264};
265
267
268/* vim:ts=8:sts=4:sw=4:expandtab:
269 */
270#endif /*_BBC_PARSE_DASH_MPD_DESCRIPTOR_HH_*/
AdaptationSet class.
Definition AdaptationSet.hh:60
Definition Descriptor.hh:41
Descriptor & schemeId(URI &&scheme_id)
Definition Descriptor.hh:166
Descriptor & value(std::string &&val)
Definition Descriptor.hh:197
Descriptor(Descriptor &&other)
Definition Descriptor.hh:95
Descriptor(const URI &scheme_id, const std::optional< std::string > &value=std::nullopt, const std::optional< std::string > &id=std::nullopt)
Constructs a new Descriptor object.
Definition Descriptor.hh:64
virtual ~Descriptor()
Definition Descriptor.hh:104
Descriptor & id(const std::nullopt_t &)
Definition Descriptor.hh:220
Descriptor & value(const std::nullopt_t &)
Definition Descriptor.hh:188
URI & schemeId()
Definition Descriptor.hh:156
Descriptor(const Descriptor &other)
Definition Descriptor.hh:82
const std::optional< std::string > & id() const
Definition Descriptor.hh:212
std::optional< std::string > & id()
Definition Descriptor.hh:213
bool has_id() const
Definition Descriptor.hh:204
Descriptor & value(const std::string &val)
Definition Descriptor.hh:196
Descriptor & id(std::string &&id)
Definition Descriptor.hh:229
Descriptor & operator=(Descriptor &&other)
Definition Descriptor.hh:129
Descriptor(URI &&scheme_id, const std::optional< std::string > &value=std::nullopt, const std::optional< std::string > &id=std::nullopt)
Constructs a new Descriptor object.
Definition Descriptor.hh:68
bool has_value() const
Definition Descriptor.hh:173
std::optional< std::string > & value()
Definition Descriptor.hh:181
const URI & schemeId() const
Definition Descriptor.hh:155
bool operator==(const Descriptor &other) const
Definition Descriptor.hh:141
Descriptor & operator=(const Descriptor &other)
Definition Descriptor.hh:114
const std::optional< std::string > & value() const
Definition Descriptor.hh:180
Descriptor & schemeId(const URI &scheme_id)
Definition Descriptor.hh:165
Descriptor & id(const std::string &id)
Definition Descriptor.hh:228
Definition MPD.hh:49
Definition Period.hh:53
Definition RepresentationBase.hh:54
Definition Representation.hh:55
Definition URI.hh:40
#define LIBMPDPP_NAMESPACE_END
Definition macros.hh:54
#define LIBMPDPP_PUBLIC_API
Used to mark something as part of the public API.
Definition macros.hh:21
#define LIBMPDPP_NAMESPACE_BEGIN
Definition macros.hh:50
Definition SegmentAvailability.hh:87