2
* Copyright (C) 2010, 2011 Tuomo Penttinen, all rights reserved.
4
* Author: Tuomo Penttinen <tp@herqq.org>
6
* This file is part of Herqq UPnP (HUPnP) library.
8
* Herqq UPnP is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser 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 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 Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with Herqq UPnP. If not, see <http://www.gnu.org/licenses/>.
22
#ifndef HSERVICES_SETUPDATA_H_
23
#define HSERVICES_SETUPDATA_H_
25
#include <HUpnpCore/HUpnp>
26
#include <HUpnpCore/HServiceId>
28
#include <QtCore/QHash>
29
#include <QtCore/QString>
30
#include <QtCore/QSharedDataPointer>
38
class HServiceSetupPrivate;
41
* \brief This class is used to specify information that can be used to validate
44
* \headerfile hservices_setupdata.h HServiceSetup
46
* \ingroup hupnp_devicemodel
48
* \sa HServicesSetupData, HClientService, HServerService
50
* \remarks This class is not thread-safe.
52
class H_UPNP_CORE_EXPORT HServiceSetup
56
QSharedDataPointer<HServiceSetupPrivate> h_ptr;
61
* Creates a new, invalid instance.
68
* \brief Creates a new instance.
70
* \param id specifies the service ID.
72
* \param serviceType specifies the service type.
74
* \param incReq specifies the \e inclusion \e requirement of the
79
* \remarks the version() is set to 1.
83
const HResourceType& serviceType,
84
HInclusionRequirement incReq = InclusionMandatory);
87
* \brief Creates a new instance.
89
* \param id specifies the service ID.
91
* \param serviceType specifies the service type.
93
* \param version specifies the version of the UPnP device, which first
94
* specified the service.
96
* \param incReq specifies the \e inclusion \e requirement of the
102
const HServiceId& id,
103
const HResourceType& serviceType,
105
HInclusionRequirement incReq = InclusionMandatory);
108
* \brief Assignment operator.
110
* Copies the contents of \a other to this.
112
HServiceSetup& operator=(const HServiceSetup&);
115
* \brief Copy constructor.
117
* Creates a copy of \a other.
119
HServiceSetup(const HServiceSetup&);
122
* \brief Destroys the instance.
127
* \brief Returns the <em>inclusion requirement</em>.
129
* \return The <em>inclusion requirement</em>.
131
* \sa setInclusionRequirement()
133
HInclusionRequirement inclusionRequirement() const;
136
* \brief Indicates if the object is valid.
138
* \param checkLevel specifies whether the validity of the object should be
139
* checked strictly according to the UDA specification.
141
* \return \e true in case the object is valid, that is, the service ID,
142
* service type, version and inclusion requirement are all properly defined
143
* in respect to the specified \c checkLevel.
145
bool isValid(HValidityCheckLevel checkLevel) const;
148
* \brief Returns the service ID.
150
* \return The service ID.
154
const HServiceId& serviceId() const;
157
* \brief Returns the service type.
159
* \return The service type.
161
* \sa setServiceType()
163
const HResourceType& serviceType() const;
166
* \brief Returns the version of the UPnP device, which first specified the service.
168
* \return The version of the UPnP device, which first specified the service.
175
* \brief Sets the the <em>inclusion requirement</em>.
177
* \param arg specifies the <em>inclusion requirement</em>.
179
* \sa inclusionRequirement()
181
void setInclusionRequirement(HInclusionRequirement arg);
184
* \brief Sets the service ID.
186
* \param arg specifies the service ID.
190
void setServiceId(const HServiceId& arg);
193
* \brief Sets the service type.
195
* \param arg specifies the service type.
199
void setServiceType(const HResourceType& arg);
202
* \brief Sets the version of the UPnP device, which first specified the service.
204
* \param version defines the version of the UPnP device,
205
* which first specifies the service.
209
void setVersion(int version);
213
* Compares the two objects for equality.
215
* \return \e true in case the provided objects are equal, false otherwise.
217
* \relates HServiceSetup
219
H_UPNP_CORE_EXPORT bool operator==(const HServiceSetup&, const HServiceSetup&);
222
* Compares the two objects for inequality.
224
* \return \e true in case the provided objects are not equal, false otherwise.
226
* \relates HServiceSetup
228
inline bool operator!=(const HServiceSetup& obj1, const HServiceSetup& obj2)
230
return !(obj1 == obj2);
234
* \brief This class is used to specify information that can be used to validate
237
* \headerfile hservices_setupdata.h HServicesSetupData
239
* \ingroup hupnp_devicemodel
241
* \remarks This class is not thread-safe.
243
class H_UPNP_CORE_EXPORT HServicesSetupData
245
friend H_UPNP_CORE_EXPORT bool operator==(
246
const HServicesSetupData&, const HServicesSetupData&);
250
QHash<HServiceId, HServiceSetup> m_serviceSetupInfos;
255
* \brief Creates a new, empty instance.
259
HServicesSetupData();
262
* \brief Destroys the instance.
264
~HServicesSetupData();
267
* \brief Retrieves a service setup object.
269
* \param id specifies the service ID of the item.
271
* \return The item with the specified service ID. Note that the returned item
272
* is invalid, i.e. HServiceSetup::isValid() returns false in case no item
273
* with the specified service ID was found.
277
HServiceSetup get(const HServiceId& id) const;
280
* \brief Indicates if the instance contains a service setup item that has the
281
* specified service ID.
283
* \param id specifies the service ID of the item.
285
* \return \e true if the instance contains an item with the specified
290
bool contains(const HServiceId& id) const;
293
* \brief Indicates if the object is empty.
295
* \return \e true in case the instance has no items.
297
bool isEmpty() const;
300
* \brief Returns the number of contained items.
302
* \return The number of contained items.
307
* \brief Returns the service IDs of the contained items.
309
* \return The service IDs of the contained items.
311
QSet<HServiceId> serviceIds() const;
314
* Inserts a new item.
316
* \param newItem specifies the item to be added.
318
* \param overWrite specifies whether to replace an already existing item
319
* with the same service ID. The default is \c false.
321
* \return \e true in case the item was added. The \a newItem will not be added
322
* if the instance already contains an item that has the same
323
* HServiceSetup::serviceId() as the \a newItem and the \a overWrite is
324
* \c false, or the \a newItem is invalid.
326
bool insert(const HServiceSetup& newItem, bool overWrite = false);
329
* Removes an existing item.
331
* \param id specifies the service ID of the item to be removed.
333
* \return \e true in case the item was found and removed.
335
bool remove(const HServiceId& id);
339
* Compares the two objects for equality.
341
* \return \e true in case the provided objects are equal, false otherwise.
343
* \relates HServicesSetupData
345
H_UPNP_CORE_EXPORT bool operator==(const HServicesSetupData&, const HServicesSetupData&);
348
* Compares the two objects for inequality.
350
* \return \e true in case the provided objects are not equal, false otherwise.
352
* \relates HServicesSetupData
354
inline bool operator!=(const HServicesSetupData& obj1, const HServicesSetupData& obj2)
356
return !(obj1 == obj2);
362
#endif /* HSERVICES_SETUPDATA_H_ */