libzypp 17.37.10

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-core/Globals.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 ZYPP_API ResObject : public Resolvable
38 {
39 public:
40 using Self = ResObject;
41 using TraitsType = ResTraits<Self>;
42 using Ptr = TraitsType::PtrType;
43 using constPtr = TraitsType::constPtrType;
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 ~ResObject() override;
79 std::ostream & dumpOn( std::ostream & str ) const override;
81 operator sat::Solvable() const
82 { return satSolvable(); }
83 };
84
85
102 ResObject::Ptr makeResObject( const sat::Solvable & solvable_r ) ZYPP_API;
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 ); }
120
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>
143 inline typename ResTraits<TRes>::constPtrType asKind( const ResObject::constPtr & p )
144 { return dynamic_pointer_cast<const TRes>(p); }
145
146 template<class TRes>
147 inline typename ResTraits<TRes>::constPtrType ResObject::asKind() const
148 { return dynamic_cast<const TRes *>( this ); }
149
150 template<class TRes>
151 inline typename ResTraits<TRes>::PtrType ResObject::asKind()
152 { return dynamic_cast<TRes *>( this ); }
153
154} // namespace zypp
156#endif // ZYPP_RESOBJECT_H
LookupAttr.h
Resolvable.h
Vendor.h
zypp::IdString::asString
std::string asString() const
Conversion to std::string
Definition IdString.h:99
zypp::ResObject
Base for resolvable objects.
Definition ResObject.h:38
zypp::ResObject::constPtr
TraitsType::constPtrType constPtr
Definition ResObject.h:43
zypp::ResObject::Self
ResObject Self
Definition ResObject.h:40
zypp::ResObject::vendor
Vendor vendor() const
Vendor.
Definition ResObject.h:69
zypp::ResObject::ResObject
ResObject(const sat::Solvable &solvable_r)
Ctor.
Definition ResObject.cc:23
zypp::ResObject::Ptr
TraitsType::PtrType Ptr
Definition ResObject.h:42
zypp::ResObject::asKind
ResTraits< TRes >::PtrType asKind(const ResObject::Ptr &p)
Convert ResObject::Ptr into Ptr of a certain Kind.
Definition ResObject.h:139
zypp::ResObject::asKind
ResTraits< TRes >::constPtrType asKind() const
Convert this into a Ptr of a certain Kind.
Definition ResObject.h:147
zypp::ResObject::TraitsType
ResTraits< Self > TraitsType
Definition ResObject.h:41
zypp::Resolvable::Resolvable
Resolvable(const sat::Solvable &solvable_r)
Ctor.
Definition Resolvable.cc:21
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::make< ResObject >
ResObject::Ptr make< ResObject >(const sat::Solvable &solvable_r)
Definition ResObject.h:122
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition Capability.cc:580
zypp::make
ResTraits< TRes >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition ResObject.h:118
zypp::makeResObject
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Definition ResObject.cc:43
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::isKind
bool isKind(const ResKind &val_r)
Convenient test for ResKinds.
Definition ResTraits.h:140
zypp::Vendor
std::string Vendor
Definition Vendor.h:22
zypp::asKind
ResTraits< TRes >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition ResObject.h:127
zypp::ResTraits
ResTraits.
Definition ResTraits.h:80
zypp::ResTraits< Self >::PtrType
intrusive_ptr< Self > PtrType
Definition ResTraits.h:82
zypp::ResTraits< Self >::constPtrType
intrusive_ptr< const Self > constPtrType
Definition ResTraits.h:83
zypp::sat::SolvableType< Resolvable >::vendor
IdString vendor() const
Definition SolvableType.h:73
zypp::sat::SolvableType< Resolvable >::satSolvable
Solvable satSolvable() const
Definition SolvableType.h:57
Globals.h
Provides API related macros.
ZYPP_API
#define ZYPP_API
Definition Globals.h:69