bes  Updated for version 3.20.8
DmrppUInt64.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 "DmrppUInt64.h"
34 
35 using namespace libdap;
36 using namespace std;
37 
38 namespace dmrpp {
39 
40 void
41 DmrppUInt64::_duplicate(const DmrppUInt64 &)
42 {
43 }
44 
45 DmrppUInt64::DmrppUInt64(const string &n) : UInt64(n), DmrppCommon()
46 {
47 }
48 
49 DmrppUInt64::DmrppUInt64(const string &n, const string &d) : UInt64(n, d), DmrppCommon()
50 {
51 }
52 
53 BaseType *
54 DmrppUInt64::ptr_duplicate()
55 {
56  return new DmrppUInt64(*this);
57 }
58 
59 DmrppUInt64::DmrppUInt64(const DmrppUInt64 &rhs) : UInt64(rhs), DmrppCommon(rhs)
60 {
61  _duplicate(rhs);
62 }
63 
64 DmrppUInt64 &
65 DmrppUInt64::operator=(const DmrppUInt64 &rhs)
66 {
67  if (this == &rhs)
68  return *this;
69 
70  dynamic_cast<UInt64 &>(*this) = rhs; // run Constructor=
71 
72  _duplicate(rhs);
73  DmrppCommon::m_duplicate_common(rhs);
74 
75  return *this;
76 }
77 
78 bool
79 DmrppUInt64::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_uint64*>(read_atomic(name())));
87 
88  if ( this->twiddle_bytes() ) {
89  d_buf = bswap_64(d_buf);
90  }
91  set_read_p(true);
92 
93  return true;
94 
95 }
96 
97 void DmrppUInt64::dump(ostream & strm) const
98 {
99  strm << BESIndent::LMarg << "DmrppUInt64::dump - (" << (void *) this << ")" << endl;
100  BESIndent::Indent();
101  DmrppCommon::dump(strm);
102  UInt64::dump(strm);
103  strm << BESIndent::LMarg << "value: " << d_buf << endl;
104  BESIndent::UnIndent();
105 }
106 
107 } // namespace dmrpp