bes  Updated for version 3.20.6
W10nJsonTransform.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // FoW10nJsonTransform.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 W10NJSONTRANSFORM_H_
30 #define W10NJSONTRANSFORM_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>
43 #include <BESDataHandlerInterface.h>
44 
50 class W10nJsonTransform: 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  bool _usingTempFile;
59 
60  //void writeNodeMetadata(std::ostream *strm, libdap::BaseType *bt, std::string indent);
61  void writeVariableMetadata(std::ostream *strm, libdap::BaseType *bt, std::string indent);
62  void writeDatasetMetadata(std::ostream *strm, libdap::DDS *dds, std::string indent);
63 
64  // void transformAtomic(std::ostream *strm, libdap::BaseType *bt, std::string indent);
65 
66 
67  //void transform(std::ostream *strm, libdap::DDS *dds, std::string indent, bool sendData);
68  //void transform(std::ostream *strm, libdap::BaseType *bt, std::string indent, bool sendData);
69 
70  //void transform(std::ostream *strm, Structure *s,string indent );
71  //void transform(std::ostream *strm, Grid *g, string indent);
72  //void transform(std::ostream *strm, Sequence *s, string indent);
73  //void transform(std::ostream *strm, libdap::Constructor *cnstrctr, std::string indent, bool sendData);
74  //void transform_node_worker(std::ostream *strm, std::vector<libdap::BaseType *> leaves, std::vector<libdap::BaseType *> nodes, std::string indent, bool sendData);
75 
76 
77  //void transform(std::ostream *strm, libdap::Array *a, std::string indent, bool sendData);
78  void writeAttributes(std::ostream *strm, libdap::AttrTable &attr_table, std::string indent);
79 
80  template<typename T>
81  void json_simple_type_array(std::ostream *strm, libdap::Array *a, std::string indent);
82  void json_string_array(std::ostream *strm, libdap::Array *a, std::string indent);
83 
84  void json_array_starter(ostream *strm, libdap::Array *a, string indent);
85  template<typename T> void json_simple_type_array_sender(ostream *strm, libdap::Array *a);
86  void json_string_array_sender(ostream *strm, libdap::Array *a);
87  void json_array_ender(ostream *strm, string indent);
88 
89  template<typename T>
90  unsigned int json_simple_type_array_worker(
91  std::ostream *strm,
92  T *values,
93  unsigned int indx,
94  std::vector<unsigned int> *shape,
95  unsigned int currentDim,
96  bool flatten
97  );
98 
99  void sendW10nMetaForDDS(ostream *strm, libdap::DDS *dds, string indent);
100  void sendW10nMetaForVariable(ostream *strm, libdap::BaseType *bt, string indent, bool traverse);
101  std::ostream *getOutputStream();
102  void releaseOutputStream();
103  void sendW10nDataForVariable(ostream *strm, libdap::BaseType *bt, string indent);
104  void sendW10nData(ostream *strm, libdap::BaseType *b, string indent);
105  void sendW10nData(ostream *strm, libdap::Array *b, string indent);
106 
107 public:
108 
109  W10nJsonTransform(libdap::DDS *dds, BESDataHandlerInterface &dhi, const std::string &localfile);
110  W10nJsonTransform(libdap::DDS *dds, BESDataHandlerInterface &dhi, std::ostream *ostrm);
111  virtual ~W10nJsonTransform();
112 
113  //virtual void transform(bool sendData);
114  //virtual void sendMetadata();
115  //virtual void sendData();
116  virtual void sendW10nMetaForDDS();
117  virtual void sendW10nMetaForVariable(string &vName, bool isTop);
118  virtual void sendW10nDataForVariable(string &vName);
119 
120  virtual void dump(std::ostream &strm) const;
121 
122 };
123 
124 #endif /* W10NJSONTRANSFORM_H_ */
W10nJsonTransform::dump
virtual void dump(std::ostream &strm) const
dumps information about this transformation object for debugging purposes
Definition: W10nJsonTransform.cc:327
BESObj
top level BES object to house generic methods
Definition: BESObj.h:49
W10nJsonTransform::W10nJsonTransform
W10nJsonTransform(libdap::DDS *dds, BESDataHandlerInterface &dhi, const std::string &localfile)
Constructor that creates transformation object from the specified DataDDS object to the specified fil...
Definition: W10nJsonTransform.cc:278
W10nJsonTransform::~W10nJsonTransform
virtual ~W10nJsonTransform()
Destructor.
Definition: W10nJsonTransform.cc:314
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56
W10nJsonTransform
Definition: W10nJsonTransform.h:50