libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_RESTRAITS_H 00013 #define ZYPP_RESTRAITS_H 00014 00015 #include "zypp/base/PtrTypes.h" 00016 #include "zypp/ResKind.h" 00017 00019 namespace zypp 00020 { 00021 00023 namespace traits 00024 { 00025 00028 inline bool isPseudoInstalled( ResKind kind_r ) 00029 { return( kind_r == ResKind::patch || kind_r == ResKind::pattern ); } 00030 00032 } // namespace traits 00034 00062 DEFINE_PTR_TYPE( Resolvable ); 00063 DEFINE_PTR_TYPE( ResObject ); 00064 00065 DEFINE_PTR_TYPE( Package ); 00066 DEFINE_PTR_TYPE( SrcPackage ); 00067 DEFINE_PTR_TYPE( Pattern ); 00068 DEFINE_PTR_TYPE( Product ); 00069 DEFINE_PTR_TYPE( Patch ); 00071 00073 class PoolItem; 00074 00076 template<typename _Res> 00077 struct ResTraits 00078 { 00079 typedef ResKind KindType; 00080 typedef intrusive_ptr<_Res> PtrType; 00081 typedef intrusive_ptr<const _Res> constPtrType; 00082 00083 static const ResKind kind; 00084 00087 static bool isPseudoInstalled() { return traits::isPseudoInstalled( kind ); } 00088 }; 00089 00093 template<> 00094 struct ResTraits<Resolvable> 00095 { 00096 typedef ResKind KindType; 00097 typedef intrusive_ptr<Resolvable> PtrType; 00098 typedef intrusive_ptr<const Resolvable> constPtrType; 00099 }; 00100 00104 template<> 00105 struct ResTraits<ResObject> 00106 { 00107 typedef ResKind KindType; 00108 typedef intrusive_ptr<ResObject> PtrType; 00109 typedef intrusive_ptr<const ResObject> constPtrType; 00110 }; 00111 00118 template<typename _Res> 00119 inline ResKind resKind() { return ResTraits<_Res>::kind; } 00120 00129 template<typename _Res> 00130 inline bool isKind( const ResKind & val_r ) 00131 { return( resKind<_Res>() == val_r ); } 00133 template<typename _Res> 00134 inline bool isKind( const std::string & val_r ) 00135 { return( resKind<_Res>() == val_r ); } 00137 template<typename _Res> 00138 inline bool isKind( const char * val_r ) 00139 { return( resKind<_Res>() == val_r ); } 00140 00141 00143 } // namespace zypp 00145 #endif // ZYPP_RESTRAITS_H