bes  Updated for version 3.20.6
DmrppD4Group.cc
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of the BES
5 
6 // Copyright (c) 2016 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #include "config.h"
26 
27 #include <string>
28 
29 #include <D4Enum.h>
30 #include <D4EnumDefs.h>
31 #include <D4Attributes.h>
32 #include <D4Maps.h>
33 #include <D4Group.h>
34 #include <XMLWriter.h>
35 
36 #include <BESError.h>
37 #include <BESDebug.h>
38 
39 #include "DmrppD4Group.h"
40 
41 using namespace libdap;
42 using namespace std;
43 
44 namespace dmrpp {
45 
46 void
47 DmrppD4Group::_duplicate(const DmrppD4Group &)
48 {
49 }
50 
51 DmrppD4Group::DmrppD4Group(const string &n) : D4Group(n), DmrppCommon()
52 {
53 }
54 
55 DmrppD4Group::DmrppD4Group(const string &n, const string &d) : D4Group(n, d), DmrppCommon()
56 {
57 }
58 
59 BaseType *
60 DmrppD4Group::ptr_duplicate()
61 {
62  return new DmrppD4Group(*this);
63 }
64 
65 DmrppD4Group::DmrppD4Group(const DmrppD4Group &rhs) : D4Group(rhs), DmrppCommon(rhs)
66 {
67  _duplicate(rhs);
68 }
69 
70 DmrppD4Group &
71 DmrppD4Group::operator=(const DmrppD4Group &rhs)
72 {
73  if (this == &rhs)
74  return *this;
75 
76  dynamic_cast<D4Group &>(*this) = rhs; // run Constructor=
77 
78  _duplicate(rhs);
79  DmrppCommon::m_duplicate_common(rhs);
80 
81  return *this;
82 }
83 
84 #if 0
85 void
86 DmrppD4Group::print_dap4(XMLWriter &xml, bool constrained)
87 {
88  if (!name().empty() && name() != "/") {
89  // For named groups, if constrained is true only print if this group
90  // has variables that are marked for transmission. For the root group
91  // this test is not made.
92  if (constrained && !send_p())
93  return;
94 
95  if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) type_name().c_str()) < 0)
96  throw InternalErr(__FILE__, __LINE__, "Could not write " + type_name() + " element");
97 
98  if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "name", (const xmlChar*) name().c_str()) < 0)
99  throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
100  }
101 
102  // dims
103  if (!dims()->empty())
104  dims()->print_dap4(xml, constrained);
105 
106  // enums
107  if (!enum_defs()->empty())
108  enum_defs()->print_dap4(xml, constrained);
109 
110  // variables
111  Constructor::Vars_iter v = var_begin();
112  while (v != var_end())
113  (*v++)->print_dap4(xml, constrained);
114 
115  // attributes
116  attributes()->print_dap4(xml);
117 
118  // groups
119  groupsIter g = d_groups.begin();
120  while (g != d_groups.end())
121  (*g++)->print_dap4(xml, constrained);
122 
123  if (!name().empty() && name() != "/") {
124  if (xmlTextWriterEndElement(xml.get_writer()) < 0)
125  throw InternalErr(__FILE__, __LINE__, "Could not end " + type_name() + " element");
126  }
127 }
128 #endif
129 
130 
131 void DmrppD4Group::dump(ostream & strm) const
132 {
133  strm << BESIndent::LMarg << "DmrppD4Group::dump - (" << (void *) this << ")" << endl;
134  BESIndent::Indent();
135  DmrppCommon::dump(strm);
136  D4Group::dump(strm);
137  strm << BESIndent::LMarg << "value: " << "----" << /*d_buf <<*/ endl;
138  BESIndent::UnIndent();
139 }
140 
141 } // namespace dmrpp
libdap
Definition: BESDapFunctionResponseCache.h:35