bes  Updated for version 3.20.6
AggMemberDatasetSharedDDSWrapper.cc
1 // This file is part of the "NcML Module" project, a BES module designed
3 // to allow NcML files to be used to be used as a wrapper to add
4 // AIS to existing datasets of any format.
5 //
6 // Copyright (c) 2010 OPeNDAP, Inc.
7 // Author: Michael Johnson <m.johnson@opendap.org>
8 //
9 // For more information, please also see the main website: http://opendap.org/
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26 //
27 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29 #include "AggMemberDatasetSharedDDSWrapper.h"
30 #include <DDS.h> // libdap
31 #include "DDSAccessInterface.h"
32 #include "NCMLDebug.h"
33 
34 namespace agg_util
35 {
36  AggMemberDatasetSharedDDSWrapper::AggMemberDatasetSharedDDSWrapper()
37  : AggMemberDatasetWithDimensionCacheBase("") // empty location for the wrapper
38  , _pDDSHolder(0) // NULL, really shouldn't create a default.
39  {
40  }
41 
42  AggMemberDatasetSharedDDSWrapper::AggMemberDatasetSharedDDSWrapper(const DDSAccessRCInterface* pDDSHolder)
43  : AggMemberDatasetWithDimensionCacheBase("") // empty location
44  , _pDDSHolder(pDDSHolder)
45  {
46  if (_pDDSHolder)
47  {
48  _pDDSHolder->ref();
49  }
50  }
51 
52  AggMemberDatasetSharedDDSWrapper::~AggMemberDatasetSharedDDSWrapper()
53  {
54  BESDEBUG("ncml:memory", "~AggMemberDatasetDDSWrapper() called..." << endl);
55  cleanup(); // will unref()
56  }
57 
58  AggMemberDatasetSharedDDSWrapper::AggMemberDatasetSharedDDSWrapper(const AggMemberDatasetSharedDDSWrapper& proto)
59  : RCObjectInterface()
60  , AggMemberDatasetWithDimensionCacheBase(proto)
61  , _pDDSHolder(0)
62  {
63  copyRepFrom(proto);
64  }
65 
66  AggMemberDatasetSharedDDSWrapper&
67  AggMemberDatasetSharedDDSWrapper::operator=(const AggMemberDatasetSharedDDSWrapper& that)
68  {
69  if (this != &that)
70  {
71  // deal with old reference
72  cleanup();
73  // super changes
74  AggMemberDatasetWithDimensionCacheBase::operator=(that);
75  // local changes
76  copyRepFrom(that);
77  }
78  return *this;
79  }
80 
81 
82  const libdap::DDS*
84  {
85  const libdap::DDS* pDDS = 0;
86  if (_pDDSHolder)
87  {
88  pDDS = _pDDSHolder->getDDS();
89  }
90  return dynamic_cast<const libdap::DDS*>(pDDS);
91  }
92 
94 
95  void
96  AggMemberDatasetSharedDDSWrapper::cleanup() throw()
97  {
98  if (_pDDSHolder)
99  {
100  _pDDSHolder->unref();
101  _pDDSHolder = 0;
102  }
103  }
104 
105  void
106  AggMemberDatasetSharedDDSWrapper::copyRepFrom(const AggMemberDatasetSharedDDSWrapper& rhs)
107  {
108  NCML_ASSERT(!_pDDSHolder);
109  _pDDSHolder = rhs._pDDSHolder;
110  if (_pDDSHolder)
111  {
112  _pDDSHolder->ref();
113  }
114  }
115 }
agg_util::RCObjectInterface::ref
virtual int ref() const =0
agg_util::RCObjectInterface::unref
virtual int unref() const =0
agg_util::DDSAccessInterface::getDDS
virtual const libdap::DDS * getDDS() const =0
agg_util
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
Definition: AggMemberDataset.cc:38
agg_util::AggMemberDatasetSharedDDSWrapper::getDDS
virtual const libdap::DDS * getDDS()
Definition: AggMemberDatasetSharedDDSWrapper.cc:83