userver: userver/components/component_config.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
component_config.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @brief @copybrief components::ComponentConfig
5
6#include <cstdint>
7#include <string>
8#include <unordered_map>
9
10#include <userver/yaml_config/yaml_config.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace components {
15
16/// @brief Represents the config of a component that is being constructed;
17/// see @ref scripts/docs/en/userver/component_system.md for introduction into components.
18class ComponentConfig final : public yaml_config::YamlConfig {
19public:
20 /// Creates an empty config
21 explicit ComponentConfig(std::string name);
22
23 ComponentConfig(yaml_config::YamlConfig value);
24
25 /// Name of the current component
26 const std::string& Name() const;
27
28 void SetName(std::string name);
29
30private:
31 std::string name_;
32};
33
34ComponentConfig Parse(const yaml_config::YamlConfig& value, formats::parse::To<ComponentConfig>);
35
36using ComponentConfigMap = std::unordered_map<std::string, const ComponentConfig&>;
37
38} // namespace components
39
40USERVER_NAMESPACE_END