libdap++  Updated for version 3.14.0
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 
33 class Crc32;
34 
35 namespace libdap
36 {
37 
38 class D4Opaque: public BaseType
39 {
40 public:
41  typedef std::vector<uint8_t> dods_opaque;
42 
43 protected:
44  dods_opaque d_buf;
45 
46 public:
47  D4Opaque(const std::string &n) : BaseType(n, dods_opaque_c), d_buf(0) { }
48  D4Opaque(const std::string &n, const std::string &d) : BaseType(n, d, dods_opaque_c), 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 unsigned int width(bool = false) const { 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  virtual int length() const { return d_buf.size(); }
65 
66  // DAP2
67  virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool = true) {
68  throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
69  }
70  virtual bool deserialize(UnMarshaller &, DDS *, bool = false) {
71  throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
72  }
73 
74  // DAP4
75  virtual void compute_checksum(Crc32 &checksum);
76  virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
77  virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
78 
79  virtual unsigned int val2buf(void *val, bool reuse = false);
80  virtual unsigned int buf2val(void **val);
81 
82  virtual bool set_value(const dods_opaque &value);
83  virtual dods_opaque value() const;
84 
85  virtual void print_val(FILE *, std::string = "", bool = true) {
86  throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
87  }
88  virtual void print_val(std::ostream &out, std::string space = "", bool print_decl_p = true);
89 
90  //virtual void print_dap4(XMLWriter &xml, bool constrained = false);
91 
92  virtual bool ops(BaseType *, int) {
93  throw InternalErr(__FILE__, __LINE__, "Unimplemented method");
94  }
95 
96  virtual void dump(std::ostream &strm) const ;
97 };
98 
99 } // namespace libdap
100 
101 #endif // _d4_opaque_h
102 
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
virtual BaseType * ptr_duplicate()
Definition: D4Opaque.h:58
virtual unsigned int buf2val(void **val)
Reads the class data.
Definition: D4Opaque.cc:82
virtual ~D4Opaque()
Definition: D4Opaque.h:50
dods_opaque d_buf
Definition: D4Opaque.h:44
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: D4Opaque.cc:144
virtual bool deserialize(UnMarshaller &, DDS *, bool=false)
Receive data from the net.
Definition: D4Opaque.h:70
Read data from the stream made by D4StreamMarshaller.
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:61
Definition: crc.h:76
D4Opaque(const std::string &n, const std::string &d)
Definition: D4Opaque.h:48
D4Opaque(const std::string &n)
Definition: D4Opaque.h:47
A class for software fault reporting.
Definition: InternalErr.h:64
std::vector< uint8_t > dods_opaque
Definition: D4Opaque.h:41
virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool=true)
Move data to the net.
Definition: D4Opaque.h:67
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
virtual bool set_value(const dods_opaque &value)
Definition: D4Opaque.cc:112
virtual int length() const
How many elements are in this variable.
Definition: D4Opaque.h:64
virtual bool ops(BaseType *, int)
Evaluate relational operators.
Definition: D4Opaque.h:92
virtual unsigned int val2buf(void *val, bool reuse=false)
Loads class data.
Definition: D4Opaque.cc:98
Evaluate a constraint expression.
D4Opaque & operator=(const D4Opaque &rhs)
Definition: D4Opaque.cc:47
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:53
virtual void print_val(FILE *, std::string="", bool=true)
Definition: D4Opaque.h:85
D4Opaque(const D4Opaque &copy_from)
Definition: D4Opaque.h:52
virtual dods_opaque value() const
Definition: D4Opaque.cc:123
virtual unsigned int width(bool=false) const
How many bytes does this use Return the number of bytes of storage this variable uses. For scalar types, this is pretty simple (an int32 uses 4 bytes, etc.). For arrays and Constructors, it is a bit more complex. Note that a scalar String variable uses sizeof(String*) bytes, not the length of the string. In other words, the value returned is independent of the type. Also note width() of a String array returns the number of elements in the array times sizeof(String*). That is, each different array size is a different data type.
Definition: D4Opaque.h:60