38 #include <BESResponseHandler.h>
39 #include <BESResponseNames.h>
40 #include <BESVersionInfo.h>
41 #include <BESDataNames.h>
42 #include <BESDataNames.h>
43 #include <TheBESKeys.h>
47 #include "FONcRequestHandler.h"
49 #define FONC_TEMP_DIR "/tmp"
50 #define FONC_TEMP_DIR_KEY "FONc.Tempdir"
55 #define FONC_BYTE_TO_SHORT true
56 #define FONC_BYTE_TO_SHORT_KEY "FONc.ByteToShort"
58 #define FONC_USE_COMP true
59 #define FONC_USE_COMP_KEY "FONc.UseCompression"
61 #define FONC_CHUNK_SIZE 4096
62 #define FONC_CHUNK_SIZE_KEY "FONc.ChunkSize"
64 #define FONC_CLASSIC_MODEL true
65 #define FONC_CLASSIC_MODEL_KEY "FONc.ClassicModel"
67 #define FONC_NO_GLOBAL_ATTRS false
68 #define FONC_NO_GLOBAL_ATTRS_KEY "FONc.NoGlobalAttrs"
70 std::string FONcRequestHandler::temp_dir;
71 bool FONcRequestHandler::byte_to_short;
72 bool FONcRequestHandler::use_compression;
73 int FONcRequestHandler::chunk_size;
74 bool FONcRequestHandler::classic_model;
75 bool FONcRequestHandler::no_global_attrs;
88 static void read_key_value(
const string &key_name,
bool &key,
const bool default_value)
90 bool key_found =
false;
96 key = (value ==
"true" || value ==
"yes");
103 static void read_key_value(
const string &key_name,
string &key,
const string &default_value)
105 bool key_found =
false;
109 if (key[key.length() - 1] ==
'/') key.erase(key.length() - 1);
116 static void read_key_value(
const string &key_name,
int &key,
const int default_value)
118 bool key_found =
false;
123 istringstream iss(value);
125 if (iss.eof() || iss.bad() || iss.fail()) key = default_value;
147 if (FONcRequestHandler::temp_dir.empty()) {
148 read_key_value(FONC_TEMP_DIR_KEY, FONcRequestHandler::temp_dir, FONC_TEMP_DIR);
152 read_key_value(FONC_BYTE_TO_SHORT_KEY, FONcRequestHandler::byte_to_short, FONC_BYTE_TO_SHORT);
154 read_key_value(FONC_USE_COMP_KEY, FONcRequestHandler::use_compression, FONC_USE_COMP);
156 read_key_value(FONC_CHUNK_SIZE_KEY, FONcRequestHandler::chunk_size, FONC_CHUNK_SIZE);
158 read_key_value(FONC_CLASSIC_MODEL_KEY, FONcRequestHandler::classic_model, FONC_CLASSIC_MODEL);
160 read_key_value(FONC_NO_GLOBAL_ATTRS_KEY, FONcRequestHandler::no_global_attrs, FONC_NO_GLOBAL_ATTRS);
162 BESDEBUG(
"fonc",
"FONcRequestHandler::temp_dir: " << FONcRequestHandler::temp_dir << endl);
163 BESDEBUG(
"fonc",
"FONcRequestHandler::byte_to_short: " << FONcRequestHandler::byte_to_short << endl);
164 BESDEBUG(
"fonc",
"FONcRequestHandler::use_compression: " << FONcRequestHandler::use_compression << endl);
165 BESDEBUG(
"fonc",
"FONcRequestHandler::chunk_size: " << FONcRequestHandler::chunk_size << endl);
166 BESDEBUG(
"fonc",
"FONcRequestHandler::classic_model: " << FONcRequestHandler::classic_model << endl);
167 BESDEBUG(
"fonc",
"FONcRequestHandler::turn_off_global_attrs: " << FONcRequestHandler::no_global_attrs << endl);
194 string key =
"FONc.Reference";
197 if (ref.empty()) ref =
"https://docs.opendap.org/index.php/BES_-_Modules_-_FileOut_Netcdf";
198 map<string, string> attrs;
199 attrs[
"name"] = MODULE_NAME;
200 attrs[
"version"] = MODULE_VERSION;
201 attrs[
"reference"] = ref;
202 info->begin_tag(
"module", &attrs);
203 info->end_tag(
"module");
221 info->add_module(MODULE_NAME, MODULE_VERSION);
235 strm << BESIndent::LMarg <<
"FONcRequestHandler::dump - ("
236 << (
void *)
this <<
")" << endl ;
237 BESIndent::Indent() ;
239 BESIndent::UnIndent() ;
Structure storing information used by the BES to handle the request.
informational response object
exception thrown if internal error encountered
Represents a specific data type request handler.
virtual bool add_method(const std::string &name, p_request_handler_method method)
add a handler method to the request handler that knows how to fill in a specific response object
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual BESResponseObject * get_response_object()
return the current response object
Abstract base class representing a specific set of information in response to a request to the BES.
static std::string lowercase(const std::string &s)
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual ~FONcRequestHandler(void)
Any cleanup that needs to take place.
FONcRequestHandler(const std::string &name)
Constructor for FileOut NetCDF module.
static bool build_help(BESDataHandlerInterface &dhi)
adds help information for FileOut NetCDF to a help request
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()