annotate main/octcdf/src/ov-ncvar.h @ 12565:f22c1e4bc9c5 octave-forge

Fix for compiling with octave 4.0.0-rc1
author abarth93
date Tue, 10 Mar 2015 13:53:33 +0000
parents f6ce163434cf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
1 /*
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
2 octcdf, a netcdf toolbox for octave
6299
6de947d278d2 update email
abarth93
parents: 4630
diff changeset
3 Copyright (C) 2005 Alexander Barth <barth.alexander@gmail.com>
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
4
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
5 This program is free software; you can redistribute it and/or
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
6 modify it under the terms of the GNU General Public License
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
7 as published by the Free Software Foundation; either version 2
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
8 of the License, or (at your option) any later version.
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
9
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
13 GNU General Public License for more details.
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
14
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
4404
2de537641f94 More copyright updates
adb014
parents: 3228
diff changeset
16 along with this program; If not, see <http://www.gnu.org/licenses/>.
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
17 */
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
18
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
19 #if !defined (octave_ncvar_int_h)
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
20 #define octave_ncvar_int_h 1
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
21
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
22 #include "ov-netcdf.h"
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
23
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
24 typedef struct {
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
25 std::list<std::string> dimnames;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
26 int dimids[NC_MAX_VAR_DIMS];
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
27
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
28 //std::list <std::string> dimnames;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
29 nc_type nctype;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
30 int ncid;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
31
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
32 // Octave-like dim_vector. A scale would have a dimension of 1x1
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
33 dim_vector dimvec;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
34
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
35 // NetCDF-like dim_vector. A scale would have a dimension of 0
3115
6f37f0008450 The shape of a netcdf variable is now stored in a vector<int> instead of a dim_vector since the number of dimension can be smaller than 2
abarth93
parents: 2413
diff changeset
36 vector<int> ncdimvec;
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
37
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
38 int varid, natts;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
39 octave_ncfile* ncfile;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
40 std::string varname;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
41 bool autoscale;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
42 bool autonan;
3228
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
43 int count;
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
44 } ncvar_t ;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
45
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
46 class octave_ncvar:public octave_base_value {
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
47 public:
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
48 octave_ncvar(void):octave_base_value(), ncv(NULL) {}
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
49
3228
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
50 octave_ncvar(const octave_ncvar& nc_val):octave_base_value(), ncv(nc_val.ncv) { ncv->count++; }
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
51
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
52 octave_ncvar(octave_ncfile* ncfilep, int varid);
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
53
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
54 octave_ncvar(octave_ncfile* ncfilep, std::string varnamep);
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
55
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
56 octave_ncvar(nc_type nctypep, std::list <std::string> dimnamesp):octave_base_value(), ncv(NULL) { }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
57
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
58 OV_REP_TYPE *clone(void) const { return new octave_ncvar(*this); }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
59
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
60 // x.v = y x(idx).v = y x{idx}.v = y
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
61
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
62 octave_value subsasgn(const std::string & type,
2413
7ee762e11903 Further package manager updates. All but miscellaneous and audio should build in main/. Some broken symlinks in image and octcdf still
adb014
parents: 2369
diff changeset
63 const std::list < octave_value_list > &idx,
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
64 const octave_value & rhs);
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
65
2413
7ee762e11903 Further package manager updates. All but miscellaneous and audio should build in main/. Some broken symlinks in image and octcdf still
adb014
parents: 2369
diff changeset
66 octave_value subsref(const std::string & type,
7ee762e11903 Further package manager updates. All but miscellaneous and audio should build in main/. Some broken symlinks in image and octcdf still
adb014
parents: 2369
diff changeset
67 const std::list < octave_value_list > &idx);
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
68
4630
e814711b4447 Address subsref case with nargout>1 case, needed for Octave 3.1.x.. Shouldn't cause issues with Octave 3.0.x
adb014
parents: 4404
diff changeset
69 octave_value_list subsref (const std::string& type,
e814711b4447 Address subsref case with nargout>1 case, needed for Octave 3.1.x.. Shouldn't cause issues with Octave 3.0.x
adb014
parents: 4404
diff changeset
70 const std::list<octave_value_list>& idx, int)
e814711b4447 Address subsref case with nargout>1 case, needed for Octave 3.1.x.. Shouldn't cause issues with Octave 3.0.x
adb014
parents: 4404
diff changeset
71 { return subsref (type, idx); }
e814711b4447 Address subsref case with nargout>1 case, needed for Octave 3.1.x.. Shouldn't cause issues with Octave 3.0.x
adb014
parents: 4404
diff changeset
72
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
73 octave_value_list do_multi_index_op(int, const octave_value_list &)
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
74 {
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
75 error("octave_object: do_multi_index_op(nargout,args)");
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
76 return octave_value_list();
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
77 }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
78
3228
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
79 // destructor
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
80 ~octave_ncvar();
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
81
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
82 void read_info();
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
83
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
84 /* Query Interface for octave */
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
85
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
86 // Get dim_vector following Octave conventions
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
87
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
88 dim_vector dims() const { return ncv->dimvec; }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
89
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
90 int ndims() const { return dims().length(); }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
91
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
92 octave_idx_type numel() const { return dims().numel(); }
7082
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
93
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
94 // This does not work:
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
95 //
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
96 // octave_idx_type numel(const octave_value_list&) { return dims().numel(); };
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
97 // It is necessary to make numel turn 1, otherwise the following fails:
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
98 //
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
99 // >> nc{'int_var'}.byte_att = ncbyte(1234);
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
100 // invalid assignment to cs-list outside multiple assignment.
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
101
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
102
f6ce163434cf fix problem with assignement of attributes (invalid assignment to cs-list outside multiple assignment)
abarth93
parents: 6944
diff changeset
103 octave_idx_type numel(const octave_value_list&) { return 1; };
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
104
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
105 // Get dim_vector following NetCDF conventions
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
106
3115
6f37f0008450 The shape of a netcdf variable is now stored in a vector<int> instead of a dim_vector since the number of dimension can be smaller than 2
abarth93
parents: 2413
diff changeset
107 vector<int> ncdims() const { return ncv->ncdimvec; }
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
108
3115
6f37f0008450 The shape of a netcdf variable is now stored in a vector<int> instead of a dim_vector since the number of dimension can be smaller than 2
abarth93
parents: 2413
diff changeset
109 int ncndims() const { return ncdims().size(); }
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
110
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
111
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
112 void print(std::ostream & os, bool pr_as_read_syntax) const;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
113
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
114 bool is_constant(void) const {
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
115 return true;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
116 }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
117 bool is_defined(void) const {
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
118 return true;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
119 }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
120 bool is_map(void) const {
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
121 return true;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
122 }
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
123
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
124 bool& autoscale() { return ncv->autoscale; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
125 bool autoscale() const { return ncv->autoscale; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
126
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
127 bool& autonan() { return ncv->autonan; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
128 bool autonan() const { return ncv->autonan; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
129
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
130 /* Query Interface for netcdf related information */
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
131
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
132 std::list<Range> get_slice(octave_value_list key_idx);
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
133
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
134 nc_type get_nctype(void) const { return ncv->nctype; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
135 octave_ncfile* get_ncfile() const { return ncv->ncfile; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
136 int get_varid() const { return ncv->varid; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
137 int get_ncid() const { return ncv->ncid; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
138 int get_natts() const { return ncv->natts; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
139 std::string get_varname() const { return ncv->varname; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
140 int get_dimid(int i) const { return ncv->dimids[i]; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
141 std::list<std::string> get_dimnames() const { return ncv->dimnames; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
142
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
143
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
144 void set_nctype(const nc_type t) { ncv->nctype = t; };
3228
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
145 void set_ncfile(const octave_ncfile* t) {
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
146 # ifdef OV_NETCDF_VERBOSE
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
147 octave_stdout << "copy constructor"<< endl;
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
148 # endif
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
149 ncv->ncfile = new octave_ncfile(*t);
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
150 };
643624495ca0 add reference counting for netcdf datatypes
abarth93
parents: 3115
diff changeset
151
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
152 void set_varid(const int& t) { ncv->varid = t; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
153 void set_ncid(const int& t) { ncv->ncid = t; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
154 void set_natts(const int& t) { ncv->natts = t; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
155 void set_varname(const std::string& t) { ncv->varname = t; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
156 void set_dimid(int i,int t) const { ncv->dimids[i] = t; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
157 void set_dimnames(const std::list<std::string> t) { ncv->dimnames = t; };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
158
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
159 void rename(string new_name);
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
160
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
161 ncvar_t* ncv;
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
162
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
163 private:
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
164
12565
f22c1e4bc9c5 Fix for compiling with octave 4.0.0-rc1
abarth93
parents: 7082
diff changeset
165 #ifdef DEFINE_OCTAVE_ALLOCATOR
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
166 DECLARE_OCTAVE_ALLOCATOR
12565
f22c1e4bc9c5 Fix for compiling with octave 4.0.0-rc1
abarth93
parents: 7082
diff changeset
167 #endif
2369
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
168 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
169 };
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
170
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
171
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
172 // end octave_ncvar
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
173
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
174 #endif
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
175
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
176 /*
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
177 ;;; Local Variables: ***
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
178 ;;; mode: C++ ***
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
179 ;;; End: ***
c1330cc812a2 Changed the directory structure to match the package system
hauberg
parents:
diff changeset
180 */