28#include "timemory/backends/process.hpp"
29#include "timemory/backends/threading.hpp"
50struct argument_parser;
65 std::string _descript =
"", std::vector<std::string> _cmdline = {},
66 int32_t _count = -1, int32_t _max_count = -1,
67 std::vector<std::string> _choices = {});
82 virtual std::shared_ptr<vsettings>
clone() = 0;
83 virtual void clone(std::shared_ptr<vsettings> rhs);
106 template <
typename Tp>
107 std::pair<bool, Tp>
get()
const;
109 template <
typename Tp>
110 bool get(Tp& _val)
const;
112 template <
typename Tp, enable_if_t<std::is_fundamental<decay_t<Tp>>::value> = 0>
113 bool set(
const Tp& _val);
118 template <
typename Tp>
119 static auto cast(std::shared_ptr<vsettings>& _val)
124 template <
typename Tp>
125 static auto cast(
const std::shared_ptr<vsettings>& _val)
133 static bool _bool_val =
get_env(
"TIMEMORY_DEBUG_SETTINGS",
false);
134 static int _int_val =
get_env(
"TIMEMORY_DEBUG_SETTINGS", 0);
135 return (_bool_val) ? _int_val : 0;
138 template <
typename Tp>
153template <
typename Tp>
160 return {
true, _ref->
get() };
165 return {
true, _nref->
get() };
167 return {
false, Tp{} };
170template <
typename Tp>
174 auto&&
_ret = this->get<Tp>();
180template <
typename Tp, enable_if_t<std::is_fundamental<decay_t<Tp>>::value>>
201template <
typename Tp>
210 std::ostringstream oss;
211 oss << std::boolalpha;
213 <<
") changed: " << _old <<
" --> " << _new <<
"\n";
216 print_demangled_backtrace<6, 3>(oss);
218 std::cerr << oss.str() << std::flush;
224#if defined(TIMEMORY_SETTINGS_HEADER_MODE)
const hash_alias_ptr_t hash_value_t std::string *& _ret
Tp get_env(const std::string &env_id, Tp _default, bool _store)
tim::mpl::apply< std::string > string
Implements a specific setting.
Virtual base class for storing settings.
std::type_index m_type_index
const auto & get_description() const
const auto & get_name() const
vsettings(const vsettings &)=default
auto get_value_index() const
virtual display_map_t get_display(std::ios::fmtflags fmt={}, int _w=-1, int _p=-1)
virtual void add_argument(argparse::argument_parser &)=0
void report_change(Tp _old, const Tp &_new)
virtual bool matches(const std::string &, bool exact=true) const
virtual void clone(std::shared_ptr< vsettings > rhs)
std::vector< std::string > m_choices
vsettings(std::string _name="", std::string _env_name="", std::string _descript="", std::vector< std::string > _cmdline={}, int32_t _count=-1, int32_t _max_count=-1, std::vector< std::string > _choices={})
virtual std::string as_string() const =0
const auto & get_max_count() const
auto get_type_index() const
virtual parser_func_t get_action(TIMEMORY_API)=0
void set_choices(const std::vector< std::string > &v)
std::pair< bool, Tp > get() const
std::type_index m_value_index
void set(const std::string &_val)
virtual ~vsettings()=default
vsettings & operator=(const vsettings &)=default
std::map< std::string, std::string > display_map_t
void set_count(int32_t v)
vsettings & operator=(vsettings &&)=default
virtual void parse(const std::string &)=0
const auto & get_env_name() const
std::string m_description
const auto & get_command_line() const
static auto cast(std::shared_ptr< vsettings > &_val)
const auto & get_count() const
std::vector< std::string > m_cmdline
virtual std::shared_ptr< vsettings > clone()=0
void set_max_count(int32_t v)
std::function< void(parser_t &)> parser_func_t
static auto cast(const std::shared_ptr< vsettings > &_val)
vsettings(vsettings &&)=default
void set_command_line(const std::vector< std::string > &v)
const auto & get_choices() const