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(FILE *stream) const;
00173     virtual void establish_timeout(ostream &stream) const;
00174 
00175     virtual void read_ancillary_das(DAS &das, const string &anc_location = "") const;
00176 
00177     virtual void read_ancillary_dds(DDS &dds, const string &anc_location = "") const;
00178 
00179     virtual void print_usage() const;
00180 
00181     virtual void send_version_info() const;
00182 
00183     virtual void send_das(DAS &das, const string &anc_location = "",
00184                           bool with_mime_headers = true) const;
00185     virtual void send_das(FILE *out, DAS &das, const string &anc_location = "",
00186                           bool with_mime_headers = true) const;
00187     virtual void send_das(ostream &out, DAS &das, const string &anc_location = "",
00188                           bool with_mime_headers = true) const;
00189 
00190     virtual void send_dds(DDS &dds, ConstraintEvaluator &eval,
00191                           bool constrained = false,
00192                           const string &anc_location = "",
00193                           bool with_mime_headers = true) const;
00194     virtual void send_dds(FILE *out, DDS &dds, ConstraintEvaluator &eval,
00195                           bool constrained = false,
00196                           const string &anc_location = "",
00197                           bool with_mime_headers = true) const;
00198     virtual void send_dds(ostream &out, DDS &dds, ConstraintEvaluator &eval,
00199                           bool constrained = false,
00200                           const string &anc_location = "",
00201                           bool with_mime_headers = true) const;
00202 
00203     virtual void functional_constraint(BaseType &var, DDS &dds,
00204                                        ConstraintEvaluator &eval, FILE *out) const;
00205     virtual void functional_constraint(BaseType &var, DDS &dds,
00206                                        ConstraintEvaluator &eval, ostream &out) const;
00207     virtual void dataset_constraint(DDS &dds, ConstraintEvaluator &eval,
00208                                     FILE *out) const;
00209     virtual void dataset_constraint(DDS &dds, ConstraintEvaluator &eval,
00210                                     ostream &out) const;
00211 
00212     virtual void send_data(DDS &dds, ConstraintEvaluator &eval,
00213                            FILE *data_stream,
00214                            const string &anc_location = "",
00215                            bool with_mime_headers = true) const;
00216     virtual void send_data(DDS &dds, ConstraintEvaluator &eval,
00217                            ostream &data_stream,
00218                            const string &anc_location = "",
00219                            bool with_mime_headers = true) const;
00220 
00221     virtual void send_ddx(DDS &dds, ConstraintEvaluator &eval, FILE *out,
00222                           bool with_mime_headers = true) const;
00223     virtual void send_ddx(DDS &dds, ConstraintEvaluator &eval, ostream &out,
00224                           bool with_mime_headers = true) const;
00225 
00226     // Broken. 4/5/06 jhrg
00227     virtual void send_blob(DDS &dds, FILE *out, bool with_mime_headers = true);
00228 };
00229 
00230 } // namespace libdap
00231 
00232 #endif // _dodsfilter_h

Generated on Tue Jun 10 18:00:30 2008 for libdap++ by  doxygen 1.5.4