1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/detail/ResObjectFactory.h
12 #ifndef ZYPP_DETAIL_RESOBJECTFACTORY_H
13 #define ZYPP_DETAIL_RESOBJECTFACTORY_H
15 #include "zypp/base/PtrTypes.h"
17 ///////////////////////////////////////////////////////////////////
19 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////
28 namespace _resobjectfactory_detail
29 { /////////////////////////////////////////////////////////////////
32 class ResImplConnect : public _Res
35 typedef ResImplConnect Self;
36 typedef typename _Res::Impl Impl;
37 typedef base::shared_ptr<Impl> ImplPtr;
38 typedef base::intrusive_ptr<Self> Ptr;
39 typedef base::intrusive_ptr<const Self> constPtr;
41 /** \todo protect against NULL Impl. */
42 ResImplConnect( const std::string & name_r,
43 const Edition & edition_r,
46 : _Res( name_r, edition_r, arch_r )
48 { _impl->_backRef = this; }
49 virtual ~ResImplConnect()
50 { _impl->_backRef = 0; }
53 virtual Impl & pimpl() { return *_impl; }
54 virtual const Impl & pimpl() const { return *_impl; }
57 /////////////////////////////////////////////////////////////////
58 } // namespace _resobjectfactory
59 ///////////////////////////////////////////////////////////////////
62 typename _Impl::ResType::Ptr
63 makeResolvableAndImpl( const std::string & name_r,
64 const Edition & edition_r,
66 base::shared_ptr<_Impl> & impl_r )
68 impl_r.reset( new _Impl );
70 _resobjectfactory_detail::ResImplConnect<typename _Impl::ResType>
71 ( name_r, edition_r, arch_r, impl_r );
75 typename _Impl::ResType::Ptr
76 makeResolvableFromImpl( const std::string & name_r,
77 const Edition & edition_r,
79 base::shared_ptr<_Impl> impl_r )
82 throw ( "makeResolvableFromImpl: NULL Impl " );
84 throw ( "makeResolvableFromImpl: Impl already managed" );
86 _resobjectfactory_detail::ResImplConnect<typename _Impl::ResType>
87 ( name_r, edition_r, arch_r, impl_r );
90 /////////////////////////////////////////////////////////////////
92 ///////////////////////////////////////////////////////////////////
93 /////////////////////////////////////////////////////////////////
95 ///////////////////////////////////////////////////////////////////
96 #endif // ZYPP_DETAIL_RESOBJECTFACTORY_H