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

Generated on Wed Jun 27 12:56:39 2007 for libdap++ by  doxygen 1.4.7