libdap++
Updated for version 3.8.2
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., 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
// (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
// FIXME
61
#include "
XDRUtils.h
"
62
63
#define FILE_METHODS 1
64
65
namespace
libdap
66
{
67
70
typedef
vector<BaseType *>
BaseTypeRow
;
71
73
typedef
vector<BaseTypeRow *>
SequenceValues
;
74
173
class
Sequence
:
public
Constructor
174
{
175
private
:
176
// This holds the values read off the wire. Values are stored in
177
// instances of BaseTypeRow objects which hold instances of BaseType.
178
SequenceValues
d_values;
179
180
// The number of the row that has just been deserialized. Before
181
// deserialized has been called, this field is -1.
182
int
d_row_number;
183
184
// If a client asks for certain rows of a sequence using the bracket
185
// notation (<tt>[<start>:<stride>:<stop>]</tt>) primarily intended for
186
// arrays
187
// and grids, record that information in the next three fields. This
188
// information can be used by the translation software. s.a. the accessor
189
// and mutator methods for these members. Values of -1 indicate that
190
// these have not yet been set.
191
int
d_starting_row_number;
192
int
d_row_stride;
193
int
d_ending_row_number;
194
195
// Used to track if data has not already been sent.
196
bool
d_unsent_data;
197
198
// Track if the Start Of Instance marker has been written. Needed to
199
// properly send EOS for only the outer Sequence when a selection
200
// returns an empty Sequence.
201
bool
d_wrote_soi;
202
203
// This signals whether the sequence is a leaf or parent.
204
bool
d_leaf_sequence;
205
206
// In a hierarchy of sequences, is this the top most?
207
bool
d_top_most;
208
209
void
_duplicate(
const
Sequence
&s);
210
BaseType
*m_leaf_match(
const
string
&
name
,
btp_stack
*s = 0);
211
BaseType
*m_exact_match(
const
string
&name,
btp_stack
*s = 0);
212
213
bool
is_end_of_rows(
int
i);
214
215
friend
class
SequenceTest
;
216
217
protected
:
218
219
typedef
stack<SequenceValues*>
sequence_values_stack_t
;
220
221
virtual
bool
serialize_parent_part_one
(
DDS
&dds,
222
ConstraintEvaluator
&eval,
223
Marshaller
&m);
224
virtual
void
serialize_parent_part_two
(
DDS
&dds,
225
ConstraintEvaluator
&eval,
226
Marshaller
&m);
227
virtual
bool
serialize_leaf
(
DDS
&dds,
228
ConstraintEvaluator
&eval,
229
Marshaller
&m,
bool
ce_eval);
230
231
virtual
void
intern_data_private
(
ConstraintEvaluator
&eval,
232
DDS
&dds,
233
sequence_values_stack_t
&sequence_values_stack);
234
virtual
void
intern_data_for_leaf
(
DDS
&dds,
235
ConstraintEvaluator
&eval,
236
sequence_values_stack_t
&sequence_values_stack);
237
238
virtual
void
intern_data_parent_part_one
(
DDS
&dds,
239
ConstraintEvaluator
&eval,
240
sequence_values_stack_t
&sequence_values_stack);
241
242
virtual
void
intern_data_parent_part_two
(
DDS
&dds,
243
ConstraintEvaluator
&eval,
244
sequence_values_stack_t
&sequence_values_stack);
245
246
public
:
247
248
Sequence
(
const
string
&n);
249
Sequence
(
const
string
&n,
const
string
&d);
250
251
Sequence
(
const
Sequence
&rhs);
252
253
virtual
~Sequence
();
254
255
Sequence
&
operator=
(
const
Sequence
&rhs);
256
257
virtual
BaseType
*
ptr_duplicate
();
258
259
virtual
string
toString
();
260
261
virtual
int
element_count
(
bool
leaves =
false
);
262
263
virtual
bool
is_linear
();
264
265
virtual
void
set_send_p
(
bool
state);
266
virtual
void
set_read_p
(
bool
state);
267
virtual
void
set_in_selection
(
bool
state);
268
269
virtual
unsigned
int
width
();
270
virtual
unsigned
int
width
(
bool
constrained);
271
272
virtual
int
length
();
273
274
virtual
int
number_of_rows
();
275
276
virtual
bool
read_row
(
int
row,
DDS
&dds,
277
ConstraintEvaluator
&eval,
bool
ce_eval =
true
);
278
279
virtual
void
intern_data
(
ConstraintEvaluator
&eval,
DDS
&dds);
280
virtual
bool
serialize
(
ConstraintEvaluator
&eval,
DDS
&dds,
281
Marshaller
&m,
bool
ce_eval =
true
);
282
virtual
bool
deserialize
(
UnMarshaller
&um,
DDS
*dds,
bool
reuse =
false
);
283
285
void
reset_row_number
();
286
287
int
get_starting_row_number
();
288
289
virtual
int
get_row_stride
();
290
291
virtual
int
get_ending_row_number
();
292
293
virtual
void
set_row_number_constraint
(
int
start,
int
stop,
int
stride = 1);
294
296
bool
get_unsent_data
()
297
{
298
return
d_unsent_data;
299
}
300
302
void
set_unsent_data
(
bool
usd)
303
{
304
d_unsent_data = usd;
305
}
306
307
// Move me!
308
virtual
unsigned
int
val2buf
(
void
*val,
bool
reuse =
false
);
309
virtual
unsigned
int
buf2val
(
void
**val);
310
311
virtual
void
set_value
(
SequenceValues
&values);
312
virtual
SequenceValues
value
();
313
314
virtual
BaseType
*
var
(
const
string
&name,
bool
exact_match =
true
,
315
btp_stack
*s = 0);
316
virtual
BaseType
*
var
(
const
string
&n,
btp_stack
&s);
317
318
virtual
BaseType
*
var_value
(
size_t
row,
const
string
&name);
319
320
virtual
BaseType
*
var_value
(
size_t
row,
size_t
i);
321
322
virtual
BaseTypeRow
*
row_value
(
size_t
row);
323
324
virtual
void
add_var
(
BaseType
*,
Part
part =
nil
);
325
virtual
void
add_var_nocopy
(
BaseType
*,
Part
part =
nil
);
326
327
virtual
void
print_one_row
(ostream &out,
int
row,
string
space,
328
bool
print_row_num =
false
);
329
virtual
void
print_val_by_rows
(ostream &out,
string
space =
""
,
330
bool
print_decl_p =
true
,
331
bool
print_row_numbers =
true
);
332
virtual
void
print_val
(ostream &out,
string
space =
""
,
333
bool
print_decl_p =
true
);
334
335
#if FILE_METHODS
336
virtual
void
print_one_row
(FILE *out,
int
row,
string
space,
337
bool
print_row_num =
false
);
338
virtual
void
print_val_by_rows
(FILE *out,
string
space =
""
,
339
bool
print_decl_p =
true
,
340
bool
print_row_numbers =
true
);
341
virtual
void
print_val
(FILE *out,
string
space =
""
,
342
bool
print_decl_p =
true
);
343
#endif
344
345
virtual
bool
check_semantics
(
string
&msg,
bool
all =
false
);
346
347
virtual
void
set_leaf_p
(
bool
state);
348
349
virtual
bool
is_leaf_sequence
();
350
351
virtual
void
set_leaf_sequence
(
int
lvl = 1);
352
353
virtual
void
dump
(ostream &strm)
const
;
354
};
355
356
}
// namespace libdap
357
358
#endif //_sequence_h
Sequence.h
Generated by
1.8.1.1