libdap Updated for version 3.20.10
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4Opaque.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., 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#ifndef _d4_opaque_h
26#define _d4_opaque_h 1
27
28#include <vector>
29
30#include "BaseType.h"
31#include "InternalErr.h"
32
33class Crc32;
34
35namespace libdap
36{
37
38class D4Opaque: public BaseType
39{
40public:
41 typedef std::vector<uint8_t> dods_opaque;
42
43protected:
44 dods_opaque d_buf;
45
46public:
47 D4Opaque(const std::string &n) : BaseType(n, dods_opaque_c, true /*is_dap4*/), d_buf(0) { }
48 D4Opaque(const std::string &n, const std::string &d) : BaseType(n, d, dods_opaque_c, true /*is_dap4*/), d_buf(0) { }
49
50 virtual ~D4Opaque() { }
51
52 D4Opaque(const D4Opaque &copy_from) : BaseType(copy_from) {
53 d_buf = copy_from.d_buf;
54 }
55
56 D4Opaque &operator=(const D4Opaque &rhs);
57
58 virtual BaseType *ptr_duplicate() { return new D4Opaque(*this); }
59
60 virtual void clear_local_data();
61
62 virtual unsigned int width(bool = false) const { return sizeof(vector<uint8_t>); }
63
64 // Return the length of the stored data or zero if no string has been
65 // stored in the instance's internal buffer.
66 virtual int length() const { return d_buf.size(); }
67
68 // DAP2
69 virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool = true) {
70 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
71 }
72 virtual bool deserialize(UnMarshaller &, DDS *, bool = false) {
73 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
74 }
75
76 // DAP4
77 virtual void compute_checksum(Crc32 &checksum);
78 virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
79#if 0
80 virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false);
81#endif
82 virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
83
84 virtual unsigned int val2buf(void *val, bool reuse = false);
85 virtual unsigned int buf2val(void **val);
86
87 virtual bool set_value(const dods_opaque &value);
88 virtual dods_opaque value() const;
89
90 virtual void print_val(FILE *, std::string = "", bool = true) {
91 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
92 }
93 virtual void print_val(std::ostream &out, std::string space = "", bool print_decl_p = true);
94
95 //virtual void print_dap4(XMLWriter &xml, bool constrained = false);
96
97 virtual bool ops(BaseType *, int) {
98 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
99 }
100
101 virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table);
102
103 virtual void dump(std::ostream &strm) const ;
104
105};
106
107} // namespace libdap
108
109#endif // _d4_opaque_h
110
Definition crc.h:77
Contains the attributes for a dataset.
Definition AttrTable.h:143
The basic data type for the DODS DAP types.
Definition BaseType.h:118
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
Definition BaseType.cc:126
Evaluate a constraint expression.
virtual std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table)
DAP4 to DAP2 transform.
Definition D4Opaque.cc:145
virtual bool deserialize(UnMarshaller &, DDS *, bool=false)
Receive data from the net.
Definition D4Opaque.h:72
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
Definition D4Opaque.cc:72
virtual unsigned int buf2val(void **val)
Reads the class data.
Definition D4Opaque.cc:98
virtual void clear_local_data()
Definition D4Opaque.cc:61
virtual unsigned int width(bool=false) const
How many bytes does this variable use Return the number of bytes of storage this variable uses....
Definition D4Opaque.h:62
virtual int length() const
How many elements are in this variable.
Definition D4Opaque.h:66
virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool=true)
Move data to the net, then remove them from the object.
Definition D4Opaque.h:69
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition D4Opaque.cc:167
virtual dods_opaque value() const
Definition D4Opaque.cc:139
virtual unsigned int val2buf(void *val, bool reuse=false)
Loads class data.
Definition D4Opaque.cc:114
virtual bool set_value(const dods_opaque &value)
Definition D4Opaque.cc:128
virtual void print_val(FILE *, std::string="", bool=true)
Prints the value of the variable.
Definition D4Opaque.h:90
virtual BaseType * ptr_duplicate()
Definition D4Opaque.h:58
virtual bool ops(BaseType *, int)
Evaluate relational operators.
Definition D4Opaque.h:97
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
Read data from the stream made by D4StreamMarshaller.
A class for software fault reporting.
Definition InternalErr.h:65
abstract base class used to marshal/serialize dap data objects
Definition Marshaller.h:50
abstract base class used to unmarshall/deserialize dap data objects
top level DAP object to house generic methods