OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
NCMLBaseArray.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__NCMLBASEARRAY_H__
30 #define __NCML_MODULE__NCMLBASEARRAY_H__
31 
32 #include <Array.h>
33 #include <memory>
34 #include "Shape.h"
35 
41 namespace ncml_module
42 {
43 
44  class NCMLBaseArray : public libdap::Array
45  {
46  public: // class methods
62  static auto_ptr< NCMLBaseArray > createFromArray(const libdap::Array& proto);
63 
64  public: // Instance methods
65  NCMLBaseArray();
66  explicit NCMLBaseArray(const std::string& name);
67  explicit NCMLBaseArray(const NCMLBaseArray& proto);
68 
69  virtual ~NCMLBaseArray();
70 
72 
76  virtual bool read_p();
77 
81  virtual void set_read_p(bool state);
82 
101  virtual bool read();
102 
104  virtual Shape getSuperShape() const;
105 
110  virtual bool isConstrained() const;
111 
116  virtual bool haveConstraintsChangedSinceLastRead() const;
117 
119  virtual void cacheCurrentConstraints();
120 
121  virtual void cacheUnconstrainedDimensions();
122 
124  virtual void cacheSuperclassStateIfNeeded();
125 
127  virtual void cacheValuesIfNeeded() = 0;
128 
133  virtual void copyDataFrom(libdap::Array& from)=0;
134 
136  virtual bool isDataCached() const = 0;
137 
142  virtual void createAndSetConstrainedValueBuffer() = 0;
143 
144  private:
145 
147  void copyLocalRepFrom(const NCMLBaseArray& proto);
148 
150  void destroy() throw();
151 
152  protected: // Data rep
153  // The Shape for the case of NO constraints on the data, or null if not set yet.
155 
156  // The Shape for the CURRENT dimensions in super Array, used to calculate the transmission buffer
157  // for read() and also to check if haveConstraintsChangedSinceLastRead(). Null if not set yet.
159  };
160 
161 }
162 
163 #endif /* __NCML_MODULE__NCMLBASEARRAY_H__ */
virtual Shape getSuperShape() const
Get the current dimensions of our superclass Array as a Shape object.
virtual bool read()
If there are no constraints and this is the first call to read(), we will do nothing, assuming the sueprclasses have everything under control.
virtual bool read_p()
Override to return false if we have uncomputed constraints and only true if the current constraints m...
virtual bool isConstrained() const
Return whether the superclass Array has been constrained along any dimensions.
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
virtual bool isDataCached() const =0
virtual void cacheSuperclassStateIfNeeded()
Required by subclasses to copy the original data values locally.
virtual void copyDataFrom(libdap::Array &from)=0
Copy the data values from the given array, assuming the type matches the template type T of the subcl...
A wrapper class for a vector of Array::dimension structs.
Definition: Shape.h:59
virtual void cacheUnconstrainedDimensions()
NCMLBaseArray & operator=(const NCMLBaseArray &rhs)
virtual void cacheValuesIfNeeded()=0
Must copy the unconstrained current values of the proper type within Vector into the local instance...
virtual void set_read_p(bool state)
Override to disable setting of this flag.
virtual void createAndSetConstrainedValueBuffer()=0
Given the current Shape of the Array, generate the constrained value buffer and set it into the Vecto...
virtual void cacheCurrentConstraints()
Store the current super Array shape as the current constraints so we remember.
virtual bool haveConstraintsChangedSinceLastRead() const
Return whether the constraints used to create Vector._buf for the last read() have changed...
static auto_ptr< NCMLBaseArray > createFromArray(const libdap::Array &proto)
Make a new NCMLArray from the given proto, using the Array interface.