Documentation for microsoft::quantum::ConfigurationManager
microsoft::quantum::ConfigurationManager
#include <Commandline/ConfigurationManager.hpp>
Public Classes
Name | |
---|---|
struct | Section |
Public Types
Name | |
---|---|
using std::shared_ptr< IConfigBind > | IConfigBindPtr Pointer class used to bind a parameter to a value. |
using std::vector< IConfigBindPtr > | ConfigList List of bound variables. |
using std::shared_ptr< void > | VoidPtr Type-erased configuration pointer. |
using std::type_index | TypeId Type index class. |
using std::shared_ptr< bool > | BoolPtr |
using std::unordered_map< String, IConfigBindPtr > | Parameters |
using DeferredValue::DeferredValuePtr | DeferredValuePtr |
using std::unordered_map< String, DeferredValuePtr > | DeferredRefs |
using IConfigBind::ParameterVisibility | ParameterVisibility |
using std::vector< Section > | Sections List of available sections. |
Public Functions
Name | |
---|---|
ConfigurationManager() Configuration manager is default constructible, non-copyable and non-movable. |
|
ConfigurationManager(ConfigurationManager const & ) | |
ConfigurationManager(ConfigurationManager && ) | |
ConfigurationManager & | operator=(ConfigurationManager const & ) |
ConfigurationManager & | operator=(ConfigurationManager && ) |
~ConfigurationManager() | |
void | setupArguments(ParameterParser & parser) Adds all bound variables as parser arguments. |
void | configure(ParameterParser & parser, bool experimental_mode =false) Configures the value of each bound variable given a parser instance. |
template <typename T > void |
setConfig(T const & value) Given an instance of the ConfigurationManager, this method override settings of class T. |
template <typename T > T const & |
get() const Gets the configuration instance of type T. |
void | printHelp(bool experimental_mode) const Prints options for configurability to the terminal. |
void | printConfiguration() const |
template <typename T > void |
addConfig(String const & id ="", T const & default_value =T()) Adds a new configuration of type T. |
template <typename T > bool |
configWasRegistered() Whether or not a configuration of type previously registered. |
template <typename T > bool |
isActive() Whether or not the component associated with T is active. |
void | setSectionName(String const & name, String const & description) |
void | disableSectionByDefault() Disables the last section added to the manager. |
void | disableSectionById(String const & id) Disables a named section. |
void | enableSectionById(String const & id) Enables a named section. |
void | allowDisableSectionById(String const & id) Allow disabling the full section. |
template <typename T > void |
addParameter(T & bind, T default_value, String const & name, String const & description, ParameterVisibility visibility =ParameterVisibility::CliAndConfig) |
void | addShorthandNotation(String const & parameter, String const & shorthand) |
template <typename T > void |
addParameter(T & bind, String const & name, String const & description, ParameterVisibility visibility =ParameterVisibility::CliAndConfig) |
template <typename T > void |
addExperimentalParameter(T & bind, T default_value, T off_value, String const & name, String const & description, ParameterVisibility visibility =ParameterVisibility::CliAndConfig) |
template <typename T > void |
addExperimentalParameter(T & bind, T default_value, String const & name, String const & description, ParameterVisibility visibility =ParameterVisibility::CliAndConfig) |
template <typename T > void |
addExperimentalParameter(T & bind, String const & name, String const & description, ParameterVisibility visibility =ParameterVisibility::CliAndConfig) |
DeferredValuePtr | getParameter(String const & name) |
template <typename T > bool |
has() const Checks whether a configuration section exists. |
template <typename T > void |
updateParameter(String const & name, T const & value) |
void | loadConfig(String const & filename) Loads a configuration file. |
void | saveConfig(String const & filename) Saves the configuration to the specified file. |
Detailed Description
class microsoft::quantum::ConfigurationManager;
ConfigurationManager is a class that holds a collection of configurations (sections). Each of these sections are embodied in their own class with a one-to-one mapping between configuration section and the configuration type. As an example, if one wishes to make a configuration for the class Foo, one would create a class FooConfig which would hold all the variables that are configurable and then add FooConfig to the ConfigurationManager using [addConfig()](/qat/Api/Classes/classmicrosoft_1_1quantum_1_1_configuration_manager/#function-addconfig)
. For FooConfig to fulfill the concept of a configuration, it must implement a setup functions whose first argument is the ConfigurationManager.
Public Types Documentation
using IConfigBindPtr
using microsoft::quantum::ConfigurationManager::IConfigBindPtr = std::shared_ptr<IConfigBind>;
Pointer class used to bind a parameter to a value.
using ConfigList
using microsoft::quantum::ConfigurationManager::ConfigList = std::vector<IConfigBindPtr>;
List of bound variables.
using VoidPtr
using microsoft::quantum::ConfigurationManager::VoidPtr = std::shared_ptr<void>;
Type-erased configuration pointer.
using TypeId
using microsoft::quantum::ConfigurationManager::TypeId = std::type_index;
Type index class.
using BoolPtr
using microsoft::quantum::ConfigurationManager::BoolPtr = std::shared_ptr<bool>;
using Parameters
using microsoft::quantum::ConfigurationManager::Parameters = std::unordered_map<String, IConfigBindPtr>;
using DeferredValuePtr
using microsoft::quantum::ConfigurationManager::DeferredValuePtr = DeferredValue::DeferredValuePtr;
using DeferredRefs
using microsoft::quantum::ConfigurationManager::DeferredRefs = std::unordered_map<String, DeferredValuePtr>;
using ParameterVisibility
using microsoft::quantum::ConfigurationManager::ParameterVisibility = IConfigBind::ParameterVisibility;
using Sections
using microsoft::quantum::ConfigurationManager::Sections = std::vector<Section>;
List of available sections.
Public Functions Documentation
function ConfigurationManager
ConfigurationManager()
Configuration manager is default constructible, non-copyable and non-movable.
function ConfigurationManager
ConfigurationManager(
ConfigurationManager const &
)
function ConfigurationManager
ConfigurationManager(
ConfigurationManager &&
)
function operator=
ConfigurationManager & operator=(
ConfigurationManager const &
)
function operator=
ConfigurationManager & operator=(
ConfigurationManager &&
)
function ~ConfigurationManager
inline ~ConfigurationManager()
function setupArguments
void setupArguments(
ParameterParser & parser
)
Adds all bound variables as parser arguments.
function configure
void configure(
ParameterParser & parser,
bool experimental_mode =false
)
Configures the value of each bound variable given a parser instance.
function setConfig
template <typename T >
inline void setConfig(
T const & value
)
Given an instance of the ConfigurationManager, this method override settings of class T.
function get
template <typename T >
inline T const & get() const
Gets the configuration instance of type T.
function printHelp
void printHelp(
bool experimental_mode
) const
Prints options for configurability to the terminal.
function printConfiguration
void printConfiguration() const
Prints the configuration to the terminal. The configuration print is LLVM IR compatible meaning that every line starts with a semicolon ; to ensure that it is interpreted as a comment.
function addConfig
template <typename T >
inline void addConfig(
String const & id ="",
T const & default_value =T()
)
Adds a new configuration of type T.
function configWasRegistered
template <typename T >
inline bool configWasRegistered()
Whether or not a configuration of type previously registered.
function isActive
template <typename T >
inline bool isActive()
Whether or not the component associated with T is active.
function setSectionName
void setSectionName(
String const & name,
String const & description
)
Sets the section name. This method is used by the configuration class to set a section name.
function disableSectionByDefault
void disableSectionByDefault()
Disables the last section added to the manager.
function disableSectionById
void disableSectionById(
String const & id
)
Disables a named section.
function enableSectionById
void enableSectionById(
String const & id
)
Enables a named section.
function allowDisableSectionById
void allowDisableSectionById(
String const & id
)
Allow disabling the full section.
function addParameter
template <typename T >
inline void addParameter(
T & bind,
T default_value,
String const & name,
String const & description,
ParameterVisibility visibility =ParameterVisibility::CliAndConfig
)
Adds a new parameter with a default value to the configuration section. This function should be used by the configuration class.
function addShorthandNotation
void addShorthandNotation(
String const & parameter,
String const & shorthand
)
function addParameter
template <typename T >
inline void addParameter(
T & bind,
String const & name,
String const & description,
ParameterVisibility visibility =ParameterVisibility::CliAndConfig
)
Adds a new parameter to the configuration section. This method uses the bound variable value as default value. This function should be used by the configuration class.
function addExperimentalParameter
template <typename T >
inline void addExperimentalParameter(
T & bind,
T default_value,
T off_value,
String const & name,
String const & description,
ParameterVisibility visibility =ParameterVisibility::CliAndConfig
)
Adds an experimental parameter with a default value and an experimental "off" value to the configuration section. This function should be used by the configuration class. The difference to addParameter
is that this function marks the parameter as experimental and has a default "off" value
function addExperimentalParameter
template <typename T >
inline void addExperimentalParameter(
T & bind,
T default_value,
String const & name,
String const & description,
ParameterVisibility visibility =ParameterVisibility::CliAndConfig
)
Adds an experimental parameter with a default value to the configuration section. The experimental off value will be set to the default value of parameter. This function should be used by the configuration class.
function addExperimentalParameter
template <typename T >
inline void addExperimentalParameter(
T & bind,
String const & name,
String const & description,
ParameterVisibility visibility =ParameterVisibility::CliAndConfig
)
Adds an experimental parameter. The default value and the experimental off value will be the value of the parameter added. This function should be used by the configuration class.
function getParameter
DeferredValuePtr getParameter(
String const & name
)
function has
template <typename T >
inline bool has() const
Checks whether a configuration section exists.
function updateParameter
template <typename T >
inline void updateParameter(
String const & name,
T const & value
)
function loadConfig
void loadConfig(
String const & filename
)
Loads a configuration file.
function saveConfig
void saveConfig(
String const & filename
)
Saves the configuration to the specified file.
Updated on 1 August 2023 at 16:25:10 UTC