1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2002,2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #include "config.h"
27 
28 #ifndef WIN64
29 #include <unistd.h>
30 #else
31 #include <io.h>
32 #include <fcntl.h>
33 #include <process.h>
34 #endif
35 
36 //#define DODS_DEBUG
37 
38 #include "TestInt64.h"
39 #include "debug.h"
40 
41 extern int test_variable_sleep_interval;
42 
43 void
_duplicate(const TestInt64 & ts)44 TestInt64::_duplicate(const TestInt64 &ts)
45 {
46     d_series_values = ts.d_series_values;
47 }
48 
TestInt64(const string & n)49 TestInt64::TestInt64(const string &n) : Int64(n), d_series_values(false)
50 {
51     d_buf = 1;
52 }
53 
TestInt64(const string & n,const string &)54 TestInt64::TestInt64(const string &n, const string &)
55     : Int64(n), d_series_values(false)
56 {
57     d_buf = 1;
58 }
59 
TestInt64(const TestInt64 & rhs)60 TestInt64::TestInt64(const TestInt64 &rhs) : Int64(rhs), TestCommon(rhs)
61 {
62     _duplicate(rhs);
63 }
64 
65 TestInt64 &
operator =(const TestInt64 & rhs)66 TestInt64::operator=(const TestInt64 &rhs)
67 {
68     if (this == &rhs)
69 	return *this;
70 
71     dynamic_cast<Int64 &>(*this) = rhs; // run Constructor=
72 
73     _duplicate(rhs);
74 
75     return *this;
76 }
77 
78 BaseType *
ptr_duplicate()79 TestInt64::ptr_duplicate()
80 {
81     return new TestInt64(*this);
82 }
83 
84 void
output_values(std::ostream & out)85 TestInt64::output_values(std::ostream &out)
86 {
87     print_val(out, "", false);
88 }
89 
90 bool
read()91 TestInt64::read()
92 {
93     DBG(cerr << "Entering TestInt64::read for " << name() << endl);
94     if (read_p())
95 	return true;
96 
97     if (test_variable_sleep_interval > 0)
98 	sleep(test_variable_sleep_interval);
99 
100     if (get_series_values()) {
101     	// was d_buf = 64 * d_buf; but a change in the compiler broke eqiv code in Int32.cc
102     	// jhrg 3/12/14
103     	d_buf <<= 6;
104         if (!d_buf)
105             d_buf = 64;
106     }
107     else {
108         d_buf = 0x00ffffffffffffff;
109     }
110 
111     set_read_p(true);
112 
113     DBG(cerr << "In TestInt64::read, _buf = " << d_buf << endl);
114 
115     return true;
116 }
117