libzypp: zypp/ng/sat/namespaces/language.h Source File

libzypp 17.38.14

language.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14#ifndef ZYPP_NG_SAT_NAMESPACES_LANGUAGE_H_INCLUDED
15#define ZYPP_NG_SAT_NAMESPACES_LANGUAGE_H_INCLUDED
16
17#include <zypp/ng/base/settracker.h>
18#include <zypp/ng/sat/namespaces/namespaceprovider.h>
19#include <zypp/ng/locale.h>
20#include <zypp/ng/idstring.h>
21
22#include <memory>
23
24namespace zyppng::sat::namespaces {
25
30 class LanguageNamespaceProvider : public NamespaceProvider {
31 public:
32
33 LanguageNamespaceProvider() = default;
34 bool isSatisfied( detail::IdType value ) const override;
35
39 void initRequestedLocales( const LocaleSet & locales_r );
40
42 const LocaleSet & getAddedRequestedLocales() const
43 { return _requestedLocalesTracker.added(); }
44
46 const LocaleSet & getRemovedRequestedLocales() const
47 { return _requestedLocalesTracker.removed(); }
48
50 const LocaleSet & getRequestedLocales() const
51 { return _requestedLocalesTracker.current(); }
52
53 bool isRequestedLocale( const Locale & locale_r ) const
54 { return _requestedLocalesTracker.contains( locale_r ); }
55
57 void setRequestedLocales( const LocaleSet & locales_r );
59 bool addRequestedLocale( const Locale & locale_r );
61 bool eraseRequestedLocale( const Locale & locale_r );
62
64 const LocaleSet & getAvailableLocales() const;
65
66 void onReset( Pool & pool ) override;
67
68 bool isAvailableLocale( const Locale & locale_r ) const
69 {
70 const LocaleSet & avl( getAvailableLocales() );
71 LocaleSet::const_iterator it( avl.find( locale_r ) );
72 return it != avl.end();
73 }
74
75 using TrackedLocaleIds = base::SetTracker<IdStringSet> ;
76
78 const TrackedLocaleIds & trackedLocaleIds() const;
79
80 private:
81
82 void localeSetDirty( std::initializer_list<std::string_view> reasons ) {
83 _trackedLocaleIdsPtr.reset(); // requested locales changed
84 notifyDirty( PoolInvalidation::Dependency, std::move(reasons) ); // invalidate dependency/namespace related indices
85 }
86
87 base::SetTracker<LocaleSet> _requestedLocalesTracker;
88 mutable std::unique_ptr<TrackedLocaleIds> _trackedLocaleIdsPtr; // mutable because of lazy init
89 mutable std::unique_ptr<LocaleSet> _availableLocalesPtr; // mutable because of lazy init
90
91 };
92
93}
94
95#endif
zypp::Locale
'Language[_Country]' codes.
Definition Locale.h:51
zyppng::sat::NamespaceProvider
Abstract base class for logic providing data to a libsolv namespace.
Definition namespaceprovider.h:35
zyppng::sat::NamespaceProvider::notifyDirty
void notifyDirty(PoolInvalidation invalidationLevel, std::initializer_list< std::string_view > reasons)
Notify the attached registry/pool that data has changed.
Definition namespaceprovider.cc:26
zyppng::sat::Pool
Orchestrator for a libsolv pool instance.
Definition pool.h:37
zyppng::sat::namespaces::LanguageNamespaceProvider::initRequestedLocales
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition language.cc:28
zyppng::sat::namespaces::LanguageNamespaceProvider::setRequestedLocales
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition language.cc:37
zyppng::sat::namespaces::LanguageNamespaceProvider::isSatisfied
bool isSatisfied(detail::IdType value) const override
Check if a specific value satisfies this namespace condition.
Definition language.cc:22
zyppng::sat::namespaces::LanguageNamespaceProvider::getRequestedLocales
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition language.h:50
zyppng::sat::namespaces::LanguageNamespaceProvider::LanguageNamespaceProvider
LanguageNamespaceProvider()=default
zyppng::sat::namespaces::LanguageNamespaceProvider::_availableLocalesPtr
std::unique_ptr< LocaleSet > _availableLocalesPtr
Definition language.h:89
zyppng::sat::namespaces::LanguageNamespaceProvider::onReset
void onReset(Pool &pool) override
Definition language.cc:137
zyppng::sat::namespaces::LanguageNamespaceProvider::_requestedLocalesTracker
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition language.h:87
zyppng::sat::namespaces::LanguageNamespaceProvider::localeSetDirty
void localeSetDirty(std::initializer_list< std::string_view > reasons)
Definition language.h:82
zyppng::sat::namespaces::LanguageNamespaceProvider::addRequestedLocale
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition language.cc:46
zyppng::sat::namespaces::LanguageNamespaceProvider::getAddedRequestedLocales
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition language.h:42
zyppng::sat::namespaces::LanguageNamespaceProvider::getRemovedRequestedLocales
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition language.h:46
zyppng::sat::namespaces::LanguageNamespaceProvider::_trackedLocaleIdsPtr
std::unique_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition language.h:88
zyppng::sat::namespaces::LanguageNamespaceProvider::getAvailableLocales
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition language.cc:142
zyppng::sat::namespaces::LanguageNamespaceProvider::isAvailableLocale
bool isAvailableLocale(const Locale &locale_r) const
Definition language.h:68
zyppng::sat::namespaces::LanguageNamespaceProvider::trackedLocaleIds
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition language.cc:68
zyppng::sat::namespaces::LanguageNamespaceProvider::eraseRequestedLocale
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition language.cc:57
zyppng::sat::namespaces::LanguageNamespaceProvider::isRequestedLocale
bool isRequestedLocale(const Locale &locale_r) const
Definition language.h:53
zyppng::sat::namespaces::LanguageNamespaceProvider::TrackedLocaleIds
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition language.h:75
locale.h
namespaceprovider.h
zypp::pool
Definition ByIdent.h:24
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
zyppng::sat::detail::IdType
zypp::sat::detail::IdType IdType
Definition poolconstants.h:43
zyppng::sat::namespaces
Definition filesystem.cc:18
zyppng::sat::PoolInvalidation::Dependency
@ Dependency
Only external requirements/context changed (e.g., Locales).
Definition poolconstants.h:71
settracker.h
zypp::base::SetTracker
Track added/removed set items based on an initial set.
Definition SetTracker.h:39
idstring.h