OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
VariableElement.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__VARIABLE_ELEMENT_H__
30 #define __NCML_MODULE__VARIABLE_ELEMENT_H__
31 
32 #include "NCMLElement.h"
33 
34 namespace libdap
35 {
36  class BaseType;
37 }
38 
39 namespace ncml_module
40 {
41 
61  {
62  private:
63  VariableElement& operator=(const VariableElement& rhs); // disallow
64 
65  public:
66  static const string _sTypeName;
67  static const vector<string> _sValidAttributes;
68 
70  VariableElement(const VariableElement& proto);
71  virtual ~VariableElement();
72  virtual const string& getTypeName() const;
73  virtual VariableElement* clone() const; // override clone with more specific subclass
74  virtual void setAttributes(const XMLAttributeMap& attrs);
75  virtual void handleBegin();
76  virtual void handleContent(const string& content);
77  virtual void handleEnd();
78  virtual string toString() const;
79 
80  const std::string name() const
81  {
82  return _name;
83  }
84 
85  const std::string type() const
86  {
87  return _type;
88  }
89 
90  const std::string shape() const
91  {
92  return _shape;
93  }
94 
95  const std::string orgName() const
96  {
97  return _orgName;
98  }
99 
101  bool isNewVariable() const;
102 
106  bool checkGotValues() const;
107 
109  void setGotValues();
110 
111  private:
112 
120  void processBegin(NCMLParser& p);
121 
129  void processEnd(NCMLParser& p);
130 
137  void processExistingVariable(NCMLParser& p, libdap::BaseType* pVar);
138 
152  void processRenameVariable(NCMLParser& p);
153 
167  void processNewVariable(NCMLParser& p);
168 
173  void processNewStructure(NCMLParser& p);
174 
180  void processNewScalar(NCMLParser& p, const std::string& dapType);
181 
194  void processNewArray(NCMLParser& p, const std::string& dapType);
195 
203  libdap::BaseType* replaceArrayIfNeeded(NCMLParser& p, libdap::BaseType* pOrgVar, const string& name);
204 
214  void addNewVariableAndEnterScope(NCMLParser& p, const std::string& dapType);
215 
219  void enterScope(NCMLParser& p, libdap::BaseType* pVar);
220 
222  void exitScope(NCMLParser& p);
223 
227  bool isDimensionNumericConstant(const std::string& dimToken) const;
232  unsigned int getSizeForDimension(NCMLParser& p, const std::string& dimToken) const;
233 
249  unsigned int getProductOfDimensionSizes(NCMLParser& p) const;
250 
251  static vector<string> getValidAttributes();
252 
253  private:
254  string _name;
255  string _type;
256  string _shape; // empty() => existing var (shape implicit) or if new var, then scalar (rank 0).
257  string _orgName; // if !empty(), the name of existing variable we want to rename to _name
258 
259  // Ephemeral state below
260 
261  // tokenized version of _shape for dimensions
262  vector<string> _shapeTokens;
263 
264  // if not null, this element created this var and it exists in the dds of the containing dataset
265  libdap::BaseType* _pNewlyCreatedVar;
266 
267  // true once we get a valid <values> element with values in it. Used for parse error checking
268  bool _gotValues;
269  };
270 
271 }
272 
273 #endif /* __NCML_MODULE__VARIABLE_ELEMENT_H__ */
virtual void setAttributes(const XMLAttributeMap &attrs)
Set the attributes of this from the map.
const std::string type() const
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
virtual void handleBegin()
Handle a begin on this element.
const std::string shape() const
static class NCMLUtil overview
virtual string toString() const
Return a string describing the element.
virtual void handleContent(const string &content)
Handle the characters content for the element.
const std::string orgName() const
virtual VariableElement * clone() const
Make and return a copy of this.
Base class for NcML element concrete classes.
Definition: NCMLElement.h:64
static const string _sTypeName
static const vector< string > _sValidAttributes
Concrete class for NcML element.
virtual const string & getTypeName() const
Return the type of the element, which should be: the same as ConcreteClassName::getTypeName() ...
void setGotValues()
Called once we set the values from ValuesElement so we are aware.
const std::string name() const
virtual void handleEnd()
Handle the closing of this element.