bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
arrayT01.cc
1// arrayT01.cc
2
3#include <cstdlib>
4#include <fstream>
5#include <iostream>
6#include <sstream>
7
8using std::ofstream;
9using std::ios;
10using std::cerr;
11using std::endl;
12using std::ostringstream;
13
14#include <libdap/DataDDS.h>
15#include <libdap/Array.h>
16#include <libdap/Byte.h>
17#include <libdap/Int16.h>
18#include <libdap/Int32.h>
19#include <libdap/UInt16.h>
20#include <libdap/UInt32.h>
21#include <libdap/Float32.h>
22#include <libdap/Float64.h>
23#include <libdap/Str.h>
24#include <libdap/Error.h>
25
26using namespace libdap;
27
28#include <BESDataHandlerInterface.h>
29#include <BESDataNames.h>
30#include <BESDebug.h>
31
32#include "test_send_data.h"
33
34int main(int argc, char **argv)
35{
36 bool debug = false;
37 if (argc > 1) {
38 for (int i = 0; i < argc; i++) {
39 string arg = argv[i];
40 if (arg == "debug") {
41 debug = true;
42 }
43 }
44 }
45
46 try {
47 if (debug)
48 BESDebug::SetUp("cerr,fonc");
49
50 // build a DataDDS of simple type arrays with shared dimensions
51 DDS *dds = new DDS(NULL, "virtual");
52 {
53 Byte *b = new Byte("byte_array");
54 Array *a = new Array("array", b);
55 delete b;
56 b = 0;
57 a->append_dim(2, "dim1");
58 a->append_dim(5, "dim2");
59 dds->add_var(a);
60 delete a;
61 a = 0;
62
63 a = dynamic_cast<Array *>(dds->var("byte_array"));
64 if (!a) {
65 delete dds;
66 string err = "cast error for byte_array";
67 throw BESError(err, 0, __FILE__, __LINE__);
68 }
69
71 for (dods_byte i = 0; i < 10; i++) {
72 ba.push_back(i);
73 }
74 a->set_value(ba, ba.size());
75 }
76 {
77 Int16 *i16 = new Int16("i16_array");
78 Array *a = new Array("array", i16);
79 delete i16;
80 i16 = 0;
81 a->append_dim(2, "dim1");
82 a->append_dim(5, "dim2");
83 dds->add_var(a);
84 delete a;
85 a = 0;
86
87 a = dynamic_cast<Array *>(dds->var("i16_array"));
88 if (!a) {
89 delete dds;
90 string err = "cast error for i16_array";
91 throw BESError(err, 0, __FILE__, __LINE__);
92 }
93
95 for (dods_int16 i = 0; i < 10; i++) {
96 i16a.push_back(i * (-16));
97 }
98 a->set_value(i16a, i16a.size());
99 }
100 {
101 Int32 *i32 = new Int32("i32_array");
102 Array *a = new Array("array", i32);
103 delete i32;
104 i32 = 0;
105 a->append_dim(2, "dim1");
106 a->append_dim(5, "dim2");
107 dds->add_var(a);
108 delete a;
109 a = 0;
110
111 a = dynamic_cast<Array *>(dds->var("i32_array"));
112 if (!a) {
113 delete dds;
114 string err = "cast error for i32_array";
115 throw BESError(err, 0, __FILE__, __LINE__);
116 }
117
119 for (dods_int32 i = 0; i < 10; i++) {
120 i32a.push_back(i * (-512));
121 }
122 a->set_value(i32a, i32a.size());
123 }
124
125 build_dods_response(&dds, "./arrayT01.dods");
126
127 delete dds;
128 }
129 catch (BESError &e) {
130 cerr << e.get_message() << endl;
131 return 1;
132 }
133 catch (Error &e) {
134 cerr << e.get_error_message() << endl;
135 return 1;
136 }
137 catch (std::exception &e) {
138 cerr << e.what() << endl;
139 return 1;
140 }
141
142 return 0;
143}
144
static void SetUp(const std::string &values)
Sets up debugging for the bes.
Definition BESDebug.cc:91
Base exception class for the BES with basic string message.
Definition BESError.h:66
std::string get_message() const
get the error message for this exception
Definition BESError.h:132
STL class.