libdap++  Updated for version 3.14.0
D4Sequence.h
Go to the documentation of this file.
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 
168  virtual int length() const { return (int)d_length; }
169 
174  virtual void set_length(int count) { d_length = (int64_t)count; }
175 
176  virtual bool read_next_instance(/*DMR &dmr, ConstraintEvaluator &eval,*/ bool filter);
177 
178  virtual void intern_data(ConstraintEvaluator &, DDS &) {
179  throw InternalErr(__FILE__, __LINE__, "Not implemented for DAP4");
180  }
181  virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool ) {
182  throw InternalErr(__FILE__, __LINE__, "Not implemented for DAP4");
183  }
184  virtual bool deserialize(UnMarshaller &, DDS *, bool ) {
185  throw InternalErr(__FILE__, __LINE__, "Not implemented for DAP4");
186  }
187 
188  // DAP4
189  virtual void intern_data(Crc32 &checksum/*, DMR &dmr, ConstraintEvaluator &eval*/);
190  virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
191  virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
192 
193 #if INDEX_SUBSETTING
194 
205  virtual int get_starting_row_number() const { return d_starting_row_number; }
206 
217  virtual int get_row_stride() const { return d_row_stride; }
218 
230  virtual int get_ending_row_number() const { return d_ending_row_number; }
231 
232  virtual void set_row_number_constraint(int start, int stop, int stride = 1);
233 #endif
234 
244  virtual void set_value(D4SeqValues &values) { d_values = values; d_length = d_values.size(); }
245 
253  virtual D4SeqValues value() const { return d_values; }
254 
255  virtual D4SeqRow *row_value(size_t row);
256  virtual BaseType *var_value(size_t row, const string &name);
257  virtual BaseType *var_value(size_t row, size_t i);
258 
259  virtual void print_one_row(ostream &out, int row, string space,
260  bool print_row_num = false);
261  virtual void print_val_by_rows(ostream &out, string space = "",
262  bool print_decl_p = true,
263  bool print_row_numbers = true);
264  virtual void print_val(ostream &out, string space = "",
265  bool print_decl_p = true);
266 
267  virtual void dump(ostream &strm) const ;
268 };
269 
270 } // namespace libdap
271 
272 #endif //_sequence_h
virtual void print_one_row(ostream &out, int row, string space, bool print_row_num=false)
Definition: D4Sequence.cc:427
virtual BaseType * ptr_duplicate()
Definition: D4Sequence.cc:167
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
D4Sequence(const string &n)
The Sequence constructor.
Definition: D4Sequence.cc:139
virtual bool read_next_instance(bool filter)
Read the next instance of the sequence While the rest of the variables' read() methods are assumed to...
Definition: D4Sequence.cc:224
Read data from the stream made by D4StreamMarshaller.
Definition: crc.h:76
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:402
virtual void set_value(D4SeqValues &values)
Set the internal value. The 'values' of a D4Sequence is a vector of vectors of BaseType* objects...
Definition: D4Sequence.h:244
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's receiv...
virtual void set_length(int count)
Definition: D4Sequence.h:174
virtual void dump(ostream &strm) const
dumps information about this object
Definition: D4Sequence.cc:505
Holds a sequence.
Definition: D4Sequence.h:124
virtual int length() const
The number of elements in a Sequence object.
Definition: D4Sequence.h:168
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:253
friend class D4SequenceTest
Definition: D4Sequence.h:145
D4Sequence & operator=(const D4Sequence &rhs)
Definition: D4Sequence.cc:190
string name() const
Returns the name of the class instance.
Definition: BaseType.cc:261
virtual void intern_data(ConstraintEvaluator &, DDS &)
Definition: D4Sequence.h:178
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: D4Sequence.cc:492
Evaluate a constraint expression.
virtual bool deserialize(UnMarshaller &, DDS *, bool)
Receive data from the net.
Definition: D4Sequence.h:184
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:53
D4SeqValues d_values
Definition: D4Sequence.h:133
virtual D4SeqRow * row_value(size_t row)
Get a whole row from the sequence.
Definition: D4Sequence.cc:385
virtual void print_val_by_rows(ostream &out, string space="", bool print_decl_p=true, bool print_row_numbers=true)
Definition: D4Sequence.cc:469
vector< D4SeqRow * > D4SeqValues
Definition: D4Sequence.h:45
virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool)
Move data to the net.
Definition: D4Sequence.h:181
virtual ~D4Sequence()
Definition: D4Sequence.cc:184
void m_duplicate(const D4Sequence &s)
Definition: D4Sequence.cc:108