libdap  Updated for version 3.17.2
D4Sequence.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2013 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #ifndef _d4sequence_h
26 #define _d4sequence_h 1
27 
28 #include "Constructor.h"
29 
30 // DAP2 Sequence supported subsetting using the array notation. This might
31 // be introduced into DAP4 later on.
32 #define INDEX_SUBSETTING 0
33 
34 class Crc32;
35 
36 namespace libdap
37 {
38 class BaseType;
39 
42 typedef vector<BaseType *> D4SeqRow;
43 
45 typedef vector<D4SeqRow *> D4SeqValues;
46 
124 class D4Sequence: public Constructor
125 {
126 private:
127 
128 protected:
129  // This holds the values of the sequence. Values are stored in
130  // instances of BaseTypeRow objects which hold instances of BaseType.
131  //
132  // Allow these values to be accessed by subclasses
133  D4SeqValues d_values;
134 
135  int64_t d_length; // How many elements are in the sequence; -1 if not currently known
136 
137 #if INDEX_SUBSETTING
138  int d_starting_row_number;
139  int d_row_stride;
140  int d_ending_row_number;
141 #endif
142 
143  void m_duplicate(const D4Sequence &s);
144 
145  friend class D4SequenceTest;
146 
147 public:
148 
149  D4Sequence(const string &n);
150  D4Sequence(const string &n, const string &d);
151 
152  D4Sequence(const D4Sequence &rhs);
153 
154  virtual ~D4Sequence();
155 
156  D4Sequence &operator=(const D4Sequence &rhs);
157 
158  virtual BaseType *ptr_duplicate();
159 
160  virtual void clear_local_data();
161 
170  virtual int length() const { return (int)d_length; }
171 
176  virtual void set_length(int count) { d_length = (int64_t)count; }
177 
178  virtual bool read_next_instance(/*DMR &dmr, ConstraintEvaluator &eval,*/ bool filter);
179 
180  virtual void intern_data(ConstraintEvaluator &, DDS &) {
181  throw InternalErr(__FILE__, __LINE__, "Not implemented for DAP4");
182  }
183  virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool ) {
184  throw InternalErr(__FILE__, __LINE__, "Not implemented for DAP4");
185  }
186  virtual bool deserialize(UnMarshaller &, DDS *, bool ) {
187  throw InternalErr(__FILE__, __LINE__, "Not implemented for DAP4");
188  }
189 
190  // DAP4
191  virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/);
192  virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
193 #if 0
194  virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false);
195 #endif
196  virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
197 
198 #if INDEX_SUBSETTING
199 
210  virtual int get_starting_row_number() const { return d_starting_row_number; }
211 
222  virtual int get_row_stride() const { return d_row_stride; }
223 
235  virtual int get_ending_row_number() const { return d_ending_row_number; }
236 
237  virtual void set_row_number_constraint(int start, int stop, int stride = 1);
238 #endif
239 
249  virtual void set_value(D4SeqValues &values) { d_values = values; d_length = d_values.size(); }
250 
258  virtual D4SeqValues value() const { return d_values; }
259 
260  virtual D4SeqRow *row_value(size_t row);
261  virtual BaseType *var_value(size_t row, const string &name);
262  virtual BaseType *var_value(size_t row, size_t i);
263 
264  virtual void print_one_row(ostream &out, int row, string space,
265  bool print_row_num = false);
266  virtual void print_val_by_rows(ostream &out, string space = "",
267  bool print_decl_p = true,
268  bool print_row_numbers = true);
269  virtual void print_val(ostream &out, string space = "",
270  bool print_decl_p = true);
271 
272  virtual void dump(ostream &strm) const ;
273 };
274 
275 } // namespace libdap
276 
277 #endif //_sequence_h
virtual BaseType * ptr_duplicate()
Definition: D4Sequence.cc:169
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
D4Sequence(const string &n)
The Sequence constructor.
Definition: D4Sequence.cc:141
virtual bool read_next_instance(bool filter)
Read the next instance of the sequence While the rest of the variables&#39; read() methods are assumed to...
Definition: D4Sequence.cc:236
Read data from the stream made by D4StreamMarshaller.
Definition: crc.h:76
virtual void clear_local_data()
Definition: D4Sequence.cc:191
virtual BaseType * var_value(size_t row, const string &name)
Get the BaseType pointer to the named variable of a given row.
Definition: D4Sequence.cc:455
virtual void set_value(D4SeqValues &values)
Set the internal value. The &#39;values&#39; of a D4Sequence is a vector of vectors of BaseType* objects...
Definition: D4Sequence.h:249
vector< BaseType * > D4SeqRow
Definition: D4Sequence.h:38
A class for software fault reporting.
Definition: InternalErr.h:64
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4&#39;s receiv...
virtual void set_length(int count)
Definition: D4Sequence.h:176
virtual void dump(ostream &strm) const
dumps information about this object
Definition: D4Sequence.cc:558
Holds a sequence.
Definition: D4Sequence.h:124
virtual int length() const
The number of elements in a Sequence object.
Definition: D4Sequence.h:170
virtual void intern_data()
Read data into this variable.
Definition: D4Sequence.cc:283
virtual D4SeqValues value() const
Get the values for this D4Sequence This method does not perform a deep copy of the values so the call...
Definition: D4Sequence.h:258
virtual string name() const
Returns the name of the class instance.
Definition: BaseType.cc:265
virtual void intern_data(ConstraintEvaluator &, DDS &)
Definition: D4Sequence.h:180
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: D4Sequence.cc:545
Evaluate a constraint expression.
virtual bool deserialize(UnMarshaller &, DDS *, bool)
Receive data from the net.
Definition: D4Sequence.h:186
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:50
virtual D4SeqRow * row_value(size_t row)
Get a whole row from the sequence.
Definition: D4Sequence.cc:438
vector< D4SeqRow * > D4SeqValues
Definition: D4Sequence.h:45
virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool)
Move data to the net, then remove them from the object.
Definition: D4Sequence.h:183