xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
switch_base.h
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <map>
7 #include <vector>
8 #include "../object.h"
9 #include "../ustring.h"
10 #include "source_levels.h"
11 
13 namespace xtd {
15  namespace diagnostics {
26  class switch_base : public object {
27  public:
29  switch_base(const switch_base& value) = default;
30  switch_base& operator=(const switch_base& value) = default;
31  bool operator==(const switch_base& value) const;
32  bool operator!=(const switch_base& value) const;
34 
37  const std::map<xtd::ustring, xtd::ustring>& attributes() const;
40  std::map<xtd::ustring, xtd::ustring>& attributes();
43  void attributes(const std::map<xtd::ustring, xtd::ustring>& attributes);
44 
48  const xtd::ustring& description() const;
49 
53  const xtd::ustring& display_name() const;
54 
55  protected:
62  switch_base(const xtd::ustring& display_name, const xtd::ustring& description);
68  switch_base(const xtd::ustring& display_name, const xtd::ustring& description, const xtd::ustring& default_switch_value);
69 
72  int32_t switch_setting() const;
75  void switch_setting(int32_t switch_setting);
76 
82  const xtd::ustring& value() const;
88  void value(const xtd::ustring& value);
89 
95  virtual std::vector<xtd::ustring> get_supported_attributes() const;
96 
98  virtual void on_switch_setting_changed();
99 
104  virtual void on_value_changed();
105 
106  private:
107  xtd::ustring display_name_;
108  xtd::ustring description_;
109  std::map<xtd::ustring, xtd::ustring> attributes_;
110  int32_t switch_setting_ = 0;
111  xtd::ustring value_;
112  };
113  }
114 }
const xtd::ustring & description() const
Gets a description of the switch.
virtual void on_switch_setting_changed()
Invoked when the switch_setting property is changed.
const xtd::ustring & display_name() const
Gets a name used to identify the switch.
virtual void on_value_changed()
Invoked when the value property is changed.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
virtual std::vector< xtd::ustring > get_supported_attributes() const
Gets the custom attributes supported by the switch.
Contains xtd::diagnostics::source_levels enum class.
const xtd::ustring & value() const
Gets the value of the switch.
int32_t switch_setting() const
Gets the current setting for this switch.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
Provides an abstract base class to create new debugging and tracing switches.
Definition: switch_base.h:26
const std::map< xtd::ustring, xtd::ustring > & attributes() const
Gets the custom switch attributes nA StringDictionary containing the case-insensitive custom attribu...
switch_base(const xtd::ustring &display_name, const xtd::ustring &description)
Initializes a new instance of the switch_base class.