Awali
Another Weighted Automata library
Public Member Functions
awali::dyn::options_t Class Reference

An options_t is a set of optional parameters that is passed on to called functions. More...

#include <options.hh>

Public Member Functions

template<typename T >
 options_t (internal::option_t< T > opt)
 Creates an options_t from an internal::option_t by mapping it to its default value. More...
 
 options_t (internal::option_value_pair_t pair)
 Creates an options_t from one option/value pair. More...
 
 options_t (std::initializer_list< internal::option_value_pair_t > list)
 Creates an options_t from a list of option/value pairs. More...
 
options_t operator+ (internal::option_value_pair_t const &pair) const
 Creates a new options_t that is the union of this options_t with another option/value pair. More...
 
options_t operator+ (options_t const &other) const
 Creates a new options_t that is the union of this options_t with another options_t. More...
 
options_toperator+= (internal::option_value_pair_t const &other)
 Adds an option/value pair to this options_t, possibly overriding a previous value. More...
 
options_toperator+= (options_t const &other)
 Adds all option/value mapping in other to this options_t, possibly overriding previous values. More...
 
template<typename T >
internal::option_t< T >::value_t operator[] (internal::option_t< T > option)
 Gets the value associated by to given option by this options_t. More...
 

Detailed Description

An options_t is a set of optional parameters that is passed on to called functions.

More precisely, it is a map from registered internal::option_t to their expected value. Hence in general, adding new mappings to an options_t might override a previous mapping.

This class is an attempt to reduce the number of optional parameters in functions. It emulates the named optional parameters paradigm of high level languages (typically, in Python).

(Examples below assume using namespace awali and using namespace awali::dyn.)

Example (Providing one option)
ratexp_t exp = ratexp_t::from("(aa)*a(aa)*");
// Computing the Thompson automaton of exp
automaton_t aut1 = exp_to_aut(exp, {EXP_TO_AUT_ALGO=THOMPSON} );
// Compute the automaton resulting from the "Derived Term" algorithm
automaton_t aut2 = exp_to_aut(exp, {EXP_TO_AUT_ALGO=DERIVED_TERM} );
Example (Providing multiple options)
ratexp_t exp = ratexp_t::from("(aa)*aa(aa)*");
// Next line computes the minimal automaton accepting the language
// of `exp`.
// It basically calls in order:
// 1. exp_to_aut, 2. proper, 3. determinize, 4. min_quotient
// Optional parameters for all these functions may be provided.
automaton_t aut = minimal_automaton(exp,
Example (Meaningless options are silently ignored)
options_t opt = { IN_PLACE=true,
KEEP_HISTORY=true, //This is useless since KEEP_HISTORY
//default to `true` anyway
};
ratexp_t exp = ratexp_t::from("(a+b)*aba(a+b)*");
automaton_t aut = exp_to_aut(exp, opt); // Only EXP_TO_AUT_ALGO is
// meaningful, Thompson's
// algorithm is used.
proper(aut, opt); // IN_PLACE is meaningful, hence this modifies `aut`

See group Options for details on this mechanism.

Constructor & Destructor Documentation

◆ options_t() [1/3]

awali::dyn::options_t::options_t ( std::initializer_list< internal::option_value_pair_t list)

Creates an options_t from a list of option/value pairs.

Parameters
listList of option/value pairs.

◆ options_t() [2/3]

awali::dyn::options_t::options_t ( internal::option_value_pair_t  pair)

Creates an options_t from one option/value pair.

Parameters
pairOption/value pair.

◆ options_t() [3/3]

template<typename T >
awali::dyn::options_t::options_t ( internal::option_t< T >  opt)

Creates an options_t from an internal::option_t by mapping it to its default value.

Member Function Documentation

◆ operator+() [1/2]

options_t awali::dyn::options_t::operator+ ( internal::option_value_pair_t const &  pair) const

Creates a new options_t that is the union of this options_t with another option/value pair.

If pair gives a value to an option that is already defined in this options_t, the one in pair in kept and the one in this options_t is ignored.

Parameters
pairoption/value pair to be added.
Returns
A new options_t

◆ operator+() [2/2]

options_t awali::dyn::options_t::operator+ ( options_t const &  other) const

Creates a new options_t that is the union of this options_t with another options_t.

If other and this options_t give a value to the same option, only the one in other is kept in the returned options_t.

Parameters
otherRight operand of the union.
Returns
A new options_t

◆ operator+=() [1/2]

options_t& awali::dyn::options_t::operator+= ( internal::option_value_pair_t const &  other)

Adds an option/value pair to this options_t, possibly overriding a previous value.

Parameters
otherNew pair to add in this options_t.
Returns
A reference to this options_t

◆ operator+=() [2/2]

options_t& awali::dyn::options_t::operator+= ( options_t const &  other)

Adds all option/value mapping in other to this options_t, possibly overriding previous values.

Parameters
other
Returns
A reference to this options_t.

◆ operator[]()

template<typename T >
internal::option_t<T>::value_t awali::dyn::options_t::operator[] ( internal::option_t< T >  option)

Gets the value associated by to given option by this options_t.

Parameters
option
Returns
An object of the type declared by option.

The documentation for this class was generated from the following file:
awali::MOORE
@ MOORE
Definition: enums.hh:65
awali::dyn::EXP_TO_AUT_ALGO
internal::option_t< exp_to_aut_algo_t > EXP_TO_AUT_ALGO
Option used when a rational expression is computed from an automaton.
awali::dyn::minimal_automaton
automaton_t minimal_automaton(automaton_t aut, options_t opts={})
Computes the minimal complete deterministic automaton of the language accepted by aut.
awali::dyn::proper
automaton_t proper(automaton_t aut, options_t opts={})
Removes epsilon-transitions in aut or returns a new automaton equivalent to aut that has no epsilon-t...
awali::dyn::QUOTIENT_ALGO
internal::option_t< quotient_algo_t > QUOTIENT_ALGO
Option used to specify the algorithm to use for computing quotients.
awali::dyn::MINIM_ALGO
internal::option_t< minim_algo_t > MINIM_ALGO
Option used to specify the algorithm to use for computing minimization.
awali::dyn::exp_to_aut
automaton_t exp_to_aut(ratexp_t ratexp, options_t opts={})
Computes an automaton equivalent to ratexp.
awali::THOMPSON
@ THOMPSON
The classical Thompson automaton, with epsilon-transitions.
Definition: enums.hh:92
awali::dyn::IN_PLACE
internal::option_t< bool > IN_PLACE
Option used when an algorithm may be done in place.
awali::DETERMINIZE_QUOTIENT
@ DETERMINIZE_QUOTIENT
Determinizes, then computes the minimal quotient (see quotient_algo_t).
Definition: enums.hh:57
awali::DERIVED_TERM
@ DERIVED_TERM
Also known as Partial derived terms.
Definition: enums.hh:82
awali::dyn::options_t::options_t
options_t(std::initializer_list< internal::option_value_pair_t > list)
Creates an options_t from a list of option/value pairs.
awali::dyn::ratexp_t::from
static ratexp_t from(std::string str, std::string weightset="B", std::string alphabet="auto")
awali::dyn::KEEP_HISTORY
internal::option_t< bool > KEEP_HISTORY
Option used to specify whether to keep the history of states.