2
* Copyright (C) 2011 Tuomo Penttinen, all rights reserved.
4
* Author: Tuomo Penttinen <tp@herqq.org>
6
* This file is part of Herqq UPnP Av (HUPnPAv) library.
8
* Herqq UPnP Av is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
13
* Herqq UPnP Av is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with Herqq UPnP Av. If not, see <http://www.gnu.org/licenses/>.
25
#include <HUpnpAv/HObject>
36
class HContainerEventInfoPrivate;
39
* \brief This class is used to contain information of an HContainer modification event.
41
* \headerfile hcontainer.h HContainerEventInfo
43
* \ingroup hupnp_av_cds_objects
45
* \remarks This class is not thread-safe.
49
class H_UPNP_AV_EXPORT HContainerEventInfo
53
QSharedDataPointer<HContainerEventInfoPrivate> h_ptr;
58
* \brief This enumeration defines the different event types instances of this class
64
* This event type is not defined.
69
* This value is used when a child object has been added into
75
* This value is used when a child object has been removed from
81
* This value is used when a child object of a container has been
88
* \brief Creates a new, invalid instance.
92
HContainerEventInfo();
95
* \brief Creates a new instance.
97
* \param type specifies the type of the event.
99
* \param childId specifies the ID of the child object that was the "target"
103
EventType type, const QString& childId, quint32 updateId = 0);
106
* \brief Copy constructor.
108
* Creates a copy of \c other.
110
HContainerEventInfo(const HContainerEventInfo&);
113
* \brief Assignment operator.
115
* Copies the contents of \c other to this.
117
HContainerEventInfo& operator=(const HContainerEventInfo&);
120
* \brief Destroys the instance.
122
~HContainerEventInfo();
125
* \brief Indicates if the instance contains any data.
127
* \return \e true if the instance does not contain any data.
129
bool isValid() const;
132
* \brief Returns the type of the event.
134
* \return The type of the event.
138
EventType type() const;
141
* \brief Returns the ID of the child object that was the "target"
144
* \return The ID of the child object that was the "target"
149
QString childId() const;
152
* \brief Returns the value of the state variable \c SystemUpdateId at the time this
153
* event was generated.
155
* \return the value of the state variable \c SystemUpdateId at the time this
156
* event was generated.
160
quint32 updateId() const;
163
* \brief Specifies the type of the event.
165
* \param type specifies the type of the event.
169
void setType(EventType type);
172
* \brief Specifies the ID of the child object that was the "target"
175
* \param arg specifies the ID of the child object that was the "target"
180
void setChildId(const QString& arg);
183
* \brief Specifies the value of the state variable \c SystemUpdateId at the time this
184
* event was generated.
186
* \param arg specifies the value of the state variable \c SystemUpdateId at the time this
187
* event was generated.
191
void setUpdateId(quint32 arg);
195
* Compares the two objects for equality.
197
* \return \e true in case the objects are logically equivalent.
199
* \relates HContainerEventInfo
201
H_UPNP_AV_EXPORT bool operator==(const HContainerEventInfo&, const HContainerEventInfo&);
204
* Compares the two objects for inequality.
206
* \return \e true in case the objects are not logically equivalent.
208
* \relates HContainerEventInfo
210
inline bool operator!=(const HContainerEventInfo& obj1, const HContainerEventInfo& obj2)
212
return !(obj1 == obj2);
215
class HContainerPrivate;
218
* \brief This class is used to represent a collection of individual content objects
219
* and other collections of individual content objects.
221
* The class identifier specified by the AV Working
222
* Committee is \c object.container .
224
* \headerfile hcontainer.h HContainer
226
* \ingroup hupnp_av_cds_objects
228
* \remarks This class is not thread-safe.
230
class H_UPNP_AV_EXPORT HContainer :
234
H_DISABLE_COPY(HContainer)
235
H_DECLARE_PRIVATE(HContainer)
240
* Constructs a new instance.
242
* \param clazz specifies the UPnP class of the object. This cannot be empty.
244
* \param cdsType specifies the CDS type of the object. This cannot be
245
* HObject::UndefinedCdsType.
247
* \sa isInitialized()
249
HContainer(const QString& clazz = sClass(), CdsType cdsType = sType());
254
HContainer(HContainerPrivate&);
257
* Specifies the number of child objects the container is supposed to contain.
259
* \param arg specifies the number of child objects the container is supposed to contain.
261
* \sa expectedChildCount()
263
void setExpectedChildCount(quint32 arg);
265
virtual bool validate() const;
267
// Documented in HClonable
268
virtual HContainer* newInstance() const;
269
// Documented in HClonable
270
virtual void doClone(HClonable* target) const;
275
* \brief Creates a new instance.
277
* \param title specifies the title of the object.
279
* \param parentId specifies the ID of the object that contains this
280
* object. If the object has no parent, this has to be left empty.
282
* \param id specifies the ID of this object. If this is not specified,
283
* a unique identifier within the running process is created for the object.
288
const QString& title,
289
const QString& parentId = QString(),
290
const QString& id = QString());
293
* \brief Destroys the instance.
295
virtual ~HContainer();
298
* \brief Returns the IDs of the individual content objects that this container
301
* \return The IDs of the individual content objects that this container
304
* \sa setChildIds(), expectedChildCount()
306
QSet<QString> childIds() const;
309
* \brief Indicates if a search can be performed to this container.
311
* \return \e true if a search can be performed to this container.
313
* \sa setSearchable()
315
bool searchable() const;
318
* \brief Returns the container update ID.
320
* \return The container update ID, which is the value of the state variable
321
* \c SystemUpdateID at the time of the most recent \e Container \e Modification
324
* \sa setContainerUpdateId()
326
quint32 containerUpdateId() const;
329
* \brief Returns the total number of child objects that have been deleted
330
* from this container since the last initialization.
332
* \return the total number of child objects that have been deleted
333
* from this container since the last initialization.
335
* \sa setTotalDeletedChildCount()
337
quint32 totalDeletedChildCount() const;
340
* \brief Returns the class types that can be created within this container.
342
* \return The class types that can be created within this container.
344
* \sa setCreateClassInfos()
346
QList<HCdsClassInfo> createClassInfos() const;
349
* \brief Returns the class types that can be used in searches targeted to this
352
* \return The class types that can be used in searches targeted to this
355
* \sa setSearchClassInfos(), ContentDirectory:3, Appendix B.1.11.
357
QList<HCdsClassInfo> searchClassInfos() const;
360
* Returns the number of child objects the container is supposed to contain.
362
* At server-side the expected child count always equals to the size of
363
* childIds(). However, at client-side the number of child objects of a
364
* container are may be known before the actual child objects are available.
365
* Further, child objects may be added to a container object progressively
366
* and because of that non-zero size of childIds() does not mean that every
367
* child object of a container has been retrieved.
369
* You should never consider the size of childIds() as the number of all child
370
* objects of a container at client-side, unless the size equals to the
371
* value this method returns.
373
* \return the number of child objects the container is supposed to contain.
375
* \sa setExpectedChildCount(), childIds()
377
quint32 expectedChildCount() const;
380
* Indicates if the container contains the specified child ID.
382
* \param childId specifies the child ID to check.
384
* \return \e true if the container contains the specified child ID.
386
bool hasChildId(const QString& childId) const;
389
* \brief Sets the IDs of the individual content objects that this container contains.
391
* \param childIds specifies the IDs of the individual content objects that this
392
* container contains.
394
void setChildIds(const QSet<QString>& childIds);
397
* Adds the specified IDs of the individual content objects to this container.
399
* \param childIds specifies the IDs of the individual content objects to
400
* be added to this container.
402
void addChildIds(const QSet<QString>& childIds);
405
* Adds an ID of an individual content object to this container.
407
* \param childId specifies the ID of the individual content object to
408
* be added to this container.
410
void addChildId(const QString& childId);
413
* Removes the specified child ID.
415
* \param childId specifies the child ID to be removed.
417
void removeChildId(const QString& childId);
420
* Removes the specified child IDs.
422
* \param childIds specifies the child IDs to be removed.
424
void removeChildIds(const QSet<QString>& childIDs);
427
* \brief Specifies the class types that can be created within this
430
* \param arg specifies the class types that can be created within this
433
* \sa searchClassInfos()
435
void setCreateClassInfos(const QList<HCdsClassInfo>& arg);
438
* \brief Specifies the container update ID.
440
* \param arg specifies the container update ID.
442
* \sa containerUpdateId()
444
void setContainerUpdateId(quint32 arg);
447
* \brief Specifies whether a search can be performed to this container.
449
* \param arg specifies whether a search can be performed to this container.
453
void setSearchable(bool arg);
456
* \brief Specifies class types that can be used in searches targeted to this
459
* \param arg specifies the class types that can be used in searches
460
* targeted to this container.
462
* \sa searchClassInfos()
464
void setSearchClassInfos(const QList<HCdsClassInfo>& arg);
467
* Specifies the total number of child objects that have been deleted
468
* from this container since the last initialization.
470
* \param arg specifies the total number of child objects that have been deleted
471
* from this container since the last initialization.
473
* \sa totalDeletedChildCount()
475
void setTotalDeletedChildCount(quint32 arg);
478
* \brief Returns the class identifier specified by the AV Working Committee.
480
* \return The class identifier specified by the AV Working Committee.
482
inline static QString sClass() { return "object.container"; }
485
* \brief Returns the CdsType value of this class.
487
* \return The CdsType value of this class.
489
inline static CdsType sType() { return Container; }
492
* Creates a new instance with no title or parentID.
494
* \return a pointer to the newly created instance.
496
* \remarks the ownership of the object is transferred to the caller. Make sure
497
* to delete the object.
499
inline static HContainer* create() { return new HContainer(); }
504
* \brief This signal is emitted when a container has been modified.
506
* \param source specifies the HContainer that sent the event.
508
* \param eventInfo specifies information of the \e Container \e Modification that
511
* \note Since HContainer knows only the IDs of its child objects, HContainer
512
* does not monitor its child objects for changes. Because of this, an
513
* HContainer instance will never emit this signal when a child object
514
* has been modified. However, this type of functionality is provided by
515
* HAbstractCdsDataSource.
517
* \sa HAbstractCdsDataSource
519
void containerModified(
520
Herqq::Upnp::Av::HContainer* source,
521
const Herqq::Upnp::Av::HContainerEventInfo& eventInfo);
528
#endif /* HCONTAINER_H_ */