libdap++ Updated for version 3.8.2

DODSFilter.h

Go to the documentation of this file.
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 #define FILE_METHODS 1
00050 
00051 namespace libdap
00052 {
00053 
00080 class DODSFilter
00081 {
00082 public:
00084     enum Response {
00085         Unknown_Response,
00086         DAS_Response,
00087         DDS_Response,
00088         DataDDS_Response,
00089         DDX_Response,
00090         DataDDX_Response,
00091         BLOB_Response,
00092         Version_Response
00093     };
00094 
00095 protected:
00096     bool d_comp;  // True if the output should be compressed.
00097     bool d_bad_options;  // True if the options (argc,argv) are bad.
00098     bool d_conditional_request;
00099 
00100     string d_program_name; // Name of the filter program
00101     string d_dataset;  // Name of the dataset/database
00102     string d_ce;  // Constraint expression
00103     string d_cgi_ver;  // Version of CGI script (caller)
00104     string d_anc_dir;  // Look here for ancillary files
00105     string d_anc_file;  // Use this for ancillary file name
00106     string d_cache_dir;  // Use this for cache files
00107     string d_url;  // URL minus CE.
00108 
00109     Response d_response; // enum name of the response to generate
00110     string d_action;  // string name of the response to generate
00111 
00112     int d_timeout;  // Server timeout after N seconds
00113 
00114     time_t d_anc_das_lmt; // Last modified time of the anc. DAS.
00115     time_t d_anc_dds_lmt; // Last modified time of the anc. DDS.
00116     time_t d_if_modified_since; // Time from a conditional request.
00117 
00118     void initialize();
00119     void initialize(int argc, char *argv[]);
00120 
00121     virtual int process_options(int argc, char *argv[]);
00122 
00123 public:
00131     DODSFilter()
00132     {
00133         initialize();
00134     }
00135     DODSFilter(int argc, char *argv[]) throw(Error);
00136 
00137     virtual ~DODSFilter();
00138 
00139     virtual bool is_conditional() const;
00140 
00141     virtual string get_cgi_version() const;
00142     virtual void set_cgi_version(string version);
00143 
00144     virtual string get_ce() const;
00145     virtual void set_ce(string _ce);
00146 
00147     virtual string get_dataset_name() const;
00148     virtual void set_dataset_name(const string _dataset);
00149 
00150     virtual string get_URL() const;
00151     virtual void set_URL(const string &url);
00152 
00153     virtual string get_dataset_version() const;
00154 
00155     virtual Response get_response() const;
00156     virtual string get_action() const;
00157     virtual void set_response(const string &r);
00158 
00159     virtual time_t get_dataset_last_modified_time() const;
00160 
00161     virtual time_t get_das_last_modified_time(const string &anc_location = "") const;
00162 
00163     virtual time_t get_dds_last_modified_time(const string &anc_location = "") const;
00164 
00165     virtual time_t get_data_last_modified_time(const string &anc_location = "") const;
00166 
00167     virtual time_t get_request_if_modified_since() const;
00168 
00169     virtual string get_cache_dir() const;
00170 
00171     void set_timeout(int timeout = 0);
00172 
00173     int get_timeout() const;
00174 
00175     virtual void establish_timeout(ostream &stream) const;
00176 
00177     virtual void print_usage() const;
00178 
00179     virtual void send_version_info() const;
00180 
00181     virtual void send_das(DAS &das, const string &anc_location = "",
00182                           bool with_mime_headers = true) const;
00183     virtual void send_das(ostream &out, DAS &das, const string &anc_location = "",
00184                           bool with_mime_headers = true) const;
00185 
00186     virtual void send_dds(DDS &dds, ConstraintEvaluator &eval,
00187                           bool constrained = false,
00188                           const string &anc_location = "",
00189                           bool with_mime_headers = true) const;
00190     virtual void send_dds(ostream &out, DDS &dds, ConstraintEvaluator &eval,
00191                           bool constrained = false,
00192                           const string &anc_location = "",
00193                           bool with_mime_headers = true) const;
00194     // deprecated
00195     virtual void functional_constraint(BaseType &var, DDS &dds,
00196                                        ConstraintEvaluator &eval, ostream &out) const;
00197 
00198     virtual void dataset_constraint(DDS &dds, ConstraintEvaluator &eval,
00199                                     ostream &out, bool ce_eval = true) const;
00200     virtual void dataset_constraint_ddx(DDS & dds, ConstraintEvaluator & eval,
00201                                    ostream &out, const string &boundary,
00202                                    const string &start,
00203                                    bool ce_eval = true) const;
00204 
00205     virtual void send_data(DDS &dds, ConstraintEvaluator &eval,
00206                            ostream &data_stream,
00207                            const string &anc_location = "",
00208                            bool with_mime_headers = true) const;
00209     virtual void send_ddx(DDS &dds, ConstraintEvaluator &eval, ostream &out,
00210                           bool with_mime_headers = true) const;
00211     virtual void send_data_ddx(DDS &dds, ConstraintEvaluator &eval,
00212                            ostream &data_stream, const string &start,
00213                            const string &boundary,
00214                            const string &anc_location = "",
00215                            bool with_mime_headers = true) const;
00216 
00217 #if FILE_METHODS
00218     virtual void establish_timeout(FILE *stream) const;
00219     virtual void send_das(FILE *out, DAS &das, const string &anc_location = "",
00220                           bool with_mime_headers = true) const;
00221     virtual void send_dds(FILE *out, DDS &dds, ConstraintEvaluator &eval,
00222                           bool constrained = false,
00223                           const string &anc_location = "",
00224                           bool with_mime_headers = true) const;
00225     // deprecated
00226     virtual void functional_constraint(BaseType &var, DDS &dds,
00227                                        ConstraintEvaluator &eval, FILE *out) const;
00228 
00229     virtual void dataset_constraint(DDS &dds, ConstraintEvaluator &eval,
00230                                     FILE *out, bool ce_eval = true) const;
00231     virtual void send_data(DDS &dds, ConstraintEvaluator &eval,
00232                            FILE *data_stream,
00233                            const string &anc_location = "",
00234                            bool with_mime_headers = true) const;
00235     virtual void send_ddx(DDS &dds, ConstraintEvaluator &eval, FILE *out,
00236                           bool with_mime_headers = true) const;
00237 #endif
00238 };
00239 
00240 } // namespace libdap
00241 
00242 #endif // _dodsfilter_h