libzypp: zypp/ng/sat/components/namespacecomponent.cc Source File

libzypp 17.38.14

namespacecomponent.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9#include "namespacecomponent.h"
10#include <zypp/ng/sat/namespaces/namespaceprovider.h>
11#include <zypp/ng/sat/pool.h>
12
13#include <zypp/ng/idstring.h>
14#include <algorithm>
15
16namespace zyppng::sat {
17
18 void NamespaceComponent::registerProvider( detail::IdType namespaceId, std::shared_ptr<NamespaceProvider> provider )
19 {
20 _providers.insert_or_assign ( namespaceId, provider );
21 }
22
23 bool NamespaceComponent::handleNamespace( detail::IdType namespaceId, detail::IdType value ) const
24 {
25 auto iter = _providers.find( namespaceId );
26 if ( iter != _providers.end() )
27 return iter->second->isSatisfied ( value );
28 return false;
29 }
30
31 void NamespaceComponent::attach(Pool &pool)
32 {
33 pool.get()->nscallback = &NamespaceComponent::libsolv_callback;
34 pool.get()->nscallbackdata = this;
35 for ( auto & p : _providers ) {
36 p.second->attach(pool);
37 }
38 }
39
40 void NamespaceComponent::checkDirty( Pool & pool )
41 {
42 for ( auto & provider : _providers )
43 provider.second->checkDirty( pool );
44 }
45
46 void NamespaceComponent::prepare( Pool & pool )
47 {
48 for ( auto & provider : _providers )
49 provider.second->prepare( pool );
50 }
51
52 void NamespaceComponent::onReset( Pool & pool )
53 {
54 for ( auto & p : _providers )
55 p.second->onReset( pool );
56 }
57
58 detail::IdType NamespaceComponent::libsolv_callback(detail::CPool *, void *data, detail::IdType lhs, detail::IdType rhs)
59 {
60 auto self = static_cast<NamespaceComponent*>(data);
61 if ( self && self->handleNamespace( lhs, rhs ) )
62 return 1; // RET_systemProperty
63
64 return 0; // RET_unsupported
65 }
66
67} // namespace zyppng::sat
zyppng::sat::NamespaceComponent
Mediator managing the collection of NamespaceProviders for a Pool.
Definition namespacecomponent.h:37
zyppng::sat::NamespaceComponent::handleNamespace
bool handleNamespace(detail::IdType namespaceId, detail::IdType value) const
The entry point for the libsolv namespace callback.
Definition namespacecomponent.cc:23
zyppng::sat::NamespaceComponent::libsolv_callback
static detail::IdType libsolv_callback(detail::CPool *, void *data, detail::IdType lhs, detail::IdType rhs)
The static C-style callback for libsolv.
Definition namespacecomponent.cc:58
zyppng::sat::NamespaceComponent::checkDirty
void checkDirty(Pool &pool) override
Probe external state.
Definition namespacecomponent.cc:40
zyppng::sat::NamespaceComponent::_providers
std::unordered_map< detail::IdType, std::shared_ptr< NamespaceProvider > > _providers
Internal map of IDs to their respective providers.
Definition namespacecomponent.h:73
zyppng::sat::NamespaceComponent::prepare
void prepare(Pool &pool) override
Definition namespacecomponent.cc:46
zyppng::sat::NamespaceComponent::onReset
void onReset(Pool &pool) override
Definition namespacecomponent.cc:52
zyppng::sat::NamespaceComponent::attach
void attach(Pool &pool) override
Definition namespacecomponent.cc:31
zyppng::sat::NamespaceComponent::registerProvider
void registerProvider(detail::IdType namespaceId, std::shared_ptr< NamespaceProvider > provider)
Register a provider for a specific namespace.
Definition namespacecomponent.cc:18
zyppng::sat::Pool
Orchestrator for a libsolv pool instance.
Definition pool.h:37
namespacecomponent.h
namespaceprovider.h
zypp::pool
Definition ByIdent.h:24
zyppng::sat::detail::CPool
zypp::sat::detail::CPool CPool
Definition poolconstants.h:36
zyppng::sat::detail::IdType
zypp::sat::detail::IdType IdType
Definition poolconstants.h:43
zyppng::sat
This file contains private API, this might break at any time between releases.
Definition capabilities.h:22
pool.h
idstring.h