OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
FoDapJsonTransform.h
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // FoDapJsonTransform.cc
4 //
5 // This file is part of BES JSON File Out Module
6 //
7 // Copyright (c) 2014 OPeNDAP, Inc.
8 // Author: Nathan Potter <ndp@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 // (c) COPYRIGHT URI/MIT 1995-1999
26 // Please read the full copyright statement in the file COPYRIGHT_URI.
27 //
28 
29 #ifndef FODAPNJSONTRANSFORM_H_
30 #define FODAPNJSONTRANSFORM_H_
31 
32 #include <string>
33 #include <vector>
34 #include <map>
35 
36 
37 #include <BaseType.h>
38 #include <DDS.h>
39 #include <Array.h>
40 
41 
42 #include <BESObj.h>
44 
50 class FoDapJsonTransform: public BESObj {
51 private:
52  libdap::DDS *_dds;
53  std::string _localfile;
54  std::string _returnAs;
55  std::string _indent_increment;
56 
57  std::ostream *_ostrm;
58 
59  void writeNodeMetadata(std::ostream *strm, libdap::BaseType *bt, std::string indent);
60  void writeLeafMetadata(std::ostream *strm, libdap::BaseType *bt, std::string indent);
61  void writeDatasetMetadata(std::ostream *strm, libdap::DDS *dds, std::string indent);
62 
63  void transformAtomic(std::ostream *strm, libdap::BaseType *bt, std::string indent, bool sendData);
64 
65 
66  void transform(std::ostream *strm, libdap::DDS *dds, std::string indent, bool sendData);
67  void transform(std::ostream *strm, libdap::BaseType *bt, std::string indent, bool sendData);
68 
69  //void transform(std::ostream *strm, Structure *s,string indent );
70  //void transform(std::ostream *strm, Grid *g, string indent);
71  //void transform(std::ostream *strm, Sequence *s, string indent);
72  void transform(std::ostream *strm, libdap::Constructor *cnstrctr, std::string indent, bool sendData);
73  void transform_node_worker(std::ostream *strm, std::vector<libdap::BaseType *> leaves, std::vector<libdap::BaseType *> nodes, std::string indent, bool sendData);
74 
75 
76  void transform(std::ostream *strm, libdap::Array *a, std::string indent, bool sendData);
77  void transform(std::ostream *strm, libdap::AttrTable &attr_table, std::string indent);
78 
79  template<typename T>
80  void json_simple_type_array(std::ostream *strm, libdap::Array *a, std::string indent, bool sendData);
81 
82  void json_string_array(std::ostream *strm, libdap::Array *a, std::string indent, bool sendData);
83 
84  template<typename T>
85  unsigned int json_simple_type_array_worker(
86  std::ostream *strm,
87  T *values,
88  unsigned int indx,
89  std::vector<unsigned int> *shape,
90  unsigned int currentDim
91  );
92 
93 
94 
95 public:
96 
97  FoDapJsonTransform(libdap::DDS *dds, BESDataHandlerInterface &dhi, const std::string &localfile);
98  FoDapJsonTransform(libdap::DDS *dds, BESDataHandlerInterface &dhi, std::ostream *ostrm);
99  virtual ~FoDapJsonTransform();
100 
101  virtual void transform(bool sendData);
102 
103  virtual void dump(std::ostream &strm) const;
104 
105 };
106 
107 #endif /* FODAPJSONTRANSFORM_H_ */
Used to transform a DDS into a w10n JSON metadata or w10n JSON data document.
virtual void dump(std::ostream &strm) const
dumps information about this transformation object for debugging purposes
Base object for bes objects.
Definition: BESObj.h:52
virtual ~FoDapJsonTransform()
Destructor.
Structure storing information used by the BES to handle the request.
FoDapJsonTransform(libdap::DDS *dds, BESDataHandlerInterface &dhi, const std::string &localfile)
Constructor that creates transformation object from the specified DataDDS object to the specified fil...