libzypp  11.13.5
ResTraits.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESTRAITS_H
13 #define ZYPP_RESTRAITS_H
14 
15 #include "zypp/base/PtrTypes.h"
16 #include "zypp/ResKind.h"
17 
19 namespace zypp
20 {
21 
23  namespace traits
24  {
25 
28  inline bool isPseudoInstalled( ResKind kind_r )
29  { return( kind_r == ResKind::patch || kind_r == ResKind::pattern ); }
30 
32  } // namespace traits
34 
62  DEFINE_PTR_TYPE( Resolvable );
63  DEFINE_PTR_TYPE( ResObject );
64 
65  DEFINE_PTR_TYPE( Package );
66  DEFINE_PTR_TYPE( SrcPackage );
67  DEFINE_PTR_TYPE( Pattern );
68  DEFINE_PTR_TYPE( Product );
69  DEFINE_PTR_TYPE( Patch );
71 
73  class PoolItem;
74 
76  template<typename _Res>
77  struct ResTraits
78  {
79  typedef ResKind KindType;
80  typedef intrusive_ptr<_Res> PtrType;
81  typedef intrusive_ptr<const _Res> constPtrType;
82 
83  static const ResKind kind;
84 
87  static bool isPseudoInstalled() { return traits::isPseudoInstalled( kind ); }
88  };
89 
93  template<>
95  {
96  typedef ResKind KindType;
97  typedef intrusive_ptr<Resolvable> PtrType;
98  typedef intrusive_ptr<const Resolvable> constPtrType;
99  };
100 
104  template<>
106  {
107  typedef ResKind KindType;
108  typedef intrusive_ptr<ResObject> PtrType;
109  typedef intrusive_ptr<const ResObject> constPtrType;
110  };
111 
118  template<typename _Res>
119  inline ResKind resKind() { return ResTraits<_Res>::kind; }
120 
129  template<typename _Res>
130  inline bool isKind( const ResKind & val_r )
131  { return( resKind<_Res>() == val_r ); }
133  template<typename _Res>
134  inline bool isKind( const std::string & val_r )
135  { return( resKind<_Res>() == val_r ); }
137  template<typename _Res>
138  inline bool isKind( const char * val_r )
139  { return( resKind<_Res>() == val_r ); }
140 
141 
143 } // namespace zypp
145 #endif // ZYPP_RESTRAITS_H