userver: userver/components/container.hpp File Reference
Loading...
Searching...
No Matches
container.hpp File Reference

Detailed Description

A simple Component that creates, hold, and distributes an object of user type T. The component has a name equal to the constexpr std::string_view result of user-defined ContainerName(Of<T>{}).

Definition in file container.hpp.

Go to the source code of this file.

#include <concepts>
#include <string_view>
#include <type_traits>
#include <utility>
#include <userver/components/component_base.hpp>
#include <userver/components/component_config.hpp>
#include <userver/components/component_context.hpp>
#include <userver/formats/common/meta.hpp>
#include <userver/yaml_config/merge_schemas.hpp>

Classes

struct  components::Of< T >
class  components::Container< T >
 A simple Component that creates, hold, and distributes an object of user type T. The component has a name equal to the constexpr std::string_view result of user-defined ContainerName(Of<T>{}). More...

Namespaces

namespace  components
 Contains functions and types to start a userver based service/tool.

Functions

template<typename T>
requires (formats::common::impl::HasParse<yaml_config::YamlConfig, T> && std::is_class_v<T>)
components::LocateDependency (WithType< T >, const ComponentConfig &config, const ComponentContext &)
 A function that extracts an in-component-stored data (probably, reference) of type T, T&, or const T& from components::ComponentContext.
template<typename T>
requires impl::ContainerHasName<T>
T & components::LocateDependency (WithType< T >, const ComponentConfig &, const ComponentContext &context)
template<typename T>
requires std::derived_from<T, RawComponentBase>
T & components::LocateDependency (WithType< T >, const ComponentConfig &, const ComponentContext &context)