bes  Updated for version 3.20.6
RenamedArrayWrapper.h
1 // This file is part of the "NcML Module" project, a BES module designed
3 // to allow NcML files to be used to be used as a wrapper to add
4 // AIS to existing datasets of any format.
5 //
6 // Copyright (c) 2009 OPeNDAP, Inc.
7 // Author: Michael Johnson <m.johnson@opendap.org>
8 //
9 // For more information, please also see the main website: http://opendap.org/
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26 //
27 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29 #ifndef __NCML_MODULE__RENAMED_ARRAY_WRAPPER_H__
30 #define __NCML_MODULE__RENAMED_ARRAY_WRAPPER_H__
31 
32 #include "config.h"
33 #include <Array.h>
34 #include <vector>
35 
36 using namespace libdap;
37 
38 namespace libdap {
39 class DDS;
40 class Marshaller;
41 class UnMarshaller;
42 }
43 
44 namespace ncml_module {
60 class RenamedArrayWrapper: public libdap::Array {
61 public:
64 
68  RenamedArrayWrapper(libdap::Array* toBeWrapped);
69 
70  virtual ~RenamedArrayWrapper();
71 
72  virtual RenamedArrayWrapper* ptr_duplicate();
73  RenamedArrayWrapper& operator=(const RenamedArrayWrapper& rhs);
74 
75  // Specializations
76 
77  virtual void add_constraint(Dim_iter i, int start, int stride, int stop);
78  virtual void reset_constraint();
79 
81  virtual void clear_constraint();
82 
83  virtual string toString();
84  virtual string toString() const;
85  virtual void dump(ostream &strm) const;
86 
87  // Don't need to override this, it does what we want.
88  // virtual void set_name(const string &n);
89 #if 0
90 
91  virtual bool is_simple_type() const;
92  virtual bool is_vector_type() const;
93  virtual bool is_constructor_type() const;
94 
95  virtual bool synthesized_p();
96  virtual void set_synthesized_p(bool state);
97 
98  virtual int element_count(bool leaves = false);
99 #endif
100 
101  virtual bool read_p();
102  virtual void set_read_p(bool state);
103 
104  virtual bool send_p();
105  virtual void set_send_p(bool state);
106 #if 0
107 
108  virtual libdap::AttrTable& get_attr_table();
109  virtual void set_attr_table(const libdap::AttrTable &at);
110 
111  virtual bool is_in_selection();
112  virtual void set_in_selection(bool state);
113 
114  virtual void set_parent(BaseType *parent);
115  virtual BaseType *get_parent() const;
116 #endif
117 
118  virtual BaseType *var(const string &name = "", bool exact_match = true, btp_stack *s = 0);
119  virtual BaseType *var(const string &name, btp_stack &s);
120  virtual void add_var(BaseType *bt, Part part = nil);
121  virtual void add_var_nocopy(BaseType *bt, Part part = nil);
122 
123 #if 0
124  virtual bool check_semantics(string &msg, bool all = false);
125  virtual bool ops(BaseType *b, int op);
126 #endif
127 
128 #if FILE_METHODS // from BaseType.h, whether we include FILE* methods
129  virtual void print_decl(FILE *out, string space = " ",
130  bool print_semi = true,
131  bool constraint_info = false,
132  bool constrained = false);
133  virtual void print_xml(FILE *out, string space = " ",
134  bool constrained = false);
135  virtual void print_val(FILE *out, string space = "",
136  bool print_decl_p = true);
137 #endif // FILE_METHODS
138 
139 #if 0
140  virtual void print_decl(ostream &out, string space = " ",
141  bool print_semi = true,
142  bool constraint_info = false,
143  bool constrained = false);
144  virtual void print_xml(ostream &out, string space = " ",
145  bool constrained = false);
146  virtual void print_val(ostream &out, string space = "",
147  bool print_decl_p = true);
148 
149  virtual unsigned int width(bool constrained = false);
150 #endif
151 
152  virtual unsigned int buf2val(void **val);
153  virtual unsigned int val2buf(void *val, bool reuse = false);
154 
155  virtual bool set_value(dods_byte *val, int sz);
156  virtual bool set_value(dods_int8 *val, int sz);
157  virtual bool set_value(dods_int16 *val, int sz);
158  virtual bool set_value(dods_uint16 *val, int sz);
159  virtual bool set_value(dods_int32 *val, int sz);
160  virtual bool set_value(dods_uint32 *val, int sz);
161  virtual bool set_value(dods_int64 *val, int sz);
162  virtual bool set_value(dods_uint64 *val, int sz);
163  virtual bool set_value(dods_float32 *val, int sz);
164  virtual bool set_value(dods_float64 *val, int sz);
165  virtual bool set_value(string *val, int sz);
166 
167  virtual bool set_value(vector<dods_byte> &val, int sz);
168  virtual bool set_value(vector<dods_int8> &val, int sz);
169  virtual bool set_value(vector<dods_int16> &val, int sz);
170  virtual bool set_value(vector<dods_uint16> &val, int sz);
171  virtual bool set_value(vector<dods_int32> &val, int sz);
172  virtual bool set_value(vector<dods_uint32> &val, int sz);
173  virtual bool set_value(vector<dods_int64> &val, int sz);
174  virtual bool set_value(vector<dods_uint64> &val, int sz);
175  virtual bool set_value(vector<dods_float32> &val, int sz);
176  virtual bool set_value(vector<dods_float64> &val, int sz);
177  virtual bool set_value(vector<string> &val, int sz);
178 
179  virtual void value(dods_byte *b) const;
180  virtual void value(dods_int8 *b) const;
181  virtual void value(dods_int16 *b) const;
182  virtual void value(dods_uint16 *b) const;
183  virtual void value(dods_int32 *b) const;
184  virtual void value(dods_uint32 *b) const;
185  virtual void value(dods_int64 *b) const;
186  virtual void value(dods_uint64 *b) const;
187  virtual void value(dods_float32 *b) const;
188  virtual void value(dods_float64 *b) const;
189  virtual void value(vector<string> &b) const;
190 
191  virtual void value(vector<unsigned int> *indices, dods_byte *b) const;
192  virtual void value(vector<unsigned int> *indices, dods_int8 *b) const;
193  virtual void value(vector<unsigned int> *indices, dods_int16 *b) const;
194  virtual void value(vector<unsigned int> *indices, dods_uint16 *b) const;
195  virtual void value(vector<unsigned int> *indices, dods_int32 *b) const;
196  virtual void value(vector<unsigned int> *indices, dods_uint32 *b) const;
197  virtual void value(vector<unsigned int> *indices, dods_int64 *b) const;
198  virtual void value(vector<unsigned int> *indices, dods_uint64 *b) const;
199  virtual void value(vector<unsigned int> *indices, dods_float32 *b) const;
200  virtual void value(vector<unsigned int> *indices, dods_float64 *b) const;
201  virtual void value(vector<unsigned int> *index, vector<string> &b) const;
202 
203  virtual void *value();
204 
205  virtual bool read();
206  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
207  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true);
208  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
209 
210 private:
211  // Private methods
212 
214  void copyLocalRepFrom(const RenamedArrayWrapper& proto);
215 
217  void destroy();
218 
219 #if 0
220 
221  void withNewName();
222 
224  void withOrgName();
225 #endif
226 
236  void syncConstraints() const
237  {
238  const_cast<RenamedArrayWrapper*>(this)->syncConstraints();
239  }
240  void syncConstraints();
241 
242 
243  template <typename T> void value_worker(T *v) const;
244  template <typename T> void value_worker(vector<unsigned int> *indices, T *b) const;
245 
246  template <typename T> bool set_value_worker(T *v, int sz);
247  template <typename T> bool set_value_worker(vector<T> &v, int sz);
248 
249 private:
250  // Data rep
251 
254  libdap::Array* _pArray;
255  string _orgName; // the original, underlying name of the array, cached.
256 };
257 
258 }
259 
260 #endif /* __NCML_MODULE__RENAMED_ARRAY_WRAPPER_H__ */
libdap
Definition: BESDapFunctionResponseCache.h:35
ncml_module
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...
Definition: AggregationElement.cc:72
ncml_module::RenamedArrayWrapper
A Decorator Pattern for wrapping a libdap::Array in order to change its name efficiently in the face ...
Definition: RenamedArrayWrapper.h:60