libzypp  17.38.7
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 
19 #include <zypp/ng/locale.h>
20 #include <zypp/ng/idstring.h>
21 
22 #include <memory>
23 
24 namespace zyppng::sat::namespaces {
25 
31  public:
32 
33  LanguageNamespaceProvider() = default;
34  bool isSatisfied( detail::IdType value ) const override;
35 
39  void initRequestedLocales( const LocaleSet & locales_r );
40 
43  { return _requestedLocalesTracker.added(); }
44 
47  { return _requestedLocalesTracker.removed(); }
48 
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
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition: language.h:87
Provider for NAMESPACE_LANGUAGE.
Definition: language.h:30
bool isRequestedLocale(const Locale &locale_r) const
Definition: language.h:53
Only external requirements/context changed (e.g., Locales).
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:29
Orchestrator for a libsolv pool instance.
Definition: pool.h:36
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition: language.cc:28
const LocaleSet & getRequestedLocales() const
Current set of requested Locales.
Definition: language.h:50
std::unique_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition: language.h:88
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition: language.cc:68
zypp::sat::detail::IdType IdType
Definition: poolconstants.h:43
bool isAvailableLocale(const Locale &locale_r) const
Definition: language.h:68
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:50
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: language.cc:46
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
Definition: language.h:46
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
Definition: language.h:42
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition: language.cc:57
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition: language.h:75
bool isSatisfied(detail::IdType value) const override
Check if a specific value satisfies this namespace condition.
Definition: language.cc:22
Abstract base class for logic providing data to a libsolv namespace.
void notifyDirty(PoolInvalidation invalidationLevel, std::initializer_list< std::string_view > reasons)
Notify the attached registry/pool that data has changed.
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition: language.cc:142
void localeSetDirty(std::initializer_list< std::string_view > reasons)
Definition: language.h:82
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition: language.cc:37
std::unique_ptr< LocaleSet > _availableLocalesPtr
Definition: language.h:89