bes  Updated for version 3.20.6
ScanElement.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__SCAN_ELEMENT_H__
30 #define __NCML_MODULE__SCAN_ELEMENT_H__
31 
32 #include "NCMLElement.h"
33 #include "AggMemberDataset.h"
34 
35 namespace agg_util {
36 class DirectoryUtil;
37 }
38 
39 namespace ncml_module {
40 // FDecls
41 class NetcdfElement;
42 class AggregationElement;
43 
48 class ScanElement: public NCMLElement {
49 public:
50  // class vars
51  // Name of the element
52  static const std::string _sTypeName;
53 
54  // All possible attributes for this element.
55  static const std::vector<std::string> _sValidAttrs;
56 
57 private:
58  ScanElement& operator=(const ScanElement& rhs); // disallow
59 
60 public:
61  ScanElement();
62  ScanElement(const ScanElement& proto);
63  virtual ~ScanElement();
64 
65  virtual const std::string& getTypeName() const;
66  virtual ScanElement* clone() const; // override clone with more specific subclass
67  virtual void setAttributes(const XMLAttributeMap& attrs);
68  virtual void handleBegin();
69  virtual void handleContent(const std::string& content);
70  virtual void handleEnd();
71  virtual std::string toString() const;
72 
74  const std::string& ncoords() const;
75 
78 
86  void setParent(AggregationElement* pParent);
87 
89  bool shouldScanSubdirs() const;
90 
96  long getOlderThanAsSeconds() const;
97 
110  void getDatasetList(std::vector<NetcdfElement*>& datasets) const;
111 
112 private:
113  // internal methods
114 
116  void setupFilters(agg_util::DirectoryUtil& scanner) const;
117 
122  void initSimpleDateFormats(const std::string& dateFormatMark);
123 
125  void deleteDateFormats() throw ();
126 
134  std::string extractTimeFromFilename(const std::string& filename) const;
135 
136  static std::vector<std::string> getValidAttributes();
137 
139  void throwOnUnhandledAttributes();
140 
142  static std::string getTimeAsString(time_t theTime);
143 
144 private:
145  // data rep
146  std::string _location;
147  std::string _suffix;
148  std::string _regExp;
149  std::string _subdirs;
150  std::string _olderThan;
151  std::string _dateFormatMark;
152  std::string _enhance; // we're not implementing this one now.
153  std::string _ncoords; // OPeNDAP EXTENSION to NcML. Inherited by all matched datasets.
154 
155  // Back pointer to our parent
156  AggregationElement* _pParent;
157 
158  // We use an opaque ptr (pimpl idiom) to push the
159  // decl of the ICU classes to the .cc
160  // to get config.h information as well as hide the icu headers.
161  struct DateFormatters;
162  DateFormatters* _pDateFormatters;
163 };
164 
165 }
166 
167 #endif /* __NCML_MODULE__SCAN_ELEMENT_H__ */
ncml_module::ScanElement::setAttributes
virtual void setAttributes(const XMLAttributeMap &attrs)
Definition: ScanElement.cc:141
ncml_module::ScanElement::shouldScanSubdirs
bool shouldScanSubdirs() const
Definition: ScanElement.cc:206
ncml_module::ScanElement::handleContent
virtual void handleContent(const std::string &content)
Definition: ScanElement.cc:172
ncml_module::ScanElement::setParent
void setParent(AggregationElement *pParent)
Definition: ScanElement.cc:124
ncml_module::ScanElement::getDatasetList
void getDatasetList(std::vector< NetcdfElement * > &datasets) const
Definition: ScanElement.cc:229
ncml_module::XMLAttributeMap
Definition: XMLHelpers.h:93
agg_util
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
Definition: AggMemberDataset.cc:38
ncml_module::ScanElement
Definition: ScanElement.h:48
ncml_module::ScanElement::handleBegin
virtual void handleBegin()
Definition: ScanElement.cc:164
ncml_module::ScanElement::toString
virtual std::string toString() const
Definition: ScanElement.cc:190
ncml_module::ScanElement::handleEnd
virtual void handleEnd()
Definition: ScanElement.cc:178
ncml_module::AggregationElement
Definition: AggregationElement.h:61
ncml_module::NCMLElement
Base class for NcML element concrete classes.
Definition: NCMLElement.h:61
ncml_module::ScanElement::getOlderThanAsSeconds
long getOlderThanAsSeconds() const
Definition: ScanElement.cc:211
ncml_module
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...
Definition: AggregationElement.cc:72
ncml_module::ScanElement::getTypeName
virtual const std::string & getTypeName() const
Definition: ScanElement.cc:130
agg_util::DirectoryUtil
Definition: DirectoryUtil.h:87
ncml_module::ScanElement::getParent
AggregationElement * getParent() const
Definition: ScanElement.cc:119
ncml_module::ScanElement::clone
virtual ScanElement * clone() const
Definition: ScanElement.cc:136