libdap  Updated for version 3.17.0
DODSFilter.h
00001 
00002 // -*- mode: c++; c-basic-offset:4 -*-
00003 
00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
00005 // Access Protocol.
00006 
00007 // Copyright (c) 2002,2003 OPeNDAP, Inc.
00008 // Author: James Gallagher <jgallagher@opendap.org>
00009 //
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023 //
00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
00025 
00026 // (c) COPYRIGHT URI/MIT 1997-1999
00027 // Please first read the full copyright statement in the file COPYRIGHT_URI.
00028 //
00029 // Authors:
00030 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
00031 
00032 #ifndef _dodsfilter_h
00033 #define _dodsfilter_h
00034 
00035 #include <string>
00036 
00037 #ifndef _das_h
00038 #include "DAS.h"
00039 #endif
00040 
00041 #ifndef _dds_h
00042 #include "DDS.h"
00043 #endif
00044 
00045 #ifndef constraint_evaluator_h
00046 #include "ConstraintEvaluator.h"
00047 #endif
00048 
00049 namespace libdap
00050 {
00051 
00078 class DODSFilter
00079 {
00080 public:
00082     enum Response {
00083         Unknown_Response,
00084         DAS_Response,
00085         DDS_Response,
00086         DataDDS_Response,
00087         DDX_Response,
00088         DataDDX_Response,
00089         BLOB_Response,
00090         Version_Response
00091     };
00092 
00093 protected:
00094     bool d_comp;  // True if the output should be compressed.
00095     bool d_bad_options;  // True if the options (argc,argv) are bad.
00096     bool d_conditional_request;
00097 
00098     string d_program_name; // Name of the filter program
00099     string d_dataset;  // Name of the dataset/database
00100     string d_dap2ce;  // DAP2 Constraint expression
00101     string d_cgi_ver;  // Version of CGI script (caller)
00102     string d_anc_dir;  // Look here for ancillary files
00103     string d_anc_file;  // Use this for ancillary file name
00104     string d_cache_dir;  // Use this for cache files
00105     string d_url;  // URL minus CE.
00106 
00107     Response d_response; // enum name of the response to generate
00108     string d_action;  // string name of the response to generate
00109 
00110     int d_timeout;  // Server timeout after N seconds
00111 
00112     time_t d_anc_das_lmt; // Last modified time of the anc. DAS.
00113     time_t d_anc_dds_lmt; // Last modified time of the anc. DDS.
00114     time_t d_if_modified_since; // Time from a conditional request.
00115 
00116     void initialize();
00117     void initialize(int argc, char *argv[]);
00118 
00119     virtual int process_options(int argc, char *argv[]);
00120 
00121 public:
00129     DODSFilter()
00130     {
00131         initialize();
00132     }
00133     DODSFilter(int argc, char *argv[]) throw(Error);
00134 
00135     virtual ~DODSFilter();
00136 
00137     virtual bool is_conditional() const;
00138 
00139     virtual string get_cgi_version() const;
00140     virtual void set_cgi_version(string version);
00141 
00142     virtual string get_ce() const;
00143     virtual void set_ce(string _ce);
00144 
00145     virtual string get_dataset_name() const;
00146     virtual void set_dataset_name(const string _dataset);
00147 
00148     virtual string get_URL() const;
00149     virtual void set_URL(const string &url);
00150 
00151     virtual string get_dataset_version() const;
00152 
00153     virtual Response get_response() const;
00154     virtual string get_action() const;
00155     virtual void set_response(const string &r);
00156 
00157     virtual time_t get_dataset_last_modified_time() const;
00158 
00159     virtual time_t get_das_last_modified_time(const string &anc_location = "") const;
00160 
00161     virtual time_t get_dds_last_modified_time(const string &anc_location = "") const;
00162 
00163     virtual time_t get_data_last_modified_time(const string &anc_location = "") const;
00164 
00165     virtual time_t get_request_if_modified_since() const;
00166 
00167     virtual string get_cache_dir() const;
00168 
00169     void set_timeout(int timeout = 0);
00170 
00171     int get_timeout() const;
00172 
00173     virtual void establish_timeout(ostream &stream) const;
00174 
00175     virtual void print_usage() const;
00176 
00177     virtual void send_version_info() const;
00178 
00179     virtual void send_das(DAS &das, const string &anc_location = "",
00180                           bool with_mime_headers = true) const;
00181     virtual void send_das(ostream &out, DAS &das, const string &anc_location = "",
00182                           bool with_mime_headers = true) const;
00183 
00184     virtual void send_dds(DDS &dds, ConstraintEvaluator &eval,
00185                           bool constrained = false,
00186                           const string &anc_location = "",
00187                           bool with_mime_headers = true) const;
00188     virtual void send_dds(ostream &out, DDS &dds, ConstraintEvaluator &eval,
00189                           bool constrained = false,
00190                           const string &anc_location = "",
00191                           bool with_mime_headers = true) const;
00192     // deprecated
00193     virtual void functional_constraint(BaseType &var, DDS &dds,
00194                                        ConstraintEvaluator &eval, ostream &out) const;
00195 
00196     virtual void dataset_constraint(DDS &dds, ConstraintEvaluator &eval,
00197                                     ostream &out, bool ce_eval = true) const;
00198     virtual void dataset_constraint_ddx(DDS & dds, ConstraintEvaluator & eval,
00199                                    ostream &out, const string &boundary,
00200                                    const string &start,
00201                                    bool ce_eval = true) const;
00202 
00203     virtual void send_data(DDS &dds, ConstraintEvaluator &eval,
00204                            ostream &data_stream,
00205                            const string &anc_location = "",
00206                            bool with_mime_headers = true) const;
00207     virtual void send_ddx(DDS &dds, ConstraintEvaluator &eval, ostream &out,
00208                           bool with_mime_headers = true) const;
00209     virtual void send_data_ddx(DDS &dds, ConstraintEvaluator &eval,
00210                            ostream &data_stream, const string &start,
00211                            const string &boundary,
00212                            const string &anc_location = "",
00213                            bool with_mime_headers = true) const;
00214 
00215     virtual void establish_timeout(FILE *stream) const;
00216     virtual void send_das(FILE *out, DAS &das, const string &anc_location = "",
00217                           bool with_mime_headers = true) const;
00218     virtual void send_dds(FILE *out, DDS &dds, ConstraintEvaluator &eval,
00219                           bool constrained = false,
00220                           const string &anc_location = "",
00221                           bool with_mime_headers = true) const;
00222     // deprecated
00223     virtual void functional_constraint(BaseType &var, DDS &dds,
00224                                        ConstraintEvaluator &eval, FILE *out) const;
00225 
00226     virtual void dataset_constraint(DDS &dds, ConstraintEvaluator &eval,
00227                                     FILE *out, bool ce_eval = true) const;
00228     virtual void send_data(DDS &dds, ConstraintEvaluator &eval,
00229                            FILE *data_stream,
00230                            const string &anc_location = "",
00231                            bool with_mime_headers = true) const;
00232     virtual void send_ddx(DDS &dds, ConstraintEvaluator &eval, FILE *out,
00233                           bool with_mime_headers = true) const;
00234 };
00235 
00236 } // namespace libdap
00237 
00238 #endif // _dodsfilter_h