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