1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/SourceFactory.h
12 #ifndef ZYPP_SOURCEFACTORY_H
13 #define ZYPP_SOURCEFACTORY_H
18 #include <boost/logic/tribool.hpp>
20 #include "zypp/base/PtrTypes.h"
22 #include "zypp/Source.h"
23 #include "zypp/source/SourceInfo.h"
25 #include "zypp/Pathname.h"
27 using namespace boost;
29 ///////////////////////////////////////////////////////////////////
31 { /////////////////////////////////////////////////////////////////
34 bool probeSource( media::MediaAccessId media_id );
37 ///////////////////////////////////////////////////////////////////
39 // CLASS NAME : SourceFactory
41 /** Factory to create a \ref Source_Ref.
42 * Actually a Singleton
47 friend std::ostream & operator<<( std::ostream & str, const SourceFactory & obj );
57 * \throw EXCEPTION on fail
59 Source_Ref createFrom( const source::SourceInfo & context );
61 /** Construct source from an implementation.
62 * Returns Source_Ref::noSource on NULL \a impl_r.
64 Source_Ref createFrom( const Source_Ref::Impl_Ptr & impl_r );
67 * \throw EXCEPTION on fail
69 Source_Ref createFrom( const Url & url_r, const Pathname & path_r = "/", const std::string & alias_r = "", const Pathname & cache_dir_r = "", bool base_source = false );
71 /** Construct source of a given type.
72 * \throw EXCEPTION on fail
74 Source_Ref createFrom( const std::string & type, const Url & url_r, const Pathname & path_r, const std::string & alias_r, const Pathname & cache_dir_r, bool base_source, tribool auto_refresh );
77 template<class _SourceImpl>
78 Source_Ref createSourceImplWorkflow( media::MediaId id, const source::SourceInfo &context );
82 /** Pointer to implementation */
83 RW_pointer<Impl> _pimpl;
89 ProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ){
93 bool operator<( const ProductEntry & rhs ) const {
94 return( _dir.asString() < rhs._dir.asString() );
98 typedef std::set<ProductEntry> ProductSet;
100 /** Check which products are available on the media
101 * \throw Exception or MediaException on fail
103 void listProducts( const Url & url_r, ProductSet & products_r );
105 // bool probeSource( const std::string name, boost::function<bool()> prober, callback::SendReport<CreateSourceReport> &report );
106 void scanProductsFile( const Pathname & file_r, ProductSet & pset_r ) const;
108 ///////////////////////////////////////////////////////////////////
110 /** \relates SourceFactory Stream output */
111 extern std::ostream & operator<<( std::ostream & str, const SourceFactory & obj );
113 /////////////////////////////////////////////////////////////////
115 ///////////////////////////////////////////////////////////////////
116 #endif // ZYPP_SOURCEFACTORY_H