blob: 6658bdb84386b17e8431b0dc4b77323d5578a695 (
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
73
74
75
76
77
|
/** 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 ::zypp::intrusive_ptr<const ResObject> ResObject_constPtr;
typedef ::zypp::intrusive_ptr<ResObject> ResObject_Ptr;
%template(ResObject_constPtr) ::zypp::intrusive_ptr<const zypp::ResObject>;
%template(ResObject_Ptr) ::zypp::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)
namespace zypp
{
typedef ::zypp::intrusive_ptr<const X> X##_constPtr;
typedef ::zypp::intrusive_ptr<X> X##_Ptr;
%template(X##_constPtr) ::zypp::intrusive_ptr<const X>;
%template(X##_Ptr) ::zypp::intrusive_ptr<X>;
bool isKind##X( const zypp::Resolvable::constPtr & p );
bool isKind##X( const zypp::PoolItem & p );
X##_constPtr asKind##X( const zypp::Resolvable::constPtr & p );
X##_constPtr asKind##X( const zypp::PoolItem & p );
}
%header
{
namespace zypp
{
inline bool isKind##X( const zypp::Resolvable::constPtr & p )
{ return isKind<X>( p ); }
inline bool isKind##X( const zypp::PoolItem & p )
{ return isKind<X>( p.resolvable() ); }
inline X::constPtr asKind##X( const zypp::Resolvable::constPtr & p )
{ return asKind<X>( p ); }
inline X::constPtr asKind##X( const zypp::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)
|