14#ifndef ZYPP_NG_SAT_COMPONENTS_POOLCOMPONENTS_H_INCLUDED
15#define ZYPP_NG_SAT_COMPONENTS_POOLCOMPONENTS_H_INCLUDED
20#include <unordered_map>
146 template <
typename T>
149 std::type_index idx(
typeid(T) );
151 return *
static_cast<T*
>(
_components[idx]->get() );
153 auto ptr = std::move(compPtr);
155 ptr = std::make_unique<T>();
157 std::unique_ptr<TypeErasure> component = std::make_unique<CompContainer<T>>( std::move(ptr) );
158 auto iter =
_components.insert( { std::move(idx), std::move(component) } );
159 auto genericComp =
static_cast<T *
>( iter.first->second->get() );
163 _basicComponents.push_back(
static_cast<detail::IBasicPoolComponent*
>( genericComp ) );
167 auto iComp =
static_cast<IPoolComponent*
>( genericComp );
168 _initComponents[
static_cast<size_t>( iComp->stage() )].push_back( iComp );
174 auto iComp =
static_cast<IPreparedPoolComponent*
>( genericComp );
182 template <
typename T>
184 const std::type_index idx(
typeid(T) );
186 return static_cast<T*
>(
_components.at(idx)->get() );
193 comp->checkDirty(
pool );
200 for (
auto *comp : bucket )
201 comp->prepare(
pool );
208 for (
auto *comp : bucket )
214 comp->onInvalidate(
pool, invalidation );
219 comp->onRepoAdded(
pool,
id );
224 comp->onRepoRemoved(
pool,
id );
229 comp->onReset(
pool );
243 template <
typename T>
268 std::stable_sort( bucket.begin(), bucket.end(), [](
const auto &
a,
const auto &
b ) {
269 return a->priority() < b->priority();
280 std::stable_sort( bucket.begin(), bucket.end(), [](
const auto &
a,
const auto &
b ) {
281 return a->priority() < b->priority();
288 std::unordered_map<std::type_index, std::unique_ptr<TypeErasure>>
_components;
Interface for components that run BEFORE the whatprovides index is built.
virtual InitStage stage() const
virtual void prepare(Pool &)
virtual void attach(Pool &)
virtual int priority() const
Fine-grained ordering within a stage.
Interface for components that run AFTER the whatprovides index is built.
virtual PreparedStage stage() const
virtual void attach(Pool &)
virtual int priority() const
Fine-grained ordering within a stage.
virtual void prepare(PreparedPool &)
std::unordered_map< std::type_index, std::unique_ptr< TypeErasure > > _components
void notifyRepoAdded(Pool &pool, detail::RepoIdType id)
void notifyPrepareWithIndex(PreparedPool &pp)
Pass 3 of prepare(): post-index component work (stage/priority order).
void notifyPrepare(Pool &pool)
Pass 2 of prepare(): pre-index component work (stage/priority order).
void sortPreparedBuckets()
T & assertComponent(std::unique_ptr< T > &&compPtr={})
const T * findComponent() const
std::array< bool, static_cast< size_t >(PreparedStage::COUNT)> _preparedDirtyBuckets
PoolComponentSet(PoolComponentSet &&)=default
std::array< std::vector< IPoolComponent * >, static_cast< size_t >(InitStage::COUNT)> _initComponents
Pre-index components — stage-bucketed, priority-sorted within bucket.
void notifyReset(Pool &pool)
PoolComponentSet & operator=(PoolComponentSet &&)=default
void notifyInvalidate(Pool &pool, PoolInvalidation invalidation)
void notifyCheckDirty(Pool &pool)
Pass 1 of prepare(): probe external state.
std::array< bool, static_cast< size_t >(InitStage::COUNT)> _initDirtyBuckets
void notifyRepoRemoved(Pool &pool, detail::RepoIdType id)
std::array< std::vector< IPreparedPoolComponent * >, static_cast< size_t >(PreparedStage::COUNT)> _preparedComponents
Post-index components — stage-bucketed, priority-sorted within bucket.
std::vector< detail::IBasicPoolComponent * > _basicComponents
Unified list for checkDirty / onInvalidate / onRepoAdded / onRepoRemoved.
PoolComponentSet & operator=(const PoolComponentSet &)=delete
PoolComponentSet()=default
PoolComponentSet(const PoolComponentSet &)=delete
Orchestrator for a libsolv pool instance.
A move-only, non-owning view of a Pool that guarantees the whatprovides index is valid.
Shared base for IPoolComponent and IPreparedPoolComponent.
IBasicPoolComponent()=default
IBasicPoolComponent(const IBasicPoolComponent &)=delete
virtual void onRepoRemoved(Pool &, RepoIdType)
IBasicPoolComponent(IBasicPoolComponent &&)=delete
IBasicPoolComponent & operator=(IBasicPoolComponent &&)=delete
IBasicPoolComponent & operator=(const IBasicPoolComponent &)=delete
virtual void checkDirty(Pool &)
Probe external state.
virtual ~IBasicPoolComponent()=default
virtual void onInvalidate(Pool &, PoolInvalidation)
React to pool invalidation — clear internal caches.
virtual void onReset(Pool &)
virtual void onRepoAdded(Pool &, RepoIdType)
constexpr bool is_base_of_v
zypp::sat::detail::RepoIdType RepoIdType
This file contains private API, this might break at any time between releases.
PreparedStage
Execution stages for IPreparedPoolComponent (post-index phase).
@ Policy
Blacklists, Reboot Specs, Storage Policy.
@ Logging
Diagnostic components.
@ Metadata
ID-indexed metadata stores.
InitStage
Execution stages for IPoolComponent (pre-index phase).
@ Environment
Arches, Locales, Namespace Callbacks (The Foundation).
PoolInvalidation
Defines the scope of an invalidation request for the Pool.
CompContainer(const CompContainer &)=delete
std::type_index typeIndex() const
~CompContainer() override=default
CompContainer(std::unique_ptr< T > component)
CompContainer(CompContainer &&)=delete
std::unique_ptr< T > _ptr
CompContainer & operator=(CompContainer &&)=delete
CompContainer & operator=(const CompContainer &)=delete
TypeErasure(TypeErasure &&)=delete
TypeErasure & operator=(const TypeErasure &)=delete
TypeErasure & operator=(TypeErasure &&)=delete
virtual ~TypeErasure()=default
TypeErasure(const TypeErasure &)=delete