bes  Updated for version 3.20.5
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 std::vector;
37 using std::string;
38 
39 using namespace libdap;
40 
41 namespace libdap {
42 class DDS;
43 class Marshaller;
44 class UnMarshaller;
45 }
46 
47 namespace ncml_module {
63 class RenamedArrayWrapper: public libdap::Array {
64 public:
67 
71  RenamedArrayWrapper(libdap::Array* toBeWrapped);
72 
73  virtual ~RenamedArrayWrapper();
74 
75  virtual RenamedArrayWrapper* ptr_duplicate();
76  RenamedArrayWrapper& operator=(const RenamedArrayWrapper& rhs);
77 
78  // Specializations
79 
80  virtual void add_constraint(Dim_iter i, int start, int stride, int stop);
81  virtual void reset_constraint();
82 
84  virtual void clear_constraint();
85 
86  virtual string toString();
87  virtual string toString() const;
88  virtual void dump(ostream &strm) const;
89 
90  // Don't need to override this, it does what we want.
91  // virtual void set_name(const string &n);
92 #if 0
93 
94  virtual bool is_simple_type() const;
95  virtual bool is_vector_type() const;
96  virtual bool is_constructor_type() const;
97 
98  virtual bool synthesized_p();
99  virtual void set_synthesized_p(bool state);
100 
101  virtual int element_count(bool leaves = false);
102 #endif
103 
104  virtual bool read_p();
105  virtual void set_read_p(bool state);
106 
107  virtual bool send_p();
108  virtual void set_send_p(bool state);
109 #if 0
110 
111  virtual libdap::AttrTable& get_attr_table();
112  virtual void set_attr_table(const libdap::AttrTable &at);
113 
114  virtual bool is_in_selection();
115  virtual void set_in_selection(bool state);
116 
117  virtual void set_parent(BaseType *parent);
118  virtual BaseType *get_parent() const;
119 #endif
120 
121  virtual BaseType *var(const string &name = "", bool exact_match = true, btp_stack *s = 0);
122  virtual BaseType *var(const string &name, btp_stack &s);
123  virtual void add_var(BaseType *bt, Part part = nil);
124  virtual void add_var_nocopy(BaseType *bt, Part part = nil);
125 
126 #if 0
127  virtual bool check_semantics(string &msg, bool all = false);
128  virtual bool ops(BaseType *b, int op);
129 #endif
130 
131 #if FILE_METHODS // from BaseType.h, whether we include FILE* methods
132  virtual void print_decl(FILE *out, string space = " ",
133  bool print_semi = true,
134  bool constraint_info = false,
135  bool constrained = false);
136  virtual void print_xml(FILE *out, string space = " ",
137  bool constrained = false);
138  virtual void print_val(FILE *out, string space = "",
139  bool print_decl_p = true);
140 #endif // FILE_METHODS
141 
142 #if 0
143  virtual void print_decl(ostream &out, string space = " ",
144  bool print_semi = true,
145  bool constraint_info = false,
146  bool constrained = false);
147  virtual void print_xml(ostream &out, string space = " ",
148  bool constrained = false);
149  virtual void print_val(ostream &out, string space = "",
150  bool print_decl_p = true);
151 
152  virtual unsigned int width(bool constrained = false);
153 #endif
154 
155  virtual unsigned int buf2val(void **val);
156  virtual unsigned int val2buf(void *val, bool reuse = false);
157 
158  virtual bool set_value(dods_byte *val, int sz);
159  virtual bool set_value(dods_int8 *val, int sz);
160  virtual bool set_value(dods_int16 *val, int sz);
161  virtual bool set_value(dods_uint16 *val, int sz);
162  virtual bool set_value(dods_int32 *val, int sz);
163  virtual bool set_value(dods_uint32 *val, int sz);
164  virtual bool set_value(dods_int64 *val, int sz);
165  virtual bool set_value(dods_uint64 *val, int sz);
166  virtual bool set_value(dods_float32 *val, int sz);
167  virtual bool set_value(dods_float64 *val, int sz);
168  virtual bool set_value(string *val, int sz);
169 
170  virtual bool set_value(vector<dods_byte> &val, int sz);
171  virtual bool set_value(vector<dods_int8> &val, int sz);
172  virtual bool set_value(vector<dods_int16> &val, int sz);
173  virtual bool set_value(vector<dods_uint16> &val, int sz);
174  virtual bool set_value(vector<dods_int32> &val, int sz);
175  virtual bool set_value(vector<dods_uint32> &val, int sz);
176  virtual bool set_value(vector<dods_int64> &val, int sz);
177  virtual bool set_value(vector<dods_uint64> &val, int sz);
178  virtual bool set_value(vector<dods_float32> &val, int sz);
179  virtual bool set_value(vector<dods_float64> &val, int sz);
180  virtual bool set_value(vector<string> &val, int sz);
181 
182  virtual void value(dods_byte *b) const;
183  virtual void value(dods_int8 *b) const;
184  virtual void value(dods_int16 *b) const;
185  virtual void value(dods_uint16 *b) const;
186  virtual void value(dods_int32 *b) const;
187  virtual void value(dods_uint32 *b) const;
188  virtual void value(dods_int64 *b) const;
189  virtual void value(dods_uint64 *b) const;
190  virtual void value(dods_float32 *b) const;
191  virtual void value(dods_float64 *b) const;
192  virtual void value(vector<string> &b) const;
193 
194  virtual void value(vector<unsigned int> *indices, dods_byte *b) const;
195  virtual void value(vector<unsigned int> *indices, dods_int8 *b) const;
196  virtual void value(vector<unsigned int> *indices, dods_int16 *b) const;
197  virtual void value(vector<unsigned int> *indices, dods_uint16 *b) const;
198  virtual void value(vector<unsigned int> *indices, dods_int32 *b) const;
199  virtual void value(vector<unsigned int> *indices, dods_uint32 *b) const;
200  virtual void value(vector<unsigned int> *indices, dods_int64 *b) const;
201  virtual void value(vector<unsigned int> *indices, dods_uint64 *b) const;
202  virtual void value(vector<unsigned int> *indices, dods_float32 *b) const;
203  virtual void value(vector<unsigned int> *indices, dods_float64 *b) const;
204  virtual void value(vector<unsigned int> *index, vector<string> &b) const;
205 
206  virtual void *value();
207 
208  virtual bool read();
209  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
210  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true);
211  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
212 
213 private:
214  // Private methods
215 
217  void copyLocalRepFrom(const RenamedArrayWrapper& proto);
218 
220  void destroy();
221 
222 #if 0
223 
224  void withNewName();
225 
227  void withOrgName();
228 #endif
229 
239  void syncConstraints() const
240  {
241  const_cast<RenamedArrayWrapper*>(this)->syncConstraints();
242  }
243  void syncConstraints();
244 
245 
246  template <typename T> void value_worker(T *v) const;
247  template <typename T> void value_worker(vector<unsigned int> *indices, T *b) const;
248 
249  template <typename T> bool set_value_worker(T *v, int sz);
250  template <typename T> bool set_value_worker(vector<T> &v, int sz);
251 
252 private:
253  // Data rep
254 
257  libdap::Array* _pArray;
258  string _orgName; // the original, underlying name of the array, cached.
259 };
260 
261 }
262 
263 #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:63