libzypp  17.31.31
attachedmediainfo_p.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_MEDIA_PRIVATE_ATTACHEDMEDIAINFO_P_H_INCLUDED
15 #define ZYPP_MEDIA_PRIVATE_ATTACHEDMEDIAINFO_P_H_INCLUDED
16 
17 #include "providefwd_p.h"
18 #include "providequeue_p.h"
19 #include <zypp-media/ng/ProvideSpec>
20 #include <string>
21 #include <chrono>
22 
23 namespace zyppng {
24 
25  class ProvidePrivate;
26 
28 
29  public:
30  void ref() {
31  if ( _refCount == 0 )
32  _idleSince = std::chrono::steady_clock::time_point::max();
33 
34  _refCount++;
35  }
36  void unref() {
37  if ( _refCount > 0 ) {
38  _refCount--;
39 
40  if ( _refCount == 0 )
41  _idleSince = std::chrono::steady_clock::now();
42  }
43  }
44 
48  bool isSameMedium ( const std::vector<zypp::Url> &urls, const ProvideMediaSpec &spec ) {
49 
50  const auto check = _spec.isSameMedium(spec);
51  if ( !zypp::indeterminate (check) )
52  return (bool)check;
53 
54  // let the URL rule
55  return ( std::find( urls.begin(), urls.end(), _attachedUrl ) != urls.end() );
56  }
57 
58  std::string _name;
59  ProvideQueueWeakRef _backingQueue; //< if initialized contains a weak reference to the queue that owns this medium
60  ProvideQueue::Config::WorkerType _workerType;
61  zypp::Url _attachedUrl; // the URL that was used for the attach request
63  uint _refCount = 0;
64  std::chrono::steady_clock::time_point _idleSince = std::chrono::steady_clock::time_point::max();
65  };
66 
67 }
68 
69 #endif
bool isSameMedium(const std::vector< zypp::Url > &urls, const ProvideMediaSpec &spec)
std::chrono::steady_clock::time_point _idleSince
zypp::TriBool isSameMedium(const ProvideMediaSpec &other)
Definition: providespec.cc:140
ProvideQueueWeakRef _backingQueue
ProvideQueue::Config::WorkerType _workerType
bool check(const std::string &sequenceinfo_r, bool quick_r)
Check via sequence info.
Url manipulation class.
Definition: Url.h:91