OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
AggMemberDatasetSharedDDSWrapper.cc
Go to the documentation of this file.
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.
30 #include <DataDDS.h> // libdap
31 #include <DDS.h> // libdap
32 #include "DDSAccessInterface.h"
33 #include "NCMLDebug.h"
34 
35 namespace agg_util
36 {
38  : AggMemberDatasetWithDimensionCacheBase("") // empty location for the wrapper
39  , _pDDSHolder(0) // NULL, really shouldn't create a default.
40  {
41  }
42 
44  : AggMemberDatasetWithDimensionCacheBase("") // empty location
45  , _pDDSHolder(pDDSHolder)
46  {
47  if (_pDDSHolder)
48  {
49  _pDDSHolder->ref();
50  }
51  }
52 
54  {
55  BESDEBUG("ncml:memory", "~AggMemberDatasetDDSWrapper() called..." << endl);
56  cleanup(); // will unref()
57  }
58 
62  , _pDDSHolder(0)
63  {
64  copyRepFrom(proto);
65  }
66 
69  {
70  if (this != &that)
71  {
72  // deal with old reference
73  cleanup();
74  // super changes
76  // local changes
77  copyRepFrom(that);
78  }
79  return *this;
80  }
81 
82 
83  const libdap::DataDDS*
85  {
86  const libdap::DDS* pDDS = 0;
87  if (_pDDSHolder)
88  {
89  pDDS = _pDDSHolder->getDDS();
90  }
91  return dynamic_cast<const libdap::DataDDS*>(pDDS);
92  }
93 
95 
96  void
97  AggMemberDatasetSharedDDSWrapper::cleanup() throw()
98  {
99  if (_pDDSHolder)
100  {
101  _pDDSHolder->unref();
102  _pDDSHolder = 0;
103  }
104  }
105 
106  void
107  AggMemberDatasetSharedDDSWrapper::copyRepFrom(const AggMemberDatasetSharedDDSWrapper& rhs)
108  {
109  NCML_ASSERT(!_pDDSHolder);
110  _pDDSHolder = rhs._pDDSHolder;
111  if (_pDDSHolder)
112  {
113  _pDDSHolder->ref();
114  }
115  }
116 }
AggMemberDatasetSharedDDSWrapper & operator=(const AggMemberDatasetSharedDDSWrapper &that)
virtual int ref() const =0
Increase the reference count by one.
#define NCML_ASSERT(cond)
Definition: NCMLDebug.h:80
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
AggMemberDatasetWithDimensionCacheBase & operator=(const AggMemberDatasetWithDimensionCacheBase &rhs)
virtual int unref() const =0
Decrease the reference count by one.
class AggMemberDatasetSharedDDSWrapper: concrete subclass of AggMemberDataset designed to hold a ref-...
Mixture interface for when we a reference-counted DDS container.
virtual const libdap::DataDDS * getDataDDS()
Access via the wrapped DDSAccessRCInterface.
virtual const libdap::DDS * getDDS() const =0
Accessor for a contained DDS.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
Interface class for a reference counted object.