Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

InstSrc.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       InstSrc.h
00014 
00015   Author:     Michael Andres <ma@suse.de>
00016   Maintainer: Michael Andres <ma@suse.de>
00017 
00018   Purpose:      Class for installation sources
00019                 Defines (provides access to)
00020                 - media access (a pointer to MediaAccess)
00021                 - source description (product, version, vendor, ...)
00022                 - contents (list of package, list of selections, ...)
00023 /-*/
00024 #ifndef InstSrc_h
00025 #define InstSrc_h
00026 
00027 #include <iosfwd>
00028 #include <list>
00029 #include <string>
00030 
00031 #include <y2util/Pathname.h>
00032 #include <y2util/Url.h>
00033 
00034 #include <y2pm/PMTypes.h>
00035 
00036 #include <y2pm/PMPackagePtr.h>
00037 #include <y2pm/PMSelectionPtr.h>
00038 #include <y2pm/PMYouPatchPtr.h>
00039 
00040 #include <y2pm/InstSrcPtr.h>
00041 #include <y2pm/InstSrcError.h>
00042 
00043 #include <y2pm/MediaAccessPtr.h>
00044 #include <y2pm/InstSrcDescrPtr.h>
00045 #include <y2pm/InstSrcDataPtr.h>
00046 
00048 //
00049 //      CLASS NAME : InstSrc
00053 class InstSrc: public CountedRep {
00054   REP_BODY(InstSrc);
00055 
00056   private:
00057 
00058     friend class InstSrcManager;
00059 
00064     void _mgr_attach();
00065 
00067   public:
00068 
00072     typedef InstSrcError Error;
00073 
00075   public:
00076 
00080     typedef PM::NumericISrcID NumericISrcID;
00081     typedef PM::NumericISrcID UniqueID;
00082 
00086     static const NumericISrcID noID;
00087 
00091     NumericISrcID srcID() const { return _srcID; }
00092 
00093   private:
00094 
00098     static NumericISrcID _SRCID;
00099 
00103     const NumericISrcID _srcID;
00104 
00106   public:
00115     enum Type {
00116       T_UNKNOWN,
00117       // :first entry
00118       T_UnitedLinux,
00119       T_PlainDir,
00120       // last entry:
00121       T_AUTODETECT
00122     };
00123 
00128     static std::string toString( const Type t );
00129 
00134     static Type fromString( std::string s );
00135 
00139     friend std::ostream & operator<<( std::ostream & str, const Type obj );
00140 
00141   private:
00142 
00146     Pathname _cache;
00147 
00151     bool _cache_deleteOnExit;
00152 
00157     bool _may_use_cache;
00158 
00162     static const Pathname _c_descr_dir;
00163 
00167     static const Pathname _c_data_dir;
00168 
00172     static const Pathname _c_media_dir;
00173 
00177     Pathname cachePath( const Pathname & sub_r ) const { return( _cache + sub_r ); }
00178 
00182     mutable Pathname previouslyDnlPackage;
00183 
00184 
00188     mutable int _specialCache;
00189 
00190   public:
00191 
00195     bool specialCache() const;
00196 
00200     void rememberPreviouslyDnlPackage( const Pathname & newpath_r ) const;
00201 
00205     Pathname cache_dir() const { return _cache; }
00206 
00211     Pathname cache_descr_dir() const { return cachePath( _c_descr_dir ); }
00212 
00217     Pathname cache_data_dir() const { return cachePath( _c_data_dir ); }
00218 
00222     Pathname cache_media_dir() const { return cachePath( _c_media_dir ); }
00223 
00224   private:
00225 
00234     PMError _init_openCache( const Pathname & cachedir_r );
00235 
00246     PMError _init_newCache( const Pathname & cachedir_r );
00247 
00256     PMError _init_newMedia( const Url & mediaurl_r, const Pathname & produduct_dir_r,
00257                             Type type_r );
00258 
00262     PMError writeDescrCache();
00263 
00264   protected:
00265 
00272     InstSrc();
00273 
00277     ~InstSrc();
00278 
00279   private:
00280 
00284     MediaAccessPtr _media;
00285 
00289     InstSrcDescrPtr _descr;
00290 
00294     InstSrcDataPtr _data;
00295 
00296   public:
00297 
00301     constInstSrcDescrPtr descr() const { return _descr; }
00302 
00306     InstSrcDescrPtr descr() { return _descr; }
00307 
00311     constInstSrcDataPtr data() const { return _data; }
00312 
00316     InstSrcDataPtr data() { return _data; }
00317 
00321     constMediaAccessPtr media() const { return _media; }
00322 
00326     MediaAccessPtr media() { return _media; }
00327 
00331     void preferredLocaleChanged() const;
00332 
00333   public:
00334 
00340     PMError enableSource();
00341 
00346     PMError disableSource();
00347 
00351     bool enabled() const { return _data; }
00352 
00353   private:
00354 
00359         mutable int _medianr;
00360 
00364         PMError provideMedia (int medianr) const;
00365 
00366   public:
00367 
00377         PMError providePackage (int medianr, const Pathname& name, const Pathname& dir, Pathname& path_r) const;
00378 
00388         PMError provideFile (int medianr, const Pathname& path, Pathname& file_r) const;
00389 
00399         PMError provideDir (int medianr, const Pathname& path, Pathname& dir_r) const;
00400 
00405         bool isRemote (void) const;
00406 
00412         PMError changeUrl (const Url & newUrl_r);
00413 
00414 
00419         PMError releaseMedia( bool if_removable_r = false ) const;
00420 
00421   public:
00422 
00423     std::ostream & dumpOn( std::ostream & str ) const;
00424 
00425   public:
00426 
00435     static PMError vconstruct( InstSrcPtr & nsrc_r, const Pathname & cachedir_r );
00436 
00447     static PMError vconstruct( InstSrcPtr & nsrc_r, const Pathname & cachedir_r,
00448                                const Url & mediaurl_r, const Pathname & produduct_dir_r,
00449                                Type type_r = T_AUTODETECT );
00450 
00451 };
00452 
00454 
00455 #endif // InstSrc_h
00456 

Generated on Fri Nov 9 14:30:31 2007 for yast2-packagemanager by doxygen 1.3.6