libdap++  Updated for version 3.8.2
GSEClause.h
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2002,2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 // (c) COPYRIGHT URI/MIT 1999
27 // Please read the full copyright statement in the file COPYRIGHT_URI.
28 //
29 // Authors:
30 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31 
32 // The Grid Selection Expression Clause class.
33 
34 #ifndef _gseclause_h
35 #define _gseclause_h 1
36 
37 
38 #include <string>
39 #include <sstream>
40 
41 #ifndef _basetype_h
42 #include "BaseType.h"
43 #endif
44 
45 #ifndef _array_h
46 #include "Array.h"
47 #endif
48 
49 #ifndef _grid_h
50 #include "Grid.h"
51 #endif
52 
53 namespace libdap
54 {
55 
56 enum relop {
64 };
65 
74 class GSEClause
75 {
76 private:
77  Array *d_map;
78  // _value1, 2 and _op1, 2 hold the first and second operators and
79  // operands. For a clause like `var op value' only _op1 and _value1 have
80  // valid information. For a clause like `value op var op value' the
81  // second operator and operand are on _op2 and _value2. 1/19/99 jhrg
82  double d_value1, d_value2;
83  relop d_op1, d_op2;
84  int d_start;
85  int d_stop;
86 
87  string d_map_min_value, d_map_max_value;
88 
89  GSEClause(); // Hidden default constructor.
90 
91  GSEClause(const GSEClause &param); // Hide
92  GSEClause &operator=(GSEClause &rhs); // Hide
93 
94  template<class T> void set_start_stop();
95  template<class T> void set_map_min_max_value(T min, T max);
96 
97  void compute_indices();
98 
99 public:
102  GSEClause(Grid *grid, const string &map, const double value,
103  const relop op);
104 
105  GSEClause(Grid *grid, const string &map, const double value1,
106  const relop op1, const double value2, const relop op2);
108 
109  virtual ~GSEClause() {
110  delete d_map; d_map = 0;
111  }
112 
113  bool OK() const;
114 
117  Array *get_map() const;
118 
119  string get_map_name() const;
120 
121  int get_start() const;
122 
123  int get_stop() const;
124 
125  string get_map_min_value() const;
126 
127  string get_map_max_value() const;
129 
132  void set_map(Array *map);
133 
134  void set_start(int start);
135 
136  void set_stop(int stop);
138 };
139 
140 } // namespace libdap
141 
142 #endif // _gseclause_h
143