bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
FONcBaseType.h
1// FONcBaseType.h
2
3// This file is part of BES Netcdf File Out Module
4
5// Copyright (c) 2004,2005 University Corporation for Atmospheric Research
6// Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public
10// License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Lesser General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// You can contact University Corporation for Atmospheric Research at
23// 3080 Center Green Drive, Boulder, CO 80301
24
25// (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
26// Please read the full copyright statement in the file COPYRIGHT_UCAR.
27//
28// Authors:
29// pwest Patrick West <pwest@ucar.edu>
30// jgarcia Jose Garcia <jgarcia@ucar.edu>
31
32#ifndef FONcBaseType_h_
33#define FONcBaseType_h_ 1
34
35#include <netcdf.h>
36#include <vector>
37#include <string>
38
39#include <libdap/AttrTable.h>
40#include <libdap/D4Attributes.h>
41#include <libdap/D4AttributeType.h>
42#include <BESObj.h>
43#include "FONcNames.h"
44
45
46namespace libdap {
47class BaseType;
48class DDS;
49class ConstraintEvaluator;
50}
51
52//using namespace libdap;
53
60class FONcBaseType: public BESObj {
61protected:
62 int d_varid = 0;
63 std::string d_varname;
64 std::string d_orig_varname;
65 std::vector<std::string> d_embed;
66 bool d_defined = false;
67 std::string d_ncVersion;
68 std::string d_nc4_datamodel;
69 // This is set by transform_dap4() in FONCtranform.cc. Look for the call to convert()
70 // and/or the comment lines that mention d_is_dap with the date 2/14/24. jhrg 2/14/24
71 bool d_is_dap4 = false;
72
73 //This is to handle the name clashing of dimension names of string type
74 bool d_is_dap4_group = false;
75
76 libdap::DDS *d_dds = nullptr;
77 libdap::ConstraintEvaluator *d_eval = nullptr;
78
79 // direct io flag, used in the define mode,the default is false. It should be set to true when direct io is supported.
80 // TODO: This is for the temporary memory usage optimization. Once we can support the define() with or without dio for individual array.
81 // This flag is not necessary and should be removed. KY 11/29/23
82 bool fdio_flag = false;
83
84
85public:
86 FONcBaseType() = default;
87 ~FONcBaseType() override = default;
88
89 libdap::DDS *get_dds() const {return d_dds;}
90 void set_dds(libdap::DDS *dds) {d_dds = dds;}
91
92 libdap::ConstraintEvaluator *get_eval() const {return d_eval;}
93 void set_eval(libdap::ConstraintEvaluator *eval) {d_eval = eval;}
94
95 // I made this change to see how hard it would be to refactor a virtual
96 // method that used parameters with default (prohibited) values. jhrg 10/3/22
97 void convert(std::vector<std::string> embed) {
98 convert(embed, false, false);
99 }
100 void convert(std::vector<std::string> embed, bool is_dap4) {
101 convert(embed, is_dap4, false);
102 }
103 virtual void convert(std::vector<std::string> embed, bool is_dap4, bool is_dap4_group);
104
105 virtual void define(int ncid);
106
107 virtual void write(int ncid) = 0;
108
109 virtual std::string name() = 0;
110
111 virtual nc_type type();
112 virtual void clear_embedded();
113 virtual int varid() const { return d_varid; }
114
115 void dump(std::ostream &strm) const override = 0;
116
117 virtual void setVersion(const std::string &version);
118 virtual void setNC4DataModel(const string &nc4_datamodel);
119 virtual bool isNetCDF4();
120 bool isNetCDF4_ENHANCED();
121 virtual void set_is_dap4(bool set_dap4) { d_is_dap4 = set_dap4;}
122 virtual libdap::AttrType getAttrType(nc_type t);
123 virtual D4AttributeType getD4AttrType(nc_type t);
124 virtual void updateD4AttrType(libdap::D4Attributes *d4_attrs, nc_type t);
125 virtual void updateAttrType(libdap::AttrTable& attrs, nc_type t);
126
127 // TODO: This is for the temporary memory usage optimization. Once we can support the define() with or without dio for individual array.
128 // The following methods are not necessary and should be removed. KY 11/29/23
129 bool get_fdio_flag() const {return fdio_flag; }
130 void set_fdio_flag(bool dio_flag_value = true) { fdio_flag = dio_flag_value; }
131
132};
133
134#endif // FONcBaseType_h_
135
top level BES object to house generic methods
Definition BESObj.h:54
virtual void define(int ncid)
Define the variable in the netcdf file.
void dump(std::ostream &strm) const override=0
dump the contents of this object to the specified ostream
virtual bool isNetCDF4()
Returns true if NetCDF4 features will be required.
virtual nc_type type()
Returns the type of data of this variable.
virtual void clear_embedded()
Clears the list of embedded variable names.
virtual void setNC4DataModel(const string &nc4_datamodel)
Identifies the netCDF4 data model (CLASSIC or ENHANCED)
virtual void setVersion(const std::string &version)
Identifies variable with use of NetCDF4 features.