libdap Updated for version 3.21.0
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 BaseType *ptr_duplicate() override { return new D4Opaque(*this); }
59
60 virtual void clear_local_data();
61
62 unsigned int width(bool = false) const override
63 {
64 return sizeof(vector<uint8_t>);
65 }
66
67 int64_t width_ll(bool = false) const override
68 {
69 return sizeof(vector<uint8_t>);
70 }
71
72 // Return the length of the stored data or zero if no string has been
73 // stored in the instance's internal buffer.
74 virtual int length() const { return d_buf.size(); }
75
76 // DAP2
77 bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool = true) override {
78 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
79 }
80 bool deserialize(UnMarshaller &, DDS *, bool = false) override {
81 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
82 }
83
84 // DAP4
85 void compute_checksum(Crc32 &checksum) override ;
86 void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false) override;
87#if 0
88 virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false);
89#endif
90 void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
91
92 unsigned int val2buf(void *val, bool reuse = false) override;
93 unsigned int buf2val(void **val) override;
94
95 virtual bool set_value(const dods_opaque &value);
96 virtual dods_opaque value() const;
97
98 void print_val(FILE *, std::string = "", bool = true) override {
99 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
100 }
101 void print_val(std::ostream &out, std::string space = "", bool print_decl_p = true) override;
102
103 //virtual void print_dap4(XMLWriter &xml, bool constrained = false);
104
105 bool ops(BaseType *, int) override {
106 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
107 }
108
109 std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table) override;
110
111 void dump(std::ostream &strm) const override;
112
113};
114
115} // namespace libdap
116
117#endif // _d4_opaque_h
118
Definition crc.h:77
Contains the attributes for a dataset.
Definition AttrTable.h:154
The basic data type for the DODS DAP types.
Definition BaseType.h:120
Evaluate a constraint expression.
bool ops(BaseType *, int) override
Evaluate relational operators.
Definition D4Opaque.h:105
unsigned int width(bool=false) const override
How many bytes does this variable use Return the number of bytes of storage this variable uses....
Definition D4Opaque.h:62
virtual void clear_local_data()
Definition D4Opaque.cc:61
std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table) override
DAP4 to DAP2 transform.
Definition D4Opaque.cc:145
virtual int length() const
How many elements are in this variable? Uses -1 in places.
Definition D4Opaque.h:74
void print_val(FILE *, std::string="", bool=true) override
Prints the value of the variable.
Definition D4Opaque.h:98
void dump(std::ostream &strm) const override
dumps information about this object
Definition D4Opaque.cc:167
BaseType * ptr_duplicate() override
Definition D4Opaque.h:58
void compute_checksum(Crc32 &checksum) override
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
Definition D4Opaque.cc:72
virtual dods_opaque value() const
Definition D4Opaque.cc:139
unsigned int buf2val(void **val) override
Reads the class data.
Definition D4Opaque.cc:98
unsigned int val2buf(void *val, bool reuse=false) override
Loads class data.
Definition D4Opaque.cc:114
bool deserialize(UnMarshaller &, DDS *, bool=false) override
Receive data from the net.
Definition D4Opaque.h:80
virtual bool set_value(const dods_opaque &value)
Definition D4Opaque.cc:128
bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool=true) override
Move data to the net, then remove them from the object.
Definition D4Opaque.h:77
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
Definition AISConnect.cc:30