libdap++
Updated for version 3.12.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Sequence.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) 2002,2003 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
//
23
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25
// (c) COPYRIGHT URI/MIT 1994-1999
26
// Please read the full copyright statement in the file COPYRIGHT_URI.
27
//
28
// Authors:
29
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
30
31
// Interface for the class Sequence. A sequence contains a single set
32
// of variables, all at the same lexical level just like a structure
33
// (and like a structure, it may contain other ctor types...). Unlike
34
// a structure, a sequence defines a pattern that is repeated N times
35
// for a sequence of N elements. Thus, Sequence { String name; Int32
36
// age; } person; means a sequence of N persons where each contain a
37
// name and age. The sequence can be arbitrarily long (i.e., you don't
38
// know N by looking at the sequence declaration.
39
//
40
// jhrg 9/14/94
41
42
#ifndef _sequence_h
43
#define _sequence_h 1
44
45
46
#include <stack>
47
48
#ifndef _basetype_h
49
#include "
BaseType.h
"
50
#endif
51
52
#ifndef _constructor_h
53
#include "
Constructor.h
"
54
#endif
55
56
#ifndef constraint_evaluator_h
57
#include "
ConstraintEvaluator.h
"
58
#endif
59
60
#ifndef S_XDRUtils_h
61
#include "
XDRUtils.h
"
62
#endif
63
64
namespace
libdap
65
{
66
69
typedef
vector<BaseType *>
BaseTypeRow
;
70
72
typedef
vector<BaseTypeRow *>
SequenceValues
;
73
172
class
Sequence
:
public
Constructor
173
{
174
private
:
175
// This holds the values read off the wire. Values are stored in
176
// instances of BaseTypeRow objects which hold instances of BaseType.
177
SequenceValues
d_values;
178
179
// The number of the row that has just been deserialized. Before
180
// deserialized has been called, this field is -1.
181
int
d_row_number;
182
183
// If a client asks for certain rows of a sequence using the bracket
184
// notation (<tt>[<start>:<stride>:<stop>]</tt>) primarily intended for
185
// arrays
186
// and grids, record that information in the next three fields. This
187
// information can be used by the translation software. s.a. the accessor
188
// and mutator methods for these members. Values of -1 indicate that
189
// these have not yet been set.
190
int
d_starting_row_number;
191
int
d_row_stride;
192
int
d_ending_row_number;
193
194
// Used to track if data has not already been sent.
195
bool
d_unsent_data;
196
197
// Track if the Start Of Instance marker has been written. Needed to
198
// properly send EOS for only the outer Sequence when a selection
199
// returns an empty Sequence.
200
bool
d_wrote_soi;
201
202
// This signals whether the sequence is a leaf or parent.
203
bool
d_leaf_sequence;
204
205
// In a hierarchy of sequences, is this the top most?
206
bool
d_top_most;
207
#if 0
208
BaseType
*
m_leaf_match
(
const
string
&
name
,
btp_stack
*s = 0);
209
BaseType
*
m_exact_match
(
const
string
&name,
btp_stack
*s = 0);
210
#endif
211
bool
is_end_of_rows(
int
i);
212
213
friend
class
SequenceTest
;
214
215
protected
:
216
void
m_duplicate
(
const
Sequence
&s);
217
typedef
stack<SequenceValues*>
sequence_values_stack_t
;
218
219
virtual
bool
serialize_parent_part_one
(
DDS
&dds,
220
ConstraintEvaluator
&eval,
221
Marshaller
&m);
222
virtual
void
serialize_parent_part_two
(
DDS
&dds,
223
ConstraintEvaluator
&eval,
224
Marshaller
&m);
225
virtual
bool
serialize_leaf
(
DDS
&dds,
226
ConstraintEvaluator
&eval,
227
Marshaller
&m,
bool
ce_eval);
228
229
virtual
void
intern_data_private
(
ConstraintEvaluator
&eval,
230
DDS
&dds,
231
sequence_values_stack_t
&sequence_values_stack);
232
virtual
void
intern_data_for_leaf
(
DDS
&dds,
233
ConstraintEvaluator
&eval,
234
sequence_values_stack_t
&sequence_values_stack);
235
236
virtual
void
intern_data_parent_part_one
(
DDS
&dds,
237
ConstraintEvaluator
&eval,
238
sequence_values_stack_t
&sequence_values_stack);
239
240
virtual
void
intern_data_parent_part_two
(
DDS
&dds,
241
ConstraintEvaluator
&eval,
242
sequence_values_stack_t
&sequence_values_stack);
243
244
public
:
245
246
Sequence
(
const
string
&n);
247
Sequence
(
const
string
&n,
const
string
&d);
248
249
Sequence
(
const
Sequence
&rhs);
250
251
virtual
~Sequence
();
252
253
Sequence
&
operator=
(
const
Sequence
&rhs);
254
255
virtual
BaseType
*
ptr_duplicate
();
256
257
virtual
bool
is_dap2_only_type
();
258
259
virtual
string
toString
();
260
#if 0
261
virtual
int
element_count
(
bool
leaves =
false
);
262
#endif
263
virtual
bool
is_linear
();
264
#if 0
265
virtual
void
set_send_p
(
bool
state);
266
virtual
void
set_read_p
(
bool
state);
267
#endif
268
#if 0
269
virtual
void
set_in_selection
(
bool
state);
270
#endif
271
#if 0
272
virtual
unsigned
int
width
(
bool
constrained =
false
);
273
virtual
unsigned
int
width
(
bool
constrained);
274
#endif
275
276
virtual
int
length
();
277
278
virtual
int
number_of_rows
();
279
280
virtual
bool
read_row
(
int
row,
DDS
&dds,
281
ConstraintEvaluator
&eval,
bool
ce_eval =
true
);
282
283
virtual
void
intern_data
(
ConstraintEvaluator
&eval,
DDS
&dds);
284
virtual
bool
serialize
(
ConstraintEvaluator
&eval,
DDS
&dds,
Marshaller
&m,
bool
ce_eval =
true
);
285
virtual
bool
deserialize
(
UnMarshaller
&um,
DDS
*dds,
bool
reuse =
false
);
286
288
void
reset_row_number
();
289
290
int
get_starting_row_number
();
291
292
virtual
int
get_row_stride
();
293
294
virtual
int
get_ending_row_number
();
295
296
virtual
void
set_row_number_constraint
(
int
start,
int
stop,
int
stride = 1);
297
299
bool
get_unsent_data
()
300
{
301
return
d_unsent_data;
302
}
303
305
void
set_unsent_data
(
bool
usd)
306
{
307
d_unsent_data = usd;
308
}
309
310
#if 0
311
// Move me!
312
virtual
unsigned
int
val2buf
(
void
*val,
bool
reuse =
false
);
313
virtual
unsigned
int
buf2val
(
void
**val);
314
#endif
315
316
virtual
void
set_value
(
SequenceValues
&values);
317
virtual
SequenceValues
value
();
318
#if 0
319
virtual
BaseType
*
var
(
const
string
&name,
bool
exact_match =
true
,
btp_stack
*s = 0);
320
virtual
BaseType
*
var
(
const
string
&n,
btp_stack
&s);
321
#endif
322
323
virtual
BaseType
*
var_value
(
size_t
row,
const
string
&name);
324
325
virtual
BaseType
*
var_value
(
size_t
row,
size_t
i);
326
327
virtual
BaseTypeRow
*
row_value
(
size_t
row);
328
#if 0
329
virtual
void
add_var
(
BaseType
*,
Part
part =
nil
);
330
virtual
void
add_var_nocopy
(
BaseType
*,
Part
part =
nil
);
331
#endif
332
virtual
void
print_one_row
(ostream &out,
int
row,
string
space,
333
bool
print_row_num =
false
);
334
virtual
void
print_val_by_rows
(ostream &out,
string
space =
""
,
335
bool
print_decl_p =
true
,
336
bool
print_row_numbers =
true
);
337
virtual
void
print_val
(ostream &out,
string
space =
""
,
338
bool
print_decl_p =
true
);
339
340
virtual
void
print_one_row
(FILE *out,
int
row,
string
space,
341
bool
print_row_num =
false
);
342
virtual
void
print_val_by_rows
(FILE *out,
string
space =
""
,
343
bool
print_decl_p =
true
,
344
bool
print_row_numbers =
true
);
345
virtual
void
print_val
(FILE *out,
string
space =
""
,
346
bool
print_decl_p =
true
);
347
#if 0
348
virtual
bool
check_semantics
(
string
&msg,
bool
all =
false
);
349
#endif
350
virtual
void
set_leaf_p
(
bool
state);
351
352
virtual
bool
is_leaf_sequence
();
353
354
virtual
void
set_leaf_sequence
(
int
lvl = 1);
355
356
virtual
void
dump
(ostream &strm)
const
;
357
};
358
359
}
// namespace libdap
360
361
#endif //_sequence_h
Sequence.h
Generated on Fri Oct 18 2013 00:14:24 for libdap++ by
1.8.4