bes  Updated for version 3.20.10
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 
44 #define RETURN_AS_NETCDF "netcdf"
45 #define RETURN_AS_NETCDF4 "netcdf-4"
46 #define NC4_CLASSIC_MODEL "NC4_CLASSIC_MODEL"
47 #define NC4_ENHANCED "NC4_ENHANCED"
48 // May add netCDF-3 CDF-5 in the future.
49 
50 namespace libdap {
51 class BaseType;
52 class DDS;
53 class ConstraintEvaluator;
54 }
55 
56 //using namespace libdap;
57 
64 class FONcBaseType: public BESObj {
65 protected:
66  int _varid;
67  std::string _varname;
68  std::string _orig_varname;
69  std::vector<std::string> _embed;
70  bool _defined;
71  std::string _ncVersion;
72  std::string _nc4_datamodel;
73  bool is_dap4;
74 
75  //This is to handle the name clashing of dimension names of string type
76  bool is_dap4_group;
77 
78  libdap::DDS *d_dds;
79  libdap::ConstraintEvaluator *d_eval;
80 
81  FONcBaseType() : _varid(0), _defined(false), is_dap4(false), is_dap4_group(false), d_dds(nullptr), d_eval(nullptr) { }
82 
83 public:
84  virtual ~FONcBaseType() = default; // { }
85 
86  libdap::DDS *get_dds() const {return d_dds;}
87  void set_dds(libdap::DDS *dds) {d_dds = dds;}
88 
89  libdap::ConstraintEvaluator *get_eval() const {return d_eval;}
90  void set_eval(libdap::ConstraintEvaluator *eval) {d_eval = eval;}
91 
92  virtual void convert(std::vector<std::string> embed, bool is_dap4= false, bool is_dap4_group=false);
93  virtual void define(int ncid);
94  virtual void write(int ncid) = 0;
95 
96  virtual std::string name() = 0;
97  virtual nc_type type();
98  virtual void clear_embedded();
99  virtual int varid() const { return _varid; }
100 
101  virtual void dump(std::ostream &strm) const = 0;
102 
103  virtual void setVersion(const std::string &version);
104  virtual void setNC4DataModel(const string &nc4_datamodel);
105  virtual bool isNetCDF4();
106  virtual bool isNetCDF4_ENHANCED();
107  virtual void set_is_dap4(bool set_dap4) {is_dap4 = set_dap4;}
108  virtual libdap::AttrType getAttrType(nc_type t);
109  virtual D4AttributeType getD4AttrType(nc_type t);
110  virtual void updateD4AttrType(libdap::D4Attributes *d4_attrs, nc_type t);
111  virtual void updateAttrType(libdap::AttrTable& attrs, nc_type t);
112 };
113 
114 #endif // FONcBaseType_h_
115 
top level BES object to house generic methods
Definition: BESObj.h:50
A DAP BaseType with file out netcdf information included.
Definition: FONcBaseType.h:64
virtual void define(int ncid)
Define the variable in the netcdf file.
Definition: FONcBaseType.cc:60
virtual bool isNetCDF4()
Returns true if NetCDF4 features will be required.
virtual nc_type type()
Returns the type of data of this variable.
Definition: FONcBaseType.cc:86
virtual void clear_embedded()
Clears the list of embedded variable names.
Definition: FONcBaseType.cc:93
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.
virtual void dump(std::ostream &strm) const =0
dump the contents of this object to the specified ostream