TECA
The Toolkit for Extreme Climate Analysis
teca_program_options.h
Go to the documentation of this file.
1
#ifndef teca_program_options_h
2
#define teca_program_options_h
3
4
/// @file
5
6
#include "teca_config.h"
7
#include "
teca_common.h
"
8
#include "
teca_mpi_util.h
"
9
10
#if defined(TECA_HAS_BOOST) && !defined(SWIG)
11
namespace
boost
12
{
13
namespace
program_options
14
{
15
class
options_description;
16
class
variables_map;
17
}
18
};
19
20
using
options_description = boost::program_options::options_description;
21
using
variables_map = boost::program_options::variables_map;
22
23
/// initialize the given options description with algorithm's properties
24
#define TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION() \
25
\
26
/** Adds the class algorithm properties to the description object */
\
27
void get_properties_description(const std::string &prefix, \
28
boost::program_options::options_description &opts) override; \
29
30
/// initialize the algorithm from the given options variable map.
31
#define TECA_SET_ALGORITHM_PROPERTIES() \
32
/** Sets the class algorithm properties from the map object */
\
33
void set_properties(const std::string &prefix, \
34
boost::program_options::variables_map &opts) override; \
35
36
// helpers for implementation dealing with Boost
37
// program options. NOTE: because the above declarations
38
// are intented to be included in class header files
39
// we are intentionally not including <string> and
40
// <boost/program_options.hpp>. These need to be
41
// included in your cxx files.
42
//
43
#define TECA_POPTS_GET(_type, _prefix, _name, _desc) \
44
(((_prefix.empty()?"":_prefix+"::") + #_name).c_str(), \
45
boost::program_options::value<_type>()->default_value \
46
(this->get_ ## _name()), "\n" _desc "\n")
47
48
#define TECA_POPTS_MULTI_GET(_type, _prefix, _name, _desc) \
49
(((_prefix.empty()?"":_prefix+"::") + #_name).c_str(), \
50
boost::program_options::value<_type>()->multitoken \
51
()->default_value(this->get_ ## _name()), \
52
"\n" _desc "\n")
53
54
#define TECA_POPTS_SET(_opts, _type, _prefix, _name) \
55
{std::string opt_name = \
56
(_prefix.empty()?"":_prefix+"::") + #_name; \
57
bool defd = _opts[opt_name].defaulted(); \
58
if (!defd) \
59
{ \
60
_type val = _opts[opt_name].as<_type>(); \
61
if (this->verbose && \
62
teca_mpi_util::mpi_rank_0(this->get_communicator())) \
63
{ \
64
TECA_STATUS("Setting " << opt_name << " = " << val) \
65
} \
66
this->set_##_name(val); \
67
}}
68
69
#else
70
#define TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
71
#define TECA_SET_ALGORITHM_PROPERTIES()
72
#endif
73
#endif
teca_mpi_util.h
teca_common.h
rtd_doxygen
core
teca_program_options.h
Generated on Thu Oct 14 2021 20:46:27 for TECA by
1.8.17