bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
simpleT00.cc
1// simpleT.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/Byte.h>
14#include <libdap/Int16.h>
15#include <libdap/Int32.h>
16#include <libdap/UInt16.h>
17#include <libdap/UInt32.h>
18#include <libdap/Float32.h>
19#include <libdap/Float64.h>
20#include <libdap/Str.h>
21#include <libdap/Error.h>
22
23using namespace libdap;
24
25#include <BESDataHandlerInterface.h>
26#include <BESDapResponseBuilder.h>
27#include <BESDataNames.h>
28#include <BESDebug.h>
29
30//#include "test_config.h"
31#include "test_send_data.h"
32
33int main(int argc, char **argv)
34{
35 bool debug = false;
36 bool dods_response = false; // write either a .dods or a netcdf file
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 else if (arg == "dods") {
44 dods_response = true;
45 }
46 }
47 }
48
49 try {
50 if (debug) {
51 BESDebug::SetUp("cerr,fonc");
52 }
53
54 // build a DataDDS of simple types and set values for each of the
55 // simple types.
56 DDS *dds = new DDS(NULL, "virtual");
57
58 Byte b("byte");
59 b.set_value(28);
60 dds->add_var(&b);
61
62 Int16 i16("i16");
63 i16.set_value(-2048);
64 dds->add_var(&i16);
65
66 Int32 i32("i32");
67 i32.set_value(-105467);
68 dds->add_var(&i32);
69
70 UInt16 ui16("ui16");
71 ui16.set_value(2048);
72 dds->add_var(&ui16);
73
74 UInt32 ui32("ui32");
75 ui32.set_value(105467);
76 dds->add_var(&ui32);
77
78 Float32 f32("f32");
79 f32.set_value(5.7866);
80 dds->add_var(&f32);
81
82 Float64 f64("f64");
83 f64.set_value(10245.1234);
84 dds->add_var(&f64);
85
86 Str s("str");
87 s.set_value("This is a String Value");
88 dds->add_var(&s);
89
90 build_dods_response(&dds, "./simpleT00.dods");
91
92 delete dds;
93 }
94 catch (BESError &e) {
95 cerr << e.get_message() << endl;
96 return 1;
97 }
98 catch (Error &e) {
99 cerr << e.get_error_message() << endl;
100 return 1;
101 }
102 catch (std::exception &e) {
103 cerr << e.what() << endl;
104 return 1;
105 }
106
107 return 0;
108}
109
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