TECA
The Toolkit for Extreme Climate Analysis
teca_variant_array_operand.h
Go to the documentation of this file.
1 #ifndef teca_variant_array_operand_h
2 #define teca_variant_array_operand_h
3 
4 /// @file
5 
6 #include "teca_variant_array.h"
7 #include "teca_array_collection.h"
8 
9 /// Codes dealing with the operands of run time specified operations on teca_variant_array
11 {
12 
13 /** @brief
14  * Handles conversion of literals to variant_arrays and the name resolution of
15  * variables.
16  */
17 class resolver
18 {
19 public:
20  /** given a text representation of a numeric value in s convert and
21  * return a variant_array filled with the numeric value. the type is
22  * determined by the last 1 or 2 characters in the string, Valid type
23  * codes are:
24  *
25  * d -- double
26  * f -- float
27  * L -- long long
28  * l -- long
29  * i -- int
30  * s -- short
31  * c -- char
32  * u -- unsigned, augments any of the integer types
33  *
34  * the return is non-zero if an error occurred, zero otherwise.
35  */
36  int get_constant(const char *s, p_teca_variant_array &c);
37 
38  /** given the name of a variable in var_name, set var to point to the
39  * array of corresponding name. see set/get_variables.
40  */
41  int get_variable(const char *var_name,
43  {
44  var = m_variables->get(var_name);
45  if (!var) return -1;
46  return 0;
47  }
48 
49  /// get the set of arrays used for variable name resolution.
50  const_p_teca_array_collection get_variables()
51  { return m_variables; }
52 
53  /// set the set of arrays used for variable name resolution.
54  void set_variables(const_p_teca_array_collection v)
55  { m_variables = v; }
56 
57 private:
58  const_p_teca_array_collection m_variables;
59 };
60 
61 };
62 
63 #endif
teca_variant_array.h
teca_variant_array_operand::resolver
Handles conversion of literals to variant_arrays and the name resolution of variables.
Definition: teca_variant_array_operand.h:17
teca_variant_array_operand::resolver::set_variables
void set_variables(const_p_teca_array_collection v)
set the set of arrays used for variable name resolution.
Definition: teca_variant_array_operand.h:54
const_p_teca_variant_array
std::shared_ptr< const teca_variant_array > const_p_teca_variant_array
Definition: teca_variant_array.h:22
teca_variant_array_operand::resolver::get_variable
int get_variable(const char *var_name, const_p_teca_variant_array &var)
Definition: teca_variant_array_operand.h:41
teca_variant_array_operand
Codes dealing with the operands of run time specified operations on teca_variant_array.
Definition: teca_variant_array_operand.h:10
teca_variant_array_operand::resolver::get_variables
const_p_teca_array_collection get_variables()
get the set of arrays used for variable name resolution.
Definition: teca_variant_array_operand.h:50
p_teca_variant_array
std::shared_ptr< teca_variant_array > p_teca_variant_array
Definition: teca_variant_array.h:22
teca_variant_array_operand::resolver::get_constant
int get_constant(const char *s, p_teca_variant_array &c)