OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
GridAggregationBase.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) 2010 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 
30 #ifndef __AGG_UTIL__GRID_AGGREGATION_BASE_H__
31 #define __AGG_UTIL__GRID_AGGREGATION_BASE_H__
32 
33 #include "AggMemberDataset.h" // agg_util
34 #include "DDSLoader.h" // agg_util
35 #include <Grid.h> // libdap
36 #include <memory> // std
37 
38 namespace libdap
39 {
40  class Array;
41  class Grid;
42  class D4Group;
43 };
44 
45 namespace agg_util
46 {
47 
48  class GridAggregationBase : public libdap::Grid
49  {
50  public:
51  GridAggregationBase(const libdap::Grid& proto,
52  const AMDList& memberDatasets,
53  const DDSLoader& loaderProto);
54 
70  GridAggregationBase(const string& name,
71  const AMDList& memberDatasets,
72  const DDSLoader& loaderProto);
73 
75 
76  virtual ~GridAggregationBase();
77 
79 #if 1
80  BaseType *transform_to_dap4(libdap::D4Group *root, libdap::Constructor *container);
81 #endif
82 
92  void setShapeFrom(const libdap::Grid& protoSubGrid, bool addMaps);
93 
99  virtual const AMDList& getDatasetList() const;
100 
111  virtual bool read();
112 
113  protected: // subclass interface
114 
120 
124  Grid* getSubGridTemplate();
125 
127  virtual const Dimension& getAggregationDimension() const = 0;
128 
129  void printConstraints(const libdap::Array& fromArray);
130 
131 
134  void readProtoSubGrid();
135 
136  // Support calls for the read()....
137 
144  void copyProtoMapsIntoThisGrid(const Dimension& aggDim);
145 
156  virtual void transferConstraintsToSubGridHook(Grid* pSubGrid);
157 
158  private: // helpers
159 
161  void duplicate(const GridAggregationBase& rhs);
162 
164  void cleanup() throw();
165 
166  static libdap::Grid* cloneSubGridProto(const libdap::Grid& proto);
167 
168 
169  private: // data rep
170 
171  // Use this to laod the member datasets as needed
172  DDSLoader _loader;
173 
174  // A template for the unaggregated (sub) Grids.
175  // It will be used to validate other datasets as they are loaded.
176  std::auto_ptr<Grid> _pSubGridProto;
177 
178  // Maintain a copy here... we may want to move this down...
179  AMDList _memberDatasets;
180 
181  }; // class GridAggregationBase
182 
183 } // namespace agg_util
184 
185 #endif /* __AGG_UTIL__GRID_AGGREGATION_BASE_H__ */
virtual const AMDList & getDatasetList() const
Accessor for the dataset description list that describes this aggregation.
void copyProtoMapsIntoThisGrid(const Dimension &aggDim)
Copy the template's read in subgrid maps into this.
void setShapeFrom(const libdap::Grid &protoSubGrid, bool addMaps)
Use the data array and maps from protoSubGrid as the initial point for the shape of the Grid...
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
GridAggregationBase(const libdap::Grid &proto, const AMDList &memberDatasets, const DDSLoader &loaderProto)
static class NCMLUtil overview
virtual bool read()
Read in only those datasets that are in the constrained output making sure to apply the internal dime...
void readProtoSubGrid()
Transfer constraints properly from this object's maps and read in the proto subgrid entirely (respect...
void printConstraints(const libdap::Array &fromArray)
Struct for holding information about a dimension of data, minimally a name and a cardinality (size)...
Definition: Dimension.h:50
virtual const Dimension & getAggregationDimension() const =0
Get the contained aggregation dimension info.
virtual void readAndAggregateConstrainedMapsHook()
Called from read()! Invokes the user hooks eventually.
std::vector< RCPtr< AggMemberDataset > > AMDList
virtual void transferConstraintsToSubGridHook(Grid *pSubGrid)
To be specialized in subclass to copy constraints on this object properly into the given pSubGrid map...
Grid * getSubGridTemplate()
Reveals the raw ptr, but only to subclasses.
GridAggregationBase & operator=(const GridAggregationBase &rhs)
BaseType * transform_to_dap4(libdap::D4Group *root, libdap::Constructor *container)