bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
VariableElement.h
1
2// 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
34namespace libdap {
35class BaseType;
36}
37
38namespace ncml_module {
39
58class VariableElement: public NCMLElement {
59private:
60 VariableElement& operator=(const VariableElement& rhs); // disallow
61
62public:
63 static const string _sTypeName;
64 static const vector<string> _sValidAttributes;
65
66 VariableElement();
67 VariableElement(const VariableElement& proto);
68 virtual ~VariableElement();
69 virtual const string& getTypeName() const;
70 virtual VariableElement* clone() const; // override clone with more specific subclass
71 virtual void setAttributes(const XMLAttributeMap& attrs);
72 virtual void handleBegin();
73 virtual void handleContent(const string& content);
74 virtual void handleEnd();
75 virtual string toString() const;
76
77 const std::string name() const
78 {
79 return _name;
80 }
81
82 const std::string type() const
83 {
84 return _type;
85 }
86
87 const std::string shape() const
88 {
89 return _shape;
90 }
91
92 const std::string orgName() const
93 {
94 return _orgName;
95 }
96
98 bool isNewVariable() const;
99
103 bool checkGotValues() const;
104
107
108private:
109
117 void processBegin(NCMLParser& p);
118
126 void processEnd(NCMLParser& p);
127
134 void processExistingVariable(NCMLParser& p, libdap::BaseType* pVar);
135
149#if 0
150 // Disabled for now. See comment in the .cc file ndp - 08/12/2015
151 void processRenameVariableDataWorker(NCMLParser& p, libdap::BaseType* pOrgVar);
152#endif
153 void processRenameVariable(NCMLParser& p);
154
168 void processNewVariable(NCMLParser& p);
169
174 void processNewStructure(NCMLParser& p);
175
181 void processNewScalar(NCMLParser& p, const std::string& dapType);
182
195 void processNewArray(NCMLParser& p, const std::string& dapType);
196
204 libdap::BaseType* replaceArrayIfNeeded(NCMLParser& p, libdap::BaseType* pOrgVar, const string& name);
205
215 void addNewVariableAndEnterScope(NCMLParser& p, const std::string& dapType);
216
220 void enterScope(NCMLParser& p, libdap::BaseType* pVar);
221
223 void exitScope(NCMLParser& p);
224
228 bool isDimensionNumericConstant(const std::string& dimToken) const;
233 unsigned int getSizeForDimension(NCMLParser& p, const std::string& dimToken) const;
234
250 unsigned int getProductOfDimensionSizes(NCMLParser& p) const;
251
252 static vector<string> getValidAttributes();
253
254private:
255 string _name;
256 string _type;
257 string _shape; // empty() => existing var (shape implicit) or if new var, then scalar (rank 0).
258 string _orgName; // if !empty(), the name of existing variable we want to rename to _name
259
260 // Ephemeral state below
261
262 // tokenized version of _shape for dimensions
263 vector<string> _shapeTokens;
264
265 // if not null, this element created this var and it exists in the dds of the containing dataset
266 libdap::BaseType* _pNewlyCreatedVar;
267
268 // true once we get a valid <values> element with values in it. Used for parse error checking
269 bool _gotValues;
270};
271
272}
273
274#endif /* __NCML_MODULE__VARIABLE_ELEMENT_H__ */
virtual void setAttributes(const XMLAttributeMap &attrs)
virtual string toString() const
virtual VariableElement * clone() const
virtual const string & getTypeName() const
STL class.
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...