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() );
162 if constexpr ( std::is_base_of_v<detail::IBasicPoolComponent, T> )
163 _basicComponents.push_back( static_cast<detail::IBasicPoolComponent*>( genericComp ) );
166 if constexpr ( std::is_base_of_v<IPoolComponent, T> ) {
167 auto iComp =
static_cast<IPoolComponent*
>( genericComp );
168 _initComponents[
static_cast<size_t>( iComp->stage() )].push_back( iComp );
173 if constexpr ( std::is_base_of_v<IPreparedPoolComponent, T> ) {
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 );
236 virtual void *
get() = 0;
243 template <
typename T>
258 void *
get()
override {
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;
ID-indexed metadata stores.
virtual void onInvalidate(Pool &, PoolInvalidation)
React to pool invalidation — clear internal caches.
virtual ~TypeErasure()=default
virtual int priority() const
Fine-grained ordering within a stage.
virtual void onReset(Pool &)
void notifyCheckDirty(Pool &pool)
Pass 1 of prepare(): probe external state.
std::vector< detail::IBasicPoolComponent * > _basicComponents
Unified list for checkDirty / onInvalidate / onRepoAdded / onRepoRemoved.
std::type_index typeIndex() const
PoolComponentSet()=default
PreparedStage
Execution stages for IPreparedPoolComponent (post-index phase).
virtual PreparedStage stage() const
std::array< std::vector< IPoolComponent * >, static_cast< size_t >InitStage::COUNT)> _initComponents
Pre-index components — stage-bucketed, priority-sorted within bucket.
const T * findComponent() const
std::array< bool, static_cast< size_t >PreparedStage::COUNT)> _preparedDirtyBuckets
Orchestrator for a libsolv pool instance.
virtual void attach(Pool &)
Interface for components that run AFTER the whatprovides index is built.
void sortPreparedBuckets()
TypeErasure & operator=(const TypeErasure &)=delete
IBasicPoolComponent()=default
void notifyRepoAdded(Pool &pool, detail::RepoIdType id)
A move-only, non-owning view of a Pool that guarantees the whatprovides index is valid.
virtual void onRepoRemoved(Pool &, RepoIdType)
Shared base for IPoolComponent and IPreparedPoolComponent.
Arches, Locales, Namespace Callbacks (The Foundation)
PoolComponentSet & operator=(const PoolComponentSet &)=delete
Interface for components that run BEFORE the whatprovides index is built.
Registry and dispatcher for all pool components.
This file contains private API, this might break at any time between releases.
virtual void checkDirty(Pool &)
Probe external state.
void notifyRepoRemoved(Pool &pool, detail::RepoIdType id)
Blacklists, Reboot Specs, Storage Policy.
void notifyReset(Pool &pool)
virtual int priority() const
Fine-grained ordering within a stage.
virtual void prepare(PreparedPool &)
virtual void onRepoAdded(Pool &, RepoIdType)
CompContainer & operator=(const CompContainer &)=delete
~CompContainer() override=default
virtual void prepare(Pool &)
std::unique_ptr< T > _ptr
PoolInvalidation
Defines the scope of an invalidation request for the Pool.
virtual InitStage stage() const
void notifyInvalidate(Pool &pool, PoolInvalidation invalidation)
std::array< bool, static_cast< size_t >InitStage::COUNT)> _initDirtyBuckets
T & assertComponent(std::unique_ptr< T > &&compPtr={})
CompContainer(std::unique_ptr< T > component)
void notifyPrepare(Pool &pool)
Pass 2 of prepare(): pre-index component work (stage/priority order).
IBasicPoolComponent & operator=(const IBasicPoolComponent &)=delete
virtual ~IBasicPoolComponent()=default
void notifyPrepareWithIndex(PreparedPool &pp)
Pass 3 of prepare(): post-index component work (stage/priority order).
std::array< std::vector< IPreparedPoolComponent * >, static_cast< size_t >PreparedStage::COUNT)> _preparedComponents
Post-index components — stage-bucketed, priority-sorted within bucket.
InitStage
Execution stages for IPoolComponent (pre-index phase).
zypp::sat::detail::RepoIdType RepoIdType
std::unordered_map< std::type_index, std::unique_ptr< TypeErasure > > _components
virtual void attach(Pool &)