bes  Updated for version 3.20.8
DmrppInt32.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 "BESDebug.h"
30 #include "BESIndent.h"
31 
32 #include "byteswap_compat.h"
33 #include "DmrppInt32.h"
34 
35 using namespace libdap;
36 using namespace std;
37 
38 namespace dmrpp {
39 
40 void
41 DmrppInt32::_duplicate(const DmrppInt32 &)
42 {
43 }
44 
45 DmrppInt32::DmrppInt32(const string &n) : Int32(n), DmrppCommon()
46 {
47 }
48 
49 DmrppInt32::DmrppInt32(const string &n, const string &d) : Int32(n, d), DmrppCommon()
50 {
51 }
52 
53 BaseType *
54 DmrppInt32::ptr_duplicate()
55 {
56  return new DmrppInt32(*this);
57 }
58 
59 DmrppInt32::DmrppInt32(const DmrppInt32 &rhs) : Int32(rhs), DmrppCommon(rhs)
60 {
61  _duplicate(rhs);
62 }
63 
64 DmrppInt32 &
65 DmrppInt32::operator=(const DmrppInt32 &rhs)
66 {
67  if (this == &rhs)
68  return *this;
69 
70  dynamic_cast<Int32 &>(*this) = rhs; // run Constructor=
71 
72  _duplicate(rhs);
73  DmrppCommon::m_duplicate_common(rhs);
74 
75  return *this;
76 }
77 
78 bool
79 DmrppInt32::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_int32*>(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 void DmrppInt32::dump(ostream & strm) const
97 {
98  strm << BESIndent::LMarg << "DmrppInt32::dump - (" << (void *) this << ")" << endl;
99  BESIndent::Indent();
100  DmrppCommon::dump(strm);
101  Int32::dump(strm);
102  strm << BESIndent::LMarg << "value: " << d_buf << endl;
103  BESIndent::UnIndent();
104 }
105 
106 } // namespace dmrpp
107