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