libzypp  17.35.11
context.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 #ifndef ZYPP_NG_CONTEXT_INCLUDED
10 #define ZYPP_NG_CONTEXT_INCLUDED
11 
12 #include <zypp-core/zyppng/async/AsyncOp>
13 #include <zypp-core/zyppng/ui/UserInterface>
14 #include <zypp/RepoManager.h>
15 #include <zypp/ResPool.h>
16 
17 namespace zypp {
19  class ZConfig;
20 }
21 
22 namespace zyppng {
23 
25  ZYPP_FWD_DECL_TYPE_WITH_REFS( ProgressObserver );
27 
29  using KeyRingRef = zypp::KeyRing_Ptr;
30 
31  class ContextPrivate;
32 
33 
38  class Context : public UserInterface
39  {
42 
43  public:
44 
46 
48 
49  template <typename AsyncRes>
51  if ( op->isReady () )
52  return;
53  return executeImpl( op );
54  }
55 
56  ProvideRef provider() const;
57  KeyRingRef keyRing () const;
59 
64 
70 
75 
76  private:
77  void executeImpl ( const AsyncOpBaseRef& op );
78  };
79 
80  template<typename T>
81  auto joinPipeline( ContextRef ctx, AsyncOpRef<T> res ) {
82  if constexpr ( detail::is_async_op_v<decltype(res)> ) {
83  ctx->execute(res);
84  return res->get();
85  } else {
86  return res;
87  }
88  }
89 
90 }
91 
92 
93 #endif
ZYPP_DECL_PRIVATE_CONSTR(Context)
zypp::KeyRing KeyRing
Definition: context.h:28
zypp::ZConfig & config()
Definition: context.cc:43
void execute(AsyncOpRef< AsyncRes > op)
Definition: context.h:50
Gpg key handling.
Definition: KeyRing.h:186
ProvideRef provider() const
Definition: context.cc:32
KeyRingRef keyRing() const
Definition: context.cc:38
#define ZYPP_ADD_CREATE_FUNC(Class)
Definition: zyppglobal.h:205
ResPool::instance().proxy();.
Definition: ResPoolProxy.h:35
zypp::KeyRing_Ptr KeyRingRef
Definition: context.h:29
ZYPP_FWD_DECL_TYPE_WITH_REFS(Context)
auto joinPipeline(ContextRef ctx, AsyncOpRef< T > res)
Definition: context.h:81
DEFINE_PTR_TYPE(Application)
zypp::ResPool pool()
Access to the resolvable pool.
Definition: context.cc:48
Interim helper class to collect global options and settings.
Definition: ZConfig.h:68
zypp::sat::Pool satPool()
Access to the sat pool.
Definition: context.cc:58
constexpr bool is_async_op_v
Definition: asyncop.h:61
std::shared_ptr< AsyncOp< T > > AsyncOpRef
Definition: asyncop.h:255
Global ResObject pool.
Definition: ResPool.h:61
void executeImpl(const AsyncOpBaseRef &op)
Definition: context.cc:63
#define ZYPP_DECLARE_PRIVATE(Class)
Definition: zyppglobal.h:87
Global sat-pool.
Definition: Pool.h:46
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
zypp::ResPoolProxy poolProxy()
Pool of ui::Selectable.
Definition: context.cc:53