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