38 {
"$Id: GSEClause.cc 18282 2008-03-01 01:36:12Z jimg $" 67 GSEClause::GSEClause()
69 throw InternalErr(__FILE__, __LINE__,
"default ctor called for GSEClause");
72 GSEClause::GSEClause(
const GSEClause &)
74 throw InternalErr(__FILE__, __LINE__,
"copy ctor called for GSEClause");
77 GSEClause &GSEClause::operator=(GSEClause &)
79 throw InternalErr(__FILE__, __LINE__,
"assigment called for GSEClause");
86 compare(T elem,
relop op,
double value)
100 return elem != value;
102 throw Error(
malformed_expr,
"Attempt to use NOP in Grid selection.");
104 throw Error(
malformed_expr,
"Unknown relational operator in Grid selection.");
111 GSEClause::set_map_min_max_value(T min, T max)
113 DBG(cerr <<
"Inside set map min max value " << min <<
", " << max << endl);
114 std::ostringstream oss1;
116 d_map_min_value = oss1.str();
118 std::ostringstream oss2;
120 d_map_max_value = oss2.str();
126 GSEClause::set_start_stop()
128 T *vals =
new T[d_map->length()];
133 set_map_min_max_value<T>(vals[d_start], vals[d_stop]);
142 while (i <= end && !compare<T>(vals[i], d_op1, d_value1))
150 while (i >= 0 && !compare<T>(vals[i], d_op1, d_value1))
161 while (i <= end && !compare<T>(vals[i], d_op2, d_value2))
167 while (i >= 0 && !compare<T>(vals[i], d_op2, d_value2))
175 GSEClause::compute_indices()
177 switch (d_map->var()->type()) {
179 set_start_stop<dods_byte>();
182 set_start_stop<dods_int16>();
185 set_start_stop<dods_uint16>();
188 set_start_stop<dods_int32>();
191 set_start_stop<dods_uint32>();
194 set_start_stop<dods_float32>();
197 set_start_stop<dods_float64>();
201 "Grid selection using non-numeric map vectors is not supported");
209 GSEClause::GSEClause(
Grid *grid,
const string &map,
const double value,
212 d_value1(value), d_value2(0), d_op1(op), d_op2(
dods_nop_op),
213 d_map_min_value(
""), d_map_max_value(
"")
215 d_map =
dynamic_cast<Array *
>(grid->
var(map));
217 throw Error(
string(
"The map variable '") + map
218 +
string(
"' does not exist in the grid '")
219 + grid->
name() + string(
"'."));
232 GSEClause::GSEClause(
Grid *grid,
const string &map,
const double value1,
233 const relop op1,
const double value2,
const relop op2)
235 d_value1(value1), d_value2(value2), d_op1(op1), d_op2(op2),
236 d_map_min_value(
""), d_map_max_value(
"")
238 d_map =
dynamic_cast<Array *
>(grid->
var(map));
240 throw Error(
string(
"The map variable '") + map
241 +
string(
"' does not exist in the grid '")
242 + grid->
name() + string(
"'."));
290 return d_map->
name();
316 DBG(cerr <<
"Returning stop index value of: " << d_stop << endl);
335 return d_map_min_value;
345 return d_map_max_value;
void gse_switch_to_buffer(void *new_buffer)
string name() const
Returns the name of the class instance.
virtual string toString()
string get_map_max_value() const
Get the maximum map vector value.
int get_stop() const
Get the stopping index of the clause's map variable as constrained by this clause.
void * gse_string(const char *yy_str)
std::vector< dimension >::iterator Dim_iter
string get_map_min_value() const
Get the minimum map vector value.
Holds the Grid data type.
void set_start(int start)
Set the starting index.
void set_stop(int stop)
Set the stopping index.
virtual int dimension_stop(Dim_iter i, bool constrained=false)
Return the stop index of the constraint.
virtual int dimension_start(Dim_iter i, bool constrained=false)
Return the start index of a dimension.
int get_start() const
Get the starting index of the clause's map variable as constrained by this clause.
virtual BaseType * var(const string &n, bool exact=true, btp_stack *s=0)
Array * get_map() const
Get a pointer to the map variable constrained by this clause.
void gse_restart(FILE *in)
A class for error processing.
void gse_delete_buffer(void *buffer)
A multidimensional array of identical data types.
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.