Source.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_SOURCE_H
00013 #define ZYPP_SOURCE_H
00014 
00015 #include <iosfwd>
00016 #include <string>
00017 
00018 #include "zypp/base/PtrTypes.h"
00019 #include "zypp/base/SafeBool.h"
00020 
00021 #include "zypp/Package.h"
00022 #include "zypp/Pathname.h"
00023 #include "zypp/Url.h"
00024 #include "zypp/Resolvable.h"
00025 
00026 #include "zypp/media/MediaManager.h"
00027 
00029 namespace zypp
00030 { 
00031   namespace source
00032   {
00033     class SourceImpl;
00034     DEFINE_PTR_TYPE(SourceImpl);
00035 
00037     //
00038     //    CLASS NAME : SkipRequestedException
00039     //
00044     class SkipRequestedException : public Exception {
00045     public:
00046         SkipRequestedException ( const std::string & msg_r ) : Exception( msg_r ) {}
00047     };
00048 
00049   }
00050   class ResStore;
00051 
00053   //
00054   //    CLASS NAME : Source
00055   //
00060   class Source_Ref : protected base::SafeBool<Source_Ref> /* private, but gcc refuses */
00061   {
00062     friend std::ostream & operator<<( std::ostream & str, const Source_Ref & obj );
00063     friend bool operator==( const Source_Ref & lhs, const Source_Ref & rhs );
00064     friend bool operator<( const Source_Ref & lhs, const Source_Ref & rhs );
00065 
00066   public:
00067     typedef source::SourceImpl     Impl;
00068     typedef source::SourceImpl_Ptr Impl_Ptr;
00069 
00070   public:
00071 
00075     Source_Ref();
00076 
00080     static const Source_Ref noSource;
00081 
00085     using base::SafeBool<Source_Ref>::operator bool_type;
00086 
00087   public:
00088     typedef unsigned long NumericId;
00089 
00091     NumericId numericId() const;
00092 
00093   public:
00094 
00096     const ResStore & resolvables() const;
00097 
00099     const ResStore resolvables(zypp::Resolvable::Kind kind) const;
00100 
00101     const Pathname providePackage( Package::constPtr package );
00102     
00104     const Pathname provideFile(const Pathname & file_r,
00105                                const unsigned media_nr = 1);
00106     const Pathname provideDirTree(const Pathname & dir_r,
00107                                   const unsigned media_nr = 1);
00108                               
00109     const void releaseFile(const Pathname & file_r,
00110                            const unsigned media_nr = 1);
00111     const void releaseDir(const Pathname & dir_r,
00112                           const unsigned media_nr = 1,
00113                           const bool recursive = false);
00114 
00115     const bool enabled() const;
00116 
00117     void enable();
00118 
00119     void disable();
00120 
00121     const bool autorefresh() const;
00122     void setAutorefresh( const bool enable_r );
00123     void refresh();
00124 
00125     void storeMetadata(const Pathname & cache_dir_r);
00126 
00128     std::string alias (void) const;
00129     void setAlias (const std::string & alias_r);
00130 
00132     std::string type (void) const;
00133 
00134     unsigned numberOfMedia(void) const;
00135 
00137     std::string vendor (void) const;
00139     std::string unique_id (void) const;
00140 
00142 
00143 
00144     std::string id (void) const;
00145     void setId (const std::string id_r);
00146     unsigned priority (void) const;
00147     void setPriority (unsigned p);
00148     unsigned priorityUnsubscribed (void) const;
00149     void setPriorityUnsubscribed (unsigned p);
00150     bool subscribed (void) const;
00151     void setSubscribed (bool s);
00152     const Pathname & cacheDir (void) const;
00153     const std::list<Pathname> publicKeys();
00155 
00157 
00158     std::string zmdName (void) const;
00159     void setZmdName (const std::string name_r);
00160     std::string zmdDescription (void) const;
00161     void setZmdDescription (const std::string desc_r);
00163 
00165 
00166     Url url (void) const;
00171     void setUrl( const Url & url );
00172     bool remote() const;
00173     const Pathname & path (void) const;
00174     const bool baseSource() const;
00176 
00177   public:
00182     void changeMedia(const media::MediaId & media_r, const Pathname & path_r);
00183 
00187     void redirect(unsigned media_nr, const Url & new_url);
00188 
00192     void release();
00193 
00200     void reattach(const Pathname &attach_point);
00201 
00205     media::MediaVerifierRef verifier(unsigned media_nr);
00206 
00207   private:
00208     friend base::SafeBool<Source_Ref>::operator bool_type() const;
00210     bool boolTest() const
00211     { return _pimpl != noSource._pimpl; }
00212 
00213   private:
00215     friend class SourceFactory;
00216     friend class source::SourceImpl;
00217 
00218   private:
00220     explicit
00221     Source_Ref( const Impl_Ptr & impl_r );
00222 
00223   private:
00225     Impl_Ptr _pimpl;
00226   };
00228 
00230   std::ostream & operator<<( std::ostream & str, const Source_Ref & obj );
00231 
00233   inline bool operator==( const Source_Ref & lhs, const Source_Ref & rhs )
00234   { return lhs._pimpl == rhs._pimpl; }
00235 
00237   inline bool operator!=( const Source_Ref & lhs, const Source_Ref & rhs )
00238   { return ! (lhs == rhs); }
00239 
00241   inline bool operator<( const Source_Ref & lhs, const Source_Ref & rhs )
00242   { return lhs._pimpl < rhs._pimpl; }
00243 
00245 } // namespace zypp
00247 #endif // ZYPP_SOURCE_H

Generated on Thu May 4 16:03:26 2006 for zypp by  doxygen 1.4.6