bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
structT01.cc
1// structT.cc
2
3#include <cstdlib>
4#include <fstream>
5#include <iostream>
6
7using std::ofstream;
8using std::ios;
9using std::cerr;
10using std::endl;
11
12#include <libdap/DataDDS.h>
13#include <libdap/Structure.h>
14#include <libdap/Array.h>
15#include <libdap/Byte.h>
16#include <libdap/Int16.h>
17#include <libdap/Int32.h>
18#include <libdap/UInt16.h>
19#include <libdap/UInt32.h>
20#include <libdap/Float32.h>
21#include <libdap/Float64.h>
22#include <libdap/Str.h>
23#include <libdap/Error.h>
24
25using namespace libdap;
26
27#include <BESDataHandlerInterface.h>
28#include <BESDataNames.h>
29#include <BESDebug.h>
30
31#include "test_send_data.h"
32
33int main(int argc, char **argv)
34{
35 bool debug = false;
36 if (argc > 1) {
37 for (int i = 0; i < argc; i++) {
38 string arg = argv[i];
39 if (arg == "debug") {
40 debug = true;
41 }
42 }
43 }
44
45 try {
46 if (debug)
47 BESDebug::SetUp("cerr,fonc");
48
49 // nested structures
50 DDS *dds = new DDS(NULL, "virtual");
51
52 Structure s1("s1");
53 Structure s2("s2");
54 Structure s3("s3");
55
56 Byte b("byte");
57 b.set_value(28);
58 s1.add_var(&b);
59
60 Int16 i16("i16");
61 i16.set_value(-2048);
62 s2.add_var(&i16);
63
64 Int32 i32("i32");
65 i32.set_value(-105467);
66 s3.add_var(&i32);
67
68 UInt16 ui16("ui16");
69 ui16.set_value(2048);
70 s1.add_var(&ui16);
71
72 UInt32 ui32("ui32a");
73 Array a("array", &ui32);
74 a.append_dim(2, "ui32a_dim1");
75 a.append_dim(5, "ui32a_dim2");
77 int numi = 0;
78 dods_uint32 i = 10532;
79 for (; numi < 10; numi++) {
80 ua.push_back(i);
81 i += 14992;
82 }
83 a.set_value(ua, ua.size());
84 s2.add_var(&a);
85
86 Float32 f32("f32");
87 f32.set_value(5.7866);
88 s3.add_var(&f32);
89
90 Float64 f64("f64");
91 f64.set_value(10245.1234);
92 s1.add_var(&f64);
93
94 Str str("str");
95 str.set_value("This is a String Value");
96 s2.add_var(&str);
97
98 s2.add_var(&s3);
99 s1.add_var(&s2);
100
101 dds->add_var(&s1);
102
103 build_dods_response(&dds, "./structT01.dods");
104
105 delete dds;
106 }
107 catch (BESError &e) {
108 cerr << e.get_message() << endl;
109 return 1;
110 }
111 catch (Error &e) {
112 cerr << e.get_error_message() << endl;
113 return 1;
114 }
115 catch (std::exception &e) {
116 cerr << e.what() << endl;
117 return 1;
118 }
119
120 return 0;
121}
122
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.