1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Resolvable.h
12 #ifndef ZYPP_RESOLVABLE_H
13 #define ZYPP_RESOLVABLE_H
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/NonCopyable.h"
20 #include "zypp/base/PtrTypes.h"
21 #include "zypp/ResTraits.h"
23 #include "zypp/Edition.h"
24 #include "zypp/Arch.h"
25 #include "zypp/Dependencies.h"
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////
33 // CLASS NAME : Resolvable
35 /** Interface base for resolvable objects (identification and dependencies).
37 class Resolvable : public base::ReferenceCounted, private base::NonCopyable
40 typedef Resolvable Self;
41 typedef ResTraits<Self> TraitsType;
42 typedef TraitsType::KindType Kind;
43 typedef TraitsType::PtrType Ptr;
44 typedef TraitsType::constPtrType constPtr;
48 const Kind & kind() const;
50 const std::string & name() const;
52 const Edition & edition() const;
54 const Arch & arch() const;
56 const Dependencies & deps() const;
58 void setDeps( const Dependencies & val_r );
62 Resolvable( const Kind & kind_r,
63 const std::string & name_r,
64 const Edition & edition_r,
65 const Arch & arch_r );
67 virtual ~Resolvable();
68 /** Helper for stream output */
69 virtual std::ostream & dumpOn( std::ostream & str ) const;
74 /** Pointer to implementation */
75 RW_pointer<Impl> _pimpl;
77 ///////////////////////////////////////////////////////////////////
79 /** Test whether a Resolvable::Ptr is of a certain Kind.
80 * \return \c Ture iff \a p is not \c NULL and points to a Resolvable
81 * of the specified Kind.
84 * isKind<Package>(resPtr);
88 inline bool isKind( const Resolvable::constPtr & p )
89 { return p && p->kind() == ResTraits<_Res>::kind; }
91 // Specialization for Resolvable: Always true.
93 inline bool isKind<Resolvable>( const Resolvable::constPtr & p )
96 // Specialization for ResObject: Always true.
98 inline bool isKind<ResObject>( const Resolvable::constPtr & p )
102 /** Convert Resolvable::Ptr into Ptr of a certain Kind.
103 * \return \c NULL iff \a p is \c NULL or points to a Resolvable
104 * not of the specified Kind.
105 * \relates Resolvable
107 * asKind<Package>(resPtr);
111 inline typename ResTraits<_Res>::PtrType asKind( const Resolvable::Ptr & p )
112 { return dynamic_pointer_cast<_Res>(p); }
115 inline typename ResTraits<_Res>::constPtrType asKind( const Resolvable::constPtr & p )
116 { return dynamic_pointer_cast<const _Res>(p); }
118 /////////////////////////////////////////////////////////////////
120 ///////////////////////////////////////////////////////////////////
121 #endif // ZYPP_RESOLVABLE_H