00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_SOURCEFACTORY_H
00013 #define ZYPP_SOURCEFACTORY_H
00014
00015 #include <iosfwd>
00016 #include <string>
00017 #include <set>
00018 #include <boost/logic/tribool.hpp>
00019
00020 #include "zypp/base/PtrTypes.h"
00021
00022 #include "zypp/Source.h"
00023 #include "zypp/source/SourceInfo.h"
00024 #include "zypp/Url.h"
00025 #include "zypp/Pathname.h"
00026
00027 using namespace boost;
00028
00030 namespace zypp
00031 {
00032
00033 template<class T>
00034 bool probeSource( media::MediaAccessId media_id );
00035
00036
00038
00039
00040
00045 class SourceFactory
00046 {
00047 friend std::ostream & operator<<( std::ostream & str, const SourceFactory & obj );
00048
00049 public:
00051 SourceFactory();
00053 ~SourceFactory();
00054
00055 public:
00059 Source_Ref createFrom( const source::SourceInfo & context );
00060
00064 Source_Ref createFrom( const Source_Ref::Impl_Ptr & impl_r );
00065
00069 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 );
00070
00074 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 );
00075
00076 protected:
00077 template<class _SourceImpl>
00078 Source_Ref createSourceImplWorkflow( media::MediaId id, const source::SourceInfo &context );
00079 private:
00081 class Impl;
00083 RW_pointer<Impl> _pimpl;
00084
00085 public:
00086 struct ProductEntry {
00087 Pathname _dir;
00088 std::string _name;
00089 ProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ){
00090 _dir = dir_r;
00091 _name = name_r;
00092 }
00093 bool operator<( const ProductEntry & rhs ) const {
00094 return( _dir.asString() < rhs._dir.asString() );
00095 }
00096 };
00097
00098 typedef std::set<ProductEntry> ProductSet;
00099
00103 void listProducts( const Url & url_r, ProductSet & products_r );
00104 private:
00105
00106 void scanProductsFile( const Pathname & file_r, ProductSet & pset_r ) const;
00107 };
00109
00111 extern std::ostream & operator<<( std::ostream & str, const SourceFactory & obj );
00112
00114 }
00116 #endif // ZYPP_SOURCEFACTORY_H