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/>.
22
#include "hcontentdirectory_serviceconfiguration.h"
23
#include "hcontentdirectory_serviceconfiguration_p.h"
25
#include "../cds_model/datasource/habstract_cds_datasource.h"
36
/*******************************************************************************
37
* HContentDirectoryServiceConfigurationPrivate
38
*******************************************************************************/
39
HContentDirectoryServiceConfigurationPrivate::HContentDirectoryServiceConfigurationPrivate() :
40
m_dataSource(0), m_refCnt(0), m_hasOwnership(false)
44
HContentDirectoryServiceConfigurationPrivate::~HContentDirectoryServiceConfigurationPrivate()
49
void HContentDirectoryServiceConfigurationPrivate::detach()
51
if (m_refCnt && --*m_refCnt == 0)
63
/*******************************************************************************
64
* HContentDirectoryServiceConfiguration
65
*******************************************************************************/
66
HContentDirectoryServiceConfiguration::HContentDirectoryServiceConfiguration() :
67
h_ptr(new HContentDirectoryServiceConfigurationPrivate())
71
HContentDirectoryServiceConfiguration::HContentDirectoryServiceConfiguration(
72
HContentDirectoryServiceConfigurationPrivate& dd) :
77
HContentDirectoryServiceConfiguration::~HContentDirectoryServiceConfiguration()
82
void HContentDirectoryServiceConfiguration::doClone(HClonable* target) const
84
HContentDirectoryServiceConfiguration* conf =
85
dynamic_cast<HContentDirectoryServiceConfiguration*>(target);
92
if (h_ptr->m_dataSource)
94
conf->h_ptr->m_refCnt = h_ptr->m_refCnt;
97
conf->h_ptr->m_hasOwnership = h_ptr->m_hasOwnership;
98
conf->h_ptr->m_dataSource = h_ptr->m_dataSource;
101
HContentDirectoryServiceConfiguration* HContentDirectoryServiceConfiguration::newInstance() const
103
return new HContentDirectoryServiceConfiguration();
106
HContentDirectoryServiceConfiguration* HContentDirectoryServiceConfiguration::clone() const
108
return static_cast<HContentDirectoryServiceConfiguration*>(HClonable::clone());
111
bool HContentDirectoryServiceConfiguration::isValid() const
113
return h_ptr->m_dataSource;
116
bool HContentDirectoryServiceConfiguration::hasOwnershipOfDataSource() const
118
return h_ptr->m_dataSource && h_ptr->m_hasOwnership;
121
HAbstractCdsDataSource* HContentDirectoryServiceConfiguration::dataSource() const
123
return h_ptr->m_dataSource.data();
126
void HContentDirectoryServiceConfiguration::setDataSource(
127
HAbstractCdsDataSource* dataSource, bool takeOwnership)
129
Q_ASSERT_X(dataSource, "", "A valid data source has to be provided");
133
if (!h_ptr->m_refCnt)
135
h_ptr->m_refCnt = new int(1);
138
h_ptr->m_hasOwnership = takeOwnership;
139
h_ptr->m_dataSource = dataSource;
142
void HContentDirectoryServiceConfiguration::detachDataSource()