libdap++  Updated for version 3.12.0
ServerFunction.h
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2013 OPeNDAP, Inc.
7 // Author: Nathan Potter <npotter@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 /*
26  * AbstractFunction.h
27  *
28  * Created on: Feb 2, 2013
29  * Author: ndp
30  */
31 
32 #ifndef ABSTRACTFUNCTION_H_
33 #define ABSTRACTFUNCTION_H_
34 
35 #include <iostream>
36 #include "expr.h"
37 
38 using std::endl;
39 
40 #include "BaseType.h"
41 
42 namespace libdap {
43 
44 
46 
47 private:
48  string name;
49  string description;
50  string usage;
51  string doc_url; // @TODO 'doc_url' Should be a URL object.
52  string role; // @TODO 'role' Should be a URI object.
53  string version;
54 
55  libdap::bool_func d_bool_func;
56  libdap::btp_func d_btp_func;
57  libdap::proj_func d_proj_func;
58 
59 public:
61  ServerFunction(string name, string version, string description, string usage, string doc_url, string role, bool_func f);
62  ServerFunction(string name, string version, string description, string usage, string doc_url, string role, btp_func f);
63  ServerFunction(string name, string version, string description, string usage, string doc_url, string role, proj_func f);
64  virtual ~ServerFunction();
65 
66 
67 
68  string getName() { return name; }
69  void setName(const string &n){ name = n; }
70 
71  string getUsageString() { return usage; }
72  void setUsageString(const string &u){ usage = u; }
73 
74  string getDocUrl() { return doc_url; }
75  void setDocUrl(const string &url){ doc_url = url; }
76 
77  string getRole() { return role; }
78  void setRole(const string &r){ role = r; }
79 
80  string getDescriptionString(){ return description; }
81  void setDescriptionString(const string &desc){ description = desc; }
82 
83  string getVersion(){ return version; }
84  void setVersion(const string &ver){ version = ver; }
85 
98  virtual bool canOperateOn(DDS &) { return true; }
99 
100  void setFunction(bool_func bf){
101  d_bool_func = bf;
102  d_btp_func = 0;
103  d_proj_func = 0;
104  }
105 
106  void setFunction(btp_func btp){
107  d_bool_func = 0;
108  d_btp_func = btp;
109  d_proj_func = 0;
110  }
111 
112  void setFunction(proj_func pf){
113  d_bool_func = 0;
114  d_btp_func = 0;
115  d_proj_func = pf;
116  }
117 
118  string getTypeString(){
119  if(d_bool_func)
120  return "boolean";
121  if(d_btp_func)
122  return "basetype";
123  if(d_proj_func)
124  return "projection";
125  return "null";
126  }
127 
128 
129  bool_func get_bool_func(){ return d_bool_func; }
130  btp_func get_btp_func() { return d_btp_func; }
131  proj_func get_proj_func(){ return d_proj_func; }
132 
133 };
134 
135 } /* namespace libdap */
136 #endif /* ABSTRACTFUNCTION_H_ */