OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
ScanElement.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__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 {
37  class DirectoryUtil;
38 };
39 
40 namespace ncml_module
41 {
42  // FDecls
43  class NetcdfElement;
44  class AggregationElement;
45 
50  class ScanElement : public NCMLElement
51  {
52  public: // class vars
53  // Name of the element
54  static const string _sTypeName;
55 
56  // All possible attributes for this element.
57  static const vector<string> _sValidAttrs;
58 
59  private:
60  ScanElement& operator=(const ScanElement& rhs); // disallow
61 
62  public:
63  ScanElement();
64  ScanElement(const ScanElement& proto);
65  virtual ~ScanElement();
66 
67  virtual const string& getTypeName() const;
68  virtual ScanElement* clone() const; // override clone with more specific subclass
69  virtual void setAttributes(const XMLAttributeMap& attrs);
70  virtual void handleBegin();
71  virtual void handleContent(const string& content);
72  virtual void handleEnd();
73  virtual string toString() const;
74 
76  const string& ncoords() const;
77 
80 
88  void setParent(AggregationElement* pParent);
89 
91  bool shouldScanSubdirs() const;
92 
98  long getOlderThanAsSeconds() const;
99 
112  void getDatasetList(vector<NetcdfElement*>& datasets) const;
113 
114  private: // internal methods
115 
117  void setupFilters(agg_util::DirectoryUtil& scanner) const;
118 
123  void initSimpleDateFormats(const std::string& dateFormatMark);
124 
126  void deleteDateFormats() throw();
127 
135  std::string extractTimeFromFilename(const std::string& filename) const;
136 
137  static vector<string> getValidAttributes();
138 
140  void throwOnUnhandledAttributes();
141 
143  static std::string getTimeAsString(time_t theTime);
144 
145  private: // data rep
146  string _location;
147  string _suffix;
148  string _regExp;
149  string _subdirs;
150  string _olderThan;
151  string _dateFormatMark;
152  string _enhance; // we're not implementing this one now.
153  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__ */
virtual void setAttributes(const XMLAttributeMap &attrs)
Set the attributes of this from the map.
Definition: ScanElement.cc:161
long getOlderThanAsSeconds() const
Get the olderThan attribute in seconds.
Definition: ScanElement.cc:241
void getDatasetList(vector< NetcdfElement * > &datasets) const
Actually perform the filesystem scan based on the specified attributes (suffix, subdirs, etc).
Definition: ScanElement.cc:264
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
STL namespace.
static const string _sTypeName
Definition: ScanElement.h:54
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
virtual void handleContent(const string &content)
Handle the characters content for the element.
Definition: ScanElement.cc:196
const string & ncoords() const
Definition: ScanElement.cc:229
Implementation of the element used to scan directories to create the set of files for an aggre...
Definition: ScanElement.h:50
static const vector< string > _sValidAttrs
Definition: ScanElement.h:57
AggregationElement * getParent() const
Get the aggregation of which I am a child.
Definition: ScanElement.cc:137
Helper classes for using dirent.h, dir.h, stat.h, etc.
Definition: DirectoryUtil.h:88
virtual void handleBegin()
Handle a begin on this element.
Definition: ScanElement.cc:186
virtual ScanElement * clone() const
Make and return a copy of this.
Definition: ScanElement.cc:155
Base class for NcML element concrete classes.
Definition: NCMLElement.h:64
virtual void handleEnd()
Handle the closing of this element.
Definition: ScanElement.cc:202
void setParent(AggregationElement *pParent)
Set the parent of this element.
Definition: ScanElement.cc:143
bool shouldScanSubdirs() const
is the subdirs attribute true?
Definition: ScanElement.cc:235
virtual string toString() const
Return a string describing the element.
Definition: ScanElement.cc:215
virtual const string & getTypeName() const
Return the type of the element, which should be: the same as ConcreteClassName::getTypeName() ...
Definition: ScanElement.cc:149