Turi Create  4.0
turi::option_manager Class Reference

#include <model_server/lib/extensions/option_manager.hpp>

Public Member Functions

void create_real_option (const std::string &name, const std::string &description, flexible_type default_value, double lower_bound, double upper_bound, bool allowed_overwrite=false)
 Convenience overload for create_option.
 
void create_integer_option (const std::string &name, const std::string &description, flexible_type default_value, flex_int lower_bound, flex_int upper_bound, bool allowed_overwrite=false)
 Convenience overload for create_option.
 
void create_categorical_option (const std::string &name, const std::string &description, const flexible_type &default_value, const std::vector< flexible_type > &allowed_possible_values, bool allowed_overwrite=false)
 Convenience overload for create_option.
 
void create_string_option (const std::string &name, const std::string &description, const flexible_type &default_value, bool allowed_overwrite=false)
 Convenience overload for create_option.
 
void create_boolean_option (const std::string &name, const std::string &description, bool default_value, bool allowed_overwrite=false)
 Convenience overload for create_option.
 
void create_flexible_type_option (const std::string &name, const std::string &description, const flexible_type &default_value, bool allowed_overwrite=false)
 Convenience overload for create_option.
 
void create_option (const option_handling::option_info &, bool allowed_overwrite=false)
 
void set_option (const std::string &name, const flexible_type &value)
 
void set_options (const std::map< std::string, flexible_type > &options)
 
void delete_option (const std::string &name)
 
void delete_options (const std::vector< std::string > &names)
 
void update_option_name (const std::string &old_name, const std::string &new_name)
 
void update_option_names (const std::map< std::string, std::string > &name_map)
 
const std::vector< option_handling::option_info > & get_option_info () const
 
const std::map< std::string, flexible_type > & current_option_values () const
 
std::map< std::string, flexible_typeget_default_options () const
 
const flexible_typevalue (const std::string &name) const
 Returns the value of the option.
 
const std::string & description (const std::string &name) const
 Returns the description of the option name.
 
bool is_option (const std::string &name) const
 Returns true if an option exists and false otherwise.
 
void save (turi::oarchive &oarc) const
 Serialization – save.
 
void load (turi::iarchive &iarc)
 Serialization – load.
 

Detailed Description

A general purpose option manager class. Functions like a std::map<std::string, flexible_type>, but permits type checking, description querying, bounds checking, checked categorical values, etc.

Definition at line 26 of file option_manager.hpp.

Member Function Documentation

◆ create_option()

void turi::option_manager::create_option ( const option_handling::option_info ,
bool  allowed_overwrite = false 
)

Create an option as dictated by option_handling::option_info.

By default, if an option of the same name exists as the one being created, an error is raised (cause it's probably a programmer typo). If allowed_overwrite is true, than the option is overwritten. The use case of this is when one module wraps another and has to change some of its options / defaults.

◆ current_option_values()

const std::map<std::string, flexible_type>& turi::option_manager::current_option_values ( ) const

Returns a map of strings to flexible_type that give the values of all the current option values.

◆ delete_option()

void turi::option_manager::delete_option ( const std::string &  name)

Delete one of the options. This removes the option from options_reference_lookup_map and _current_option_values, but does not remove it from the vector options_reference. Useful for loading from older model versions with obsolete option names.

◆ delete_options()

void turi::option_manager::delete_options ( const std::vector< std::string > &  names)

Delete a set of options. This removes the options from options_reference_lookup_map and _current_option_values, but does not remove them from the vector options_reference. Useful for loading from older model versions with obsolete option names.

◆ get_default_options()

std::map<std::string, flexible_type> turi::option_manager::get_default_options ( ) const

Creates and returns a map of the default options, as specified by the model.

◆ get_option_info()

const std::vector<option_handling::option_info>& turi::option_manager::get_option_info ( ) const

Returns the option information struct for each of the set parameters.

◆ set_option()

void turi::option_manager::set_option ( const std::string &  name,
const flexible_type value 
)

Set one of the options. This values is checked against the requirements given by the option instance.

◆ set_options()

void turi::option_manager::set_options ( const std::map< std::string, flexible_type > &  options)

Sets the options. These values are checked against the values in the option reference.

◆ update_option_name()

void turi::option_manager::update_option_name ( const std::string &  old_name,
const std::string &  new_name 
)

Update the name of an option. Useful for loading from older model versions. If an option exists with old_name, create a new option with new_name, copy over values from the old_name, then remove the old option.

◆ update_option_names()

void turi::option_manager::update_option_names ( const std::map< std::string, std::string > &  name_map)

Update the name of a set of options. Useful for loading from older model versions. If an option exists with old_name, create a new option with new_name, copy over values from the old_name, then remove the old option.


The documentation for this class was generated from the following file: