libzypp  13.10.6
InstanceId.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_INSTANCEID_H
13 #define ZYPP_INSTANCEID_H
14 
15 #include <string>
16 
17 #include "zypp/PoolItem.h"
18 
20 namespace zypp
21 {
22 
24  //
25  // CLASS NAME : InstanceId
26  //
46  class InstanceId
47  {
48  public:
51  {}
52 
54  InstanceId( const std::string & namespace_r )
55  : _namespace( namespace_r )
56  {}
57 
58  public:
60  std::string getIdFor( sat::Solvable slv_r ) const;
62  std::string getIdFor( const PoolItem & pi_r ) const
63  { return getIdFor( pi_r.satSolvable() ); }
64 
66  sat::Solvable findSolvable( const std::string str_r ) const
67  { return findPoolItem( str_r ).satSolvable(); }
69  PoolItem findPoolItem( const std::string str_r ) const;
70 
71  public:
73  std::string operator()( sat::Solvable slv_r ) const
74  { return getIdFor( slv_r ); }
75 
77  std::string operator()( const PoolItem & pi_r ) const
78  { return getIdFor( pi_r ); }
79 
81  PoolItem operator()( const std::string str_r ) const
82  { return findPoolItem( str_r ); }
83 
86  bool isSystemId( const std::string str_r ) const;
87 
88  public:
90  const std::string & getNamespace() const
91  { return _namespace; }
92 
94  void setNamespace( const std::string & namespace_r )
95  { _namespace = namespace_r; }
96 
99  { _namespace.clear(); }
100 
101  private:
102  std::string _namespace;
103  };
105 
107 } // namespace zypp
109 #endif // ZYPP_INSTANCEID_H
Build string to identify/retrieve a specific Solvable.
Definition: InstanceId.h:46
PoolItem operator()(const std::string str_r) const
InstanceId string to PoolItem.
Definition: InstanceId.h:81
A Solvable object within the sat Pool.
Definition: Solvable.h:55
InstanceId(const std::string &namespace_r)
Ctor taking namespace.
Definition: InstanceId.h:54
PoolItem findPoolItem(const std::string str_r) const
InstanceId string to PoolItem.
Definition: InstanceId.cc:49
InstanceId()
Default ctor empty empty namespace.
Definition: InstanceId.h:50
std::string operator()(const PoolItem &pi_r) const
PoolItem to InstanceId string.
Definition: InstanceId.h:77
std::string operator()(sat::Solvable slv_r) const
Solvable to InstanceId string.
Definition: InstanceId.h:73
bool isSystemId(const std::string str_r) const
Quick test whether the InstanceId string would refer to a system (installed) Solvable.
Definition: InstanceId.cc:109
void setNamespace(const std::string &namespace_r)
Set a new namespace.
Definition: InstanceId.h:94
void unsetNamespace()
Set no (empty) namespace.
Definition: InstanceId.h:98
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: PoolItem.h:114
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
std::string _namespace
Definition: InstanceId.h:102
std::string getIdFor(const PoolItem &pi_r) const
PoolItem to InstanceId string.
Definition: InstanceId.h:62
const std::string & getNamespace() const
The namespace in use.
Definition: InstanceId.h:90
sat::Solvable findSolvable(const std::string str_r) const
InstanceId string to Solvable.
Definition: InstanceId.h:66
std::string getIdFor(sat::Solvable slv_r) const
Solvable to InstanceId string.
Definition: InstanceId.cc:25