bes  Updated for version 3.20.8
DmrppUInt32.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 <BESError.h>
30 #include <BESDebug.h>
31 
32 #include "byteswap_compat.h"
33 #include "DmrppUInt32.h"
34 
35 using namespace libdap;
36 using namespace std;
37 
38 namespace dmrpp {
39 
40 void
41 DmrppUInt32::_duplicate(const DmrppUInt32 &)
42 {
43 }
44 
45 DmrppUInt32::DmrppUInt32(const string &n) : UInt32(n), DmrppCommon()
46 {
47 }
48 
49 DmrppUInt32::DmrppUInt32(const string &n, const string &d) : UInt32(n, d), DmrppCommon()
50 {
51 }
52 
53 BaseType *
54 DmrppUInt32::ptr_duplicate()
55 {
56  return new DmrppUInt32(*this);
57 }
58 
59 DmrppUInt32::DmrppUInt32(const DmrppUInt32 &rhs) : UInt32(rhs), DmrppCommon(rhs)
60 {
61  _duplicate(rhs);
62 }
63 
64 DmrppUInt32 &
65 DmrppUInt32::operator=(const DmrppUInt32 &rhs)
66 {
67  if (this == &rhs)
68  return *this;
69 
70  dynamic_cast<UInt32 &>(*this) = rhs; // run Constructor=
71 
72  _duplicate(rhs);
73  DmrppCommon::m_duplicate_common(rhs);
74 
75  return *this;
76 }
77 
78 bool
79 DmrppUInt32::read()
80 {
81  BESDEBUG("dmrpp", "Entering " <<__PRETTY_FUNCTION__ << " for '" << name() << "'" << endl);
82 
83  if (read_p())
84  return true;
85 
86  set_value(*reinterpret_cast<dods_uint32*>(read_atomic(name())));
87 
88  if ( this->twiddle_bytes() ) {
89  d_buf = bswap_32(d_buf);
90  }
91  set_read_p(true);
92 
93  return true;
94 
95 }
96 
97 
98 void DmrppUInt32::dump(ostream & strm) const
99 {
100  strm << BESIndent::LMarg << "DmrppUInt32::dump - (" << (void *) this << ")" << endl;
101  BESIndent::Indent();
102  DmrppCommon::dump(strm);
103  UInt32::dump(strm);
104  strm << BESIndent::LMarg << "value: " << d_buf << endl;
105  BESIndent::UnIndent();
106 }
107 
108 } // namespace dmrpp
109