userver: components::ComponentContext Class Reference
Loading...
Searching...
No Matches
components::ComponentContext Class Referencefinal

#include <userver/components/component_context.hpp>

Detailed Description

Public Member Functions

template<typename T >
T & FindComponent () const
 Finds a component of type T with specified name (if any) and returns the component after it was initialized.
 
template<typename T >
T & FindComponent (std::string_view name) const
 
template<typename T >
T & FindComponent (std::string_view={})
 
template<typename T >
T * FindComponentOptional () const
 If there's no component with specified type and name return nullptr; otherwise behaves as FindComponent().
 
template<typename T >
T * FindComponentOptional (std::string_view name) const
 
template<typename T >
T & FindComponentOptional (std::string_view={})
 
engine::TaskProcessor & GetTaskProcessor (const std::string &name) const
 Returns an engine::TaskProcessor with the specified name.
 
template<typename T >
engine::TaskProcessor & GetTaskProcessor (const T &)
 
const Manager & GetManager () const
 

Member Function Documentation

◆ FindComponent() [1/3]

template<typename T >
T & components::ComponentContext::FindComponent ( ) const
inline

Finds a component of type T with specified name (if any) and returns the component after it was initialized.

Can only be called from other component's constructor in a task where that constructor was called. May block and asynchronously wait for the creation of the requested component.

Exceptions
ComponentsLoadCancelledExceptionif components loading was cancelled due to errors in the creation of other component.
std::runtime_errorif component missing in component_list was requested.
Examples
components/component_sample_test.cpp, postgresql/functional_tests/basic_chaos/postgres_service.cpp, samples/grpc_service/grpc_service.cpp, samples/mongo_service/mongo_service.cpp, and samples/testsuite-support/src/metrics.cpp.

Definition at line 87 of file component_context.hpp.

◆ FindComponent() [2/3]

template<typename T >
T & components::ComponentContext::FindComponent ( std::string_view name) const
inline

Definition at line 93 of file component_context.hpp.

◆ FindComponent() [3/3]

template<typename T >
T & components::ComponentContext::FindComponent ( std::string_view = {})
inline

Definition at line 109 of file component_context.hpp.

◆ FindComponentOptional() [1/3]

template<typename T >
T * components::ComponentContext::FindComponentOptional ( ) const
inline

If there's no component with specified type and name return nullptr; otherwise behaves as FindComponent().

Definition at line 116 of file component_context.hpp.

◆ FindComponentOptional() [2/3]

template<typename T >
T * components::ComponentContext::FindComponentOptional ( std::string_view name) const
inline

Definition at line 122 of file component_context.hpp.

◆ FindComponentOptional() [3/3]

template<typename T >
T & components::ComponentContext::FindComponentOptional ( std::string_view = {})
inline

Definition at line 130 of file component_context.hpp.

◆ GetTaskProcessor()

template<typename T >
engine::TaskProcessor & components::ComponentContext::GetTaskProcessor ( const T & )
inline

Definition at line 138 of file component_context.hpp.

Friends And Related Symbol Documentation

◆ Manager

friend class Manager
friend

Definition at line 164 of file component_context.hpp.

◆ State

friend class State
friend

Definition at line 165 of file component_context.hpp.


The documentation for this class was generated from the following file: