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 "TestD4Enum.h"
39 #include "debug.h"
40
41 extern int test_variable_sleep_interval;
42
43 void
_duplicate(const TestD4Enum & ts)44 TestD4Enum::_duplicate(const TestD4Enum &ts)
45 {
46 d_series_values = ts.d_series_values;
47 }
48
TestD4Enum(const string & n,Type t)49 TestD4Enum::TestD4Enum(const string &n, Type t) : D4Enum(n, t), TestCommon(), d_series_values(false)
50 {
51 set_value(0);
52 }
53
TestD4Enum(const string & n,const string & d,Type t)54 TestD4Enum::TestD4Enum(const string &n, const string &d, Type t)
55 : D4Enum(n, d, t), TestCommon(), d_series_values(false)
56 {
57 set_value(0);
58 }
59
TestD4Enum(const TestD4Enum & rhs)60 TestD4Enum::TestD4Enum(const TestD4Enum &rhs) : D4Enum(rhs), TestCommon(rhs)
61 {
62 _duplicate(rhs);
63 }
64
65 TestD4Enum &
operator =(const TestD4Enum & rhs)66 TestD4Enum::operator=(const TestD4Enum &rhs)
67 {
68 if (this == &rhs)
69 return *this;
70
71 dynamic_cast<D4Enum &>(*this) = rhs; // run Constructor=
72
73 _duplicate(rhs);
74
75 return *this;
76 }
77
78 BaseType *
ptr_duplicate()79 TestD4Enum::ptr_duplicate()
80 {
81 return new TestD4Enum(*this);
82 }
83
84 void
output_values(std::ostream & out)85 TestD4Enum::output_values(std::ostream &out)
86 {
87 print_val(out, "", false);
88 }
89
read()90 bool TestD4Enum::read() {
91 DBG(cerr << "Entering TestD4Enum::read for " << name() << endl);
92 if (read_p()) return true;
93
94 if (test_variable_sleep_interval > 0) sleep(test_variable_sleep_interval);
95
96 if (get_series_values()) {
97 int64_t v;
98 value(&v);
99 if (v == 3)
100 set_value(1);
101 else
102 set_value(v + 1);
103 }
104 else {
105 set_value(1);
106 }
107
108 set_read_p(true);
109
110 DBG(cerr << "In TestD4Enum::read, _buf = " << d_buf << endl);
111
112 return true;
113 }
114