40 #include <dods-datatypes.h>
42 #include <InternalErr.h>
57 GSEClause::GSEClause()
59 throw InternalErr(__FILE__, __LINE__,
"default ctor called for GSEClause");
62 GSEClause::GSEClause(
const GSEClause &)
64 throw InternalErr(__FILE__, __LINE__,
"copy ctor called for GSEClause");
67 GSEClause &GSEClause::operator=(GSEClause &)
69 throw InternalErr(__FILE__, __LINE__,
"assigment called for GSEClause");
77 compare(T elem,
relop op,
double value)
93 throw Error(malformed_expr,
"Attempt to use NOP in Grid selection.");
95 throw Error(malformed_expr,
"Unknown relational operator in Grid selection.");
102 GSEClause::set_map_min_max_value(T min, T max)
104 DBG(cerr <<
"Inside set map min max value " << min <<
", " << max << endl);
105 std::ostringstream oss1;
107 d_map_min_value = oss1.str();
109 std::ostringstream oss2;
111 d_map_max_value = oss2.str();
117 GSEClause::set_start_stop()
119 T *vals =
new T[d_map->length()];
124 set_map_min_max_value<T>(vals[d_start], vals[d_stop]);
133 while (i <= end && !compare<T>(vals[i], d_op1, d_value1))
141 while (i >= 0 && !compare<T>(vals[i], d_op1, d_value1))
152 while (i <= end && !compare<T>(vals[i], d_op2, d_value2))
158 while (i >= 0 && !compare<T>(vals[i], d_op2, d_value2))
168 GSEClause::compute_indices()
170 switch (d_map->var()->type()) {
172 set_start_stop<dods_byte>();
175 set_start_stop<dods_int16>();
178 set_start_stop<dods_uint16>();
181 set_start_stop<dods_int32>();
184 set_start_stop<dods_uint32>();
187 set_start_stop<dods_float32>();
190 set_start_stop<dods_float64>();
193 throw Error(malformed_expr,
194 "Grid selection using non-numeric map vectors is not supported");
202 GSEClause::GSEClause(Grid *grid,
const string &map,
const double value,
205 d_value1(value), d_value2(0), d_op1(op), d_op2(
dods_nop_op),
206 d_map_min_value(
""), d_map_max_value(
"")
208 d_map =
dynamic_cast<Array *
>(grid->var(map));
210 throw Error(
string(
"The map variable '") + map
211 +
string(
"' does not exist in the grid '")
212 + grid->name() + string(
"'."));
214 DBG(cerr << d_map->toString());
217 Array::Dim_iter iter = d_map->dim_begin();
218 d_start = d_map->dimension_start(iter);
219 d_stop = d_map->dimension_stop(iter);
225 GSEClause::GSEClause(Grid *grid,
const string &map,
const double value1,
226 const relop op1,
const double value2,
const relop op2)
228 d_value1(value1), d_value2(value2), d_op1(op1), d_op2(op2),
229 d_map_min_value(
""), d_map_max_value(
"")
231 d_map =
dynamic_cast<Array *
>(grid->var(map));
233 throw Error(
string(
"The map variable '") + map
234 +
string(
"' does not exist in the grid '")
235 + grid->name() + string(
"'."));
237 DBG(cerr << d_map->toString());
240 Array::Dim_iter iter = d_map->dim_begin();
241 d_start = d_map->dimension_start(iter);
242 d_stop = d_map->dimension_stop(iter);
283 return d_map->name();
309 DBG(cerr <<
"Returning stop index value of: " << d_stop << endl);
328 return d_map_min_value;
338 return d_map_max_value;
Array * get_map() const
Get a pointer to the map variable constrained by this clause.
bool OK() const
Class invariant.
string get_map_max_value() const
Get the maximum map vector value.
int get_start() const
Get the starting index of the clause's map variable as constrained by this clause.
void set_start(int start)
Set the starting index.
void set_stop(int stop)
Set the stopping index.
int get_stop() const
Get the stopping index of the clause's map variable as constrained by this clause.
string get_map_min_value() const
Get the minimum map vector value.
void set_map(Array *map)
Set the pointer to the map vector contrained by this clause.
string get_map_name() const
Get the name of the map variable constrained by this clause.