libzypp  17.5.0
ResObject.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESOBJECT_H
13 #define ZYPP_RESOBJECT_H
14 
15 #include "zypp/APIConfig.h"
16 
17 #include "zypp/Resolvable.h"
18 #include "zypp/Vendor.h"
19 
20 #include "zypp/sat/LookupAttr.h"
21 #include "zypp/sat/SolvableSet.h"
22 
24 namespace zypp
25 {
38  class ResObject : public Resolvable
39  {
40  public:
41  typedef ResObject Self;
45 
46  public:
59  template<class TRes>
60  inline typename ResTraits<TRes>::constPtrType asKind() const;
61 
62  template<class TRes>
63  inline typename ResTraits<TRes>::PtrType asKind();
64 
65  public:
70  Vendor vendor() const
71  { return Resolvable::vendor().asString(); }
72 
73  protected:
74  friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
76  ResObject( const sat::Solvable & solvable_r );
78  virtual ~ResObject();
80  virtual std::ostream & dumpOn( std::ostream & str ) const;
82  operator sat::Solvable() const
83  { return satSolvable(); }
84  };
86 
103  ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
104 
118  template<class TRes>
119  inline typename ResTraits<TRes>::PtrType make( const sat::Solvable & solvable_r )
120  { return( isKind<TRes>( solvable_r ) ? new TRes( solvable_r ) : 0 ); }
122  template<>
123  inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
124  { return makeResObject( solvable_r ); }
125 
127  template<class TRes>
128  inline typename ResTraits<TRes>::PtrType asKind( const sat::Solvable & solvable_r )
129  { return make<TRes>( solvable_r ); }
130 
139  template<class TRes>
140  inline typename ResTraits<TRes>::PtrType asKind( const ResObject::Ptr & p )
141  { return dynamic_pointer_cast<TRes>(p); }
142 
143  template<class TRes>
145  { return dynamic_pointer_cast<const TRes>(p); }
146 
147  template<class TRes>
149  { return dynamic_cast<const TRes *>( this ); }
150 
151  template<class TRes>
153  { return dynamic_cast<TRes *>( this ); }
154 
155 } // namespace zypp
157 #endif // ZYPP_RESOBJECT_H
A Solvable object within the sat Pool.
Definition: Solvable.h:53
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: ResObject.cc:31
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
friend ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Definition: ResObject.cc:44
ResTraits< TRes >::PtrType asKind(const ResObject::Ptr &p)
Convert ResObject::Ptr into Ptr of a certain Kind.
Definition: ResObject.h:140
ResTraits< Self > TraitsType
Definition: ResObject.h:42
TraitsType::PtrType Ptr
Definition: ResObject.h:43
ResTraits< TRes >::constPtrType asKind() const
Convert this into a Ptr of a certain Kind.
Definition: ResObject.h:148
ResTraits< TRes >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:128
String related utilities and Regular expression matching.
std::string Vendor
Definition: Vendor.h:22
Base for resolvable objects.
Definition: Resolvable.h:49
ResTraits.
Definition: ResTraits.h:79
TraitsType::constPtrType constPtr
Definition: ResObject.h:44
ResObject Self
Definition: ResObject.h:41
Provides API related macros.
ResTraits< TRes >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:119
Base for resolvable objects.
Definition: ResObject.h:38
Vendor vendor() const
Vendor.
Definition: ResObject.h:70
intrusive_ptr< TRes > PtrType
Definition: ResTraits.h:82
virtual ~ResObject()
Dtor.
Definition: ResObject.cc:28
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Definition: ResObject.cc:44
std::string asString() const
Conversion to std::string
Definition: IdString.h:91
ResObject(const sat::Solvable &solvable_r)
Ctor.
Definition: ResObject.cc:24
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
ResObject::Ptr make< ResObject >(const sat::Solvable &solvable_r)
Definition: ResObject.h:123
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57