libdap  Updated for version 3.17.0
ServerFunction.h
00001 // -*- mode: c++; c-basic-offset:4 -*-
00002 
00003 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
00004 // Access Protocol.
00005 
00006 // Copyright (c) 2013 OPeNDAP, Inc.
00007 // Author: Nathan Potter <npotter@opendap.org>
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 //
00023 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
00024 
00025 /*
00026  * ServerFunction.h
00027  *
00028  *  Created on: Feb 2, 2013
00029  *      Author: ndp
00030  */
00031 
00032 #ifndef SERVER_FUNCTION_H_
00033 #define SERVER_FUNCTION_H_
00034 
00035 #include <iostream>
00036 
00037 #include <expr.h>
00038 #include <D4Function.h>
00039 
00040 namespace libdap {
00041 
00042 class ServerFunction {
00043 
00044 private:
00045     std::string name;
00046     std::string description;
00047     std::string usage;
00048     std::string doc_url;
00049     std::string role;
00050     std::string version;
00051 
00052     // These are typedefs from DAP2 that are used with its CE parser
00053     // and are found in expr.h. jhrg 3/10/14
00054     bool_func d_bool_func;
00055     btp_func  d_btp_func;
00056     proj_func d_proj_func;
00057 
00058     D4Function d_d4_function;
00059 
00060 public:
00061     ServerFunction();
00062     ServerFunction(std::string name, std::string version, std::string description, std::string usage,
00063                 std::string doc_url, std::string role, bool_func f);
00064     ServerFunction(std::string name, std::string version, std::string description, std::string usage,
00065                 std::string doc_url, std::string role, btp_func f);
00066     ServerFunction(std::string name, std::string version, std::string description, std::string usage,
00067                 std::string doc_url, std::string role, proj_func f);
00068     ServerFunction(std::string name, std::string version, std::string description, std::string usage,
00069                 std::string doc_url, std::string role, D4Function f);
00070 
00071     virtual ~ServerFunction() { }
00072 
00073         std::string getName() { return name; }
00074         void setName(const std::string &n){ name = n; }
00075 
00076         std::string getUsageString() { return usage; }
00077         void setUsageString(const std::string &u){ usage = u; }
00078 
00079         std::string getDocUrl() { return doc_url; }
00080         void setDocUrl(const std::string &url){ doc_url = url; }
00081 
00082         std::string getRole() { return role; }
00083         void setRole(const std::string &r){ role = r; }
00084 
00085         std::string getDescriptionString(){ return description; }
00086         void setDescriptionString(const std::string &desc){ description = desc; }
00087 
00088         std::string getVersion(){ return version; }
00089         void setVersion(const std::string &ver){ version = ver; }
00090 
00103         virtual bool canOperateOn(DDS &) { return true; }
00104 
00110         virtual bool canOperateOn(DMR &) { return true; }
00111 
00120         void setFunction(bool_func bf) {
00121                 d_bool_func = bf;
00122         }
00123 
00124         void setFunction(btp_func btp) {
00125                 d_btp_func  = btp;
00126         }
00127 
00128         void setFunction(proj_func pf) {
00129                 d_proj_func = pf;
00130         }
00131 
00132         void setFunction(D4Function pf) {
00133                 d_d4_function = pf;
00134         }
00135 
00136         std::string getTypeString() {
00137                 if (d_bool_func) return "boolean";
00138                 if (d_btp_func) return "basetype";
00139                 if (d_proj_func) return "projection";
00140                 if (d_d4_function) return "D4Function";
00141                 return "null";
00142         }
00143 
00144         bool_func get_bool_func(){ return d_bool_func; }
00145         btp_func  get_btp_func() { return d_btp_func;  }
00146         proj_func get_proj_func(){ return d_proj_func; }
00147         D4Function get_d4_function() { return d_d4_function; }
00148 };
00149 
00150 } /* namespace libdap */
00151 #endif /* SERVER_FUNCTION_H_ */