OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
RenamedArrayWrapper.h
Go to the documentation of this file.
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 using std::vector;
36 using std::string;
37 using namespace libdap;
38 
39 namespace libdap
40 {
41  class DDS;
42  class Marshaller;
43  class UnMarshaller;
44 }
45 
46 namespace ncml_module
47 {
63  class RenamedArrayWrapper : public libdap::Array
64  {
65  public:
68 
72  RenamedArrayWrapper(libdap::Array* toBeWrapped);
73 
74  virtual ~RenamedArrayWrapper();
75 
76  virtual RenamedArrayWrapper* ptr_duplicate();
77  RenamedArrayWrapper& operator=(const RenamedArrayWrapper& rhs);
78 
79  // OVERRIDES OF ALL VIRTUALS!
80 
81  virtual void add_constraint(Dim_iter i, int start, int stride, int stop);
82  virtual void reset_constraint();
83 
85  virtual void clear_constraint();
86 
87  virtual string toString();
88  virtual string toString() const;
89  virtual void dump(ostream &strm) const ;
90 
91  // Don't need to override this, it does what we want.
92  // virtual void set_name(const string &n);
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 
103  virtual bool read_p();
104  virtual void set_read_p(bool state);
105 
106  virtual bool send_p();
107  virtual void set_send_p(bool state);
108 
109  virtual libdap::AttrTable& get_attr_table();
110  virtual void set_attr_table(const libdap::AttrTable &at);
111 
112  virtual bool is_in_selection();
113  virtual void set_in_selection(bool state);
114 
115  virtual void set_parent(BaseType *parent);
116  virtual BaseType *get_parent() const;
117 
118  virtual BaseType *var(const string &name = "", bool exact_match = true,
119  btp_stack *s = 0);
120  virtual BaseType *var(const string &name, btp_stack &s);
121  virtual void add_var(BaseType *bt, Part part = nil);
122 
123  virtual bool read();
124  virtual bool check_semantics(string &msg, bool all = false);
125  virtual bool ops(BaseType *b, int op);
126 
127 #if FILE_METHODS // from BaseType.h, whether we include FILE* methods
128  virtual void print_decl(FILE *out, string space = " ",
129  bool print_semi = true,
130  bool constraint_info = false,
131  bool constrained = false);
132  virtual void print_xml(FILE *out, string space = " ",
133  bool constrained = false);
134  virtual void print_val(FILE *out, string space = "",
135  bool print_decl_p = true);
136 #endif // FILE_METHODS
137 
138  virtual void print_decl(ostream &out, string space = " ",
139  bool print_semi = true,
140  bool constraint_info = false,
141  bool constrained = false);
142  virtual void print_xml(ostream &out, string space = " ",
143  bool constrained = false);
144  virtual void print_val(ostream &out, string space = "",
145  bool print_decl_p = true);
146 
147 
148  virtual unsigned int width(bool constrained = false);
149  virtual unsigned int buf2val(void **val);
150  virtual unsigned int val2buf(void *val, bool reuse = false);
151 
152  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
153  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds,
154  Marshaller &m, bool ce_eval = true);
155  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
156 
157  virtual bool set_value(dods_byte *val, int sz);
158  virtual bool set_value(vector<dods_byte> &val, int sz);
159  virtual bool set_value(dods_int16 *val, int sz);
160  virtual bool set_value(vector<dods_int16> &val, int sz);
161  virtual bool set_value(dods_uint16 *val, int sz);
162  virtual bool set_value(vector<dods_uint16> &val, int sz);
163  virtual bool set_value(dods_int32 *val, int sz);
164  virtual bool set_value(vector<dods_int32> &val, int sz);
165  virtual bool set_value(dods_uint32 *val, int sz);
166  virtual bool set_value(vector<dods_uint32> &val, int sz);
167  virtual bool set_value(dods_float32 *val, int sz);
168  virtual bool set_value(vector<dods_float32> &val, int sz);
169  virtual bool set_value(dods_float64 *val, int sz);
170  virtual bool set_value(vector<dods_float64> &val, int sz);
171  virtual bool set_value(string *val, int sz);
172  virtual bool set_value(vector<string> &val, int sz);
173 
174  virtual void value(dods_byte *b) const;
175  virtual void value(dods_int16 *b) const;
176  virtual void value(dods_uint16 *b) const;
177  virtual void value(dods_int32 *b) const;
178  virtual void value(dods_uint32 *b) const;
179  virtual void value(dods_float32 *b) const;
180  virtual void value(dods_float64 *b) const;
181  virtual void value(vector<string> &b) const;
182  virtual void *value();
183 
184  private: // Private methods
185 
187  void copyLocalRepFrom(const RenamedArrayWrapper& proto);
188 
190  void destroy();
191 
193  void withNewName();
194 
196  void withOrgName();
197 
207  void syncConstraints() const { const_cast<RenamedArrayWrapper*>(this)->syncConstraints(); }
208  void syncConstraints();
209 
210  private: // Data rep
211 
214  libdap::Array* _pArray;
215  string _orgName; // the original, underlying name of the array, cached.
216  };
217 
218 }
219 
220 #endif /* __NCML_MODULE__RENAMED_ARRAY_WRAPPER_H__ */
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
static class NCMLUtil overview
A Decorator Pattern for wrapping a libdap::Array in order to change its name efficiently in the face ...