libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4Opaque.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., 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
37class D4Opaque : public BaseType {
38public:
39 typedef std::vector<uint8_t> dods_opaque;
40
41protected:
43
44public:
45 D4Opaque(const std::string &n) : BaseType(n, dods_opaque_c, true /*is_dap4*/), d_buf(0) {}
46 D4Opaque(const std::string &n, const std::string &d) : BaseType(n, d, dods_opaque_c, true /*is_dap4*/), d_buf(0) {}
47
48 ~D4Opaque() override {}
49
50 D4Opaque(const D4Opaque &copy_from) : BaseType(copy_from) { d_buf = copy_from.d_buf; }
51
52 D4Opaque &operator=(const D4Opaque &rhs);
53
54 BaseType *ptr_duplicate() override { return new D4Opaque(*this); }
55
56 void clear_local_data() override;
57
58 unsigned int width(bool = false) const override { return sizeof(vector<uint8_t>); }
59
60 int64_t width_ll(bool = false) const override { return sizeof(vector<uint8_t>); }
61
62 // Return the length of the stored data or zero if no string has been
63 // stored in the instance's internal buffer.
64 int length() const override { return d_buf.size(); }
65
66 // DAP2
67 bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool = true) override {
68 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
69 }
70 bool deserialize(UnMarshaller &, DDS *, bool = false) override {
71 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
72 }
73
74 // DAP4
75 void compute_checksum(Crc32 &checksum) override;
76 void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false) override;
77#if 0
78 virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false);
79#endif
80 void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
81
82 unsigned int val2buf(void *val, bool reuse = false) override;
83 unsigned int buf2val(void **val) override;
84
85 virtual bool set_value(const dods_opaque &value);
86 virtual dods_opaque value() const;
87
88 void print_val(FILE *, std::string = "", bool = true) override {
89 throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
90 }
91 void print_val(std::ostream &out, std::string space = "", bool print_decl_p = true) override;
92
93 // virtual void print_dap4(XMLWriter &xml, bool constrained = false);
94
95 bool ops(BaseType *, int) override { throw InternalErr(__FILE__, __LINE__, "Unimplemented method"); }
96
97 std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table) override;
98
99 void dump(std::ostream &strm) const override;
100};
101
102} // namespace libdap
103
104#endif // _d4_opaque_h
Definition crc.h:43
Contains the attributes for a dataset.
Definition AttrTable.h:150
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
Definition BaseType.cc:124
Evaluate a constraint expression.
bool ops(BaseType *, int) override
Evaluate relational operators.
Definition D4Opaque.h:95
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:58
D4Opaque(const std::string &n, const std::string &d)
Definition D4Opaque.h:46
std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table) override
DAP4 to DAP2 transform.
Definition D4Opaque.cc:119
void print_val(FILE *, std::string="", bool=true) override
Prints the value of the variable.
Definition D4Opaque.h:88
std::vector< uint8_t > dods_opaque
Definition D4Opaque.h:39
void dump(std::ostream &strm) const override
dumps information about this object
Definition D4Opaque.cc:139
~D4Opaque() override
Definition D4Opaque.h:48
BaseType * ptr_duplicate() override
Definition D4Opaque.h:54
int length() const override
How many elements are in this variable? Uses -1 in places.
Definition D4Opaque.h:64
D4Opaque(const std::string &n)
Definition D4Opaque.h:45
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:67
D4Opaque(const D4Opaque &copy_from)
Definition D4Opaque.h:50
void clear_local_data() override
Definition D4Opaque.cc:58
virtual dods_opaque value() const
Definition D4Opaque.cc:117
unsigned int buf2val(void **val) override
Reads the class data.
Definition D4Opaque.cc:82
unsigned int val2buf(void *val, bool reuse=false) override
Loads class data.
Definition D4Opaque.cc:96
dods_opaque d_buf
Definition D4Opaque.h:42
bool deserialize(UnMarshaller &, DDS *, bool=false) override
Receive data from the net.
Definition D4Opaque.h:70
D4Opaque & operator=(const D4Opaque &rhs)
Definition D4Opaque.cc:50
virtual bool set_value(const dods_opaque &value)
Definition D4Opaque.cc:108
int64_t width_ll(bool=false) const override
Definition D4Opaque.h:60
bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool=true) override
Move data to the net, then remove them from the object.
Definition D4Opaque.h:67
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:61
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
@ dods_opaque_c
Definition Type.h:121