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

Generated on Wed Apr 15 19:20:23 2009 for libdap++ by  doxygen 1.4.7