Bump to libzypp-bindings 0.7.4
[platform/upstream/libzypp-bindings.git] / swig / ResTraits.i
1
2 /** Base of ResTraits. Defines the Resolvable::Kind type. */
3 /*struct ResolvableTraits
4 {
5     typedef KindOf<Resolvable>  KindType;
6 };*/
7
8 namespace zypp
9 {
10   /** ResTraits. Defines common types and the Kind value. */
11   template<typename _Res>
12   struct ResTraits
13   {
14       typedef zypp::intrusive_ptr<_Res>       PtrType;
15       typedef zypp::intrusive_ptr<const _Res> constPtrType;
16   };
17
18    typedef ::zypp::intrusive_ptr<const ResObject> ResObject_constPtr;
19    typedef ::zypp::intrusive_ptr<ResObject>       ResObject_Ptr;
20    %template(ResObject_constPtr)          ::zypp::intrusive_ptr<const zypp::ResObject>;
21    %template(ResObject_Ptr)               ::zypp::intrusive_ptr<zypp::ResObject>;
22
23 }
24
25 namespace zypp::ResObject::TraitsType
26 {
27   typedef ::zypp::intrusive_ptr<const zypp::ResObject> constPtrType;
28 }
29 namespace zypp::Resolvable::TraitsType
30 {
31   typedef ::zypp::intrusive_ptr<const zypp::Resolvable> constPtrType;
32 }
33
34 %template(ResTraitsResolvable) zypp::ResTraits<zypp::Resolvable>;
35 %template(ResTraitsResObject)  zypp::ResTraits<zypp::ResObject>;
36
37 // Common definitions for all Resolvable types
38 // - *_Ptr and *_constPtr
39 // - isKind* to test whether a ResObject/PoolItem is
40 //   of a specific kind.
41 // - asKind* to convert a ResObject/PoolItem into a
42 //   specific *_constPtr.
43 %define %STUFF(X)
44 namespace zypp
45 {
46   typedef ::zypp::intrusive_ptr<const X> X##_constPtr;
47   typedef ::zypp::intrusive_ptr<X>       X##_Ptr;
48   %template(X##_constPtr)        ::zypp::intrusive_ptr<const X>;
49   %template(X##_Ptr)             ::zypp::intrusive_ptr<X>;
50
51   bool isKind##X( const zypp::Resolvable::constPtr & p );
52   bool isKind##X( const zypp::ResObject::constPtr & p );
53   bool isKind##X( const zypp::PoolItem & p );
54
55   X##_constPtr asKind##X( const zypp::Resolvable::constPtr & p );
56   X##_constPtr asKind##X( const zypp::ResObject::constPtr & p );
57   X##_constPtr asKind##X( const zypp::PoolItem & p );
58 }
59
60 %header
61 {
62   namespace zypp
63   {
64     inline bool isKind##X( const zypp::Resolvable::constPtr & p )
65     { return isKind<X>( p ); }
66     inline bool isKind##X( const zypp::ResObject::constPtr & p )
67     { return isKind<X>( p ); }
68     inline bool isKind##X( const zypp::PoolItem & p )
69     { return isKind<X>( p.resolvable() ); }
70     inline X::constPtr asKind##X( const zypp::Resolvable::constPtr & p )
71     { return asKind<X>( p ); }
72     inline X::constPtr asKind##X( const zypp::ResObject::constPtr & p )
73     { return asKind<X>( p ); }
74     inline X::constPtr asKind##X( const zypp::PoolItem & p )
75     { return asKind<X>( p.resolvable() ); }
76   }
77 }
78
79 #if defined(SWIGPYTHON)
80 %pythoncode
81 {
82   def KindOf##X():
83     return KindOfResolvable( #X )
84 }
85 #endif
86 %enddef
87
88 %STUFF(Package)
89 %STUFF(Patch)
90 %STUFF(SrcPackage)
91 %STUFF(Pattern)
92 %STUFF(Product)
93 %STUFF(Application)