1 // -*- mode: c++; c-basic-offset:4 -*-
2
3 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5
6 // Copyright (c) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25 #include "config.h"
26
27 #ifndef WIN32
28 #include <unistd.h>
29 #else
30 #include <io.h>
31 #include <fcntl.h>
32 #include <process.h>
33 #endif
34
35 #include "TestInt8.h"
36
37 extern int test_variable_sleep_interval;
38
m_duplicate(const TestInt8 & ts)39 void TestInt8::m_duplicate(const TestInt8 &ts)
40 {
41 d_series_values = ts.d_series_values;
42 }
43
TestInt8(const string & n)44 TestInt8::TestInt8(const string &n) :
45 Int8(n), d_series_values(false)
46 {
47 d_buf = 1;
48 }
49
TestInt8(const string & n,const string & d)50 TestInt8::TestInt8(const string &n, const string &d) :
51 Int8(n, d), d_series_values(false)
52 {
53 d_buf = 1;
54 }
55
TestInt8(const TestInt8 & rhs)56 TestInt8::TestInt8(const TestInt8 &rhs) :
57 Int8(rhs), TestCommon(rhs)
58 {
59 m_duplicate(rhs);
60 }
61
62 TestInt8 &
operator =(const TestInt8 & rhs)63 TestInt8::operator=(const TestInt8 &rhs)
64 {
65 if (this == &rhs) return *this;
66
67 dynamic_cast<Int8 &>(*this) = rhs; // run Constructor=
68
69 m_duplicate(rhs);
70
71 return *this;
72 }
73
74 BaseType *
ptr_duplicate()75 TestInt8::ptr_duplicate()
76 {
77 return new TestInt8(*this);
78 }
79
output_values(std::ostream & out)80 void TestInt8::output_values(std::ostream &out)
81 {
82 print_val(out, "", false);
83 }
84
read()85 bool TestInt8::read()
86 {
87 if (read_p()) return true;
88
89 if (test_variable_sleep_interval > 0) sleep (test_variable_sleep_interval);
90
91 if (get_series_values()) {
92 d_buf = (dods_int8) (2 * d_buf);
93 }
94 else {
95 d_buf = 127;
96 }
97
98 set_read_p(true);
99
100 return true;
101 }
102