libzypp  17.14.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 
23 namespace zypp
24 {
37  class ResObject : public Resolvable
38  {
39  public:
40  typedef ResObject Self;
44 
45  public:
58  template<class TRes>
59  inline typename ResTraits<TRes>::constPtrType asKind() const;
60 
61  template<class TRes>
62  inline typename ResTraits<TRes>::PtrType asKind();
63 
64  public:
69  Vendor vendor() const
70  { return Resolvable::vendor().asString(); }
71 
72  protected:
73  friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
75  ResObject( const sat::Solvable & solvable_r );
77  virtual ~ResObject();
79  virtual std::ostream & dumpOn( std::ostream & str ) const;
81  operator sat::Solvable() const
82  { return satSolvable(); }
83  };
85 
102  ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
103 
117  template<class TRes>
118  inline typename ResTraits<TRes>::PtrType make( const sat::Solvable & solvable_r )
119  { return( isKind<TRes>( solvable_r ) ? new TRes( solvable_r ) : 0 ); }
121  template<>
122  inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
123  { return makeResObject( solvable_r ); }
124 
126  template<class TRes>
127  inline typename ResTraits<TRes>::PtrType asKind( const sat::Solvable & solvable_r )
128  { return make<TRes>( solvable_r ); }
129 
138  template<class TRes>
139  inline typename ResTraits<TRes>::PtrType asKind( const ResObject::Ptr & p )
140  { return dynamic_pointer_cast<TRes>(p); }
141 
142  template<class TRes>
144  { return dynamic_pointer_cast<const TRes>(p); }
145 
146  template<class TRes>
148  { return dynamic_cast<const TRes *>( this ); }
149 
150  template<class TRes>
152  { return dynamic_cast<TRes *>( this ); }
153 
154 } // namespace zypp
156 #endif // ZYPP_RESOBJECT_H