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 
00050     //
00051     //    CLASS NAME : SourceUserRejectedException
00052     //
00057     class SourceUserRejectedException : public Exception
00058     {
00059       public:
00060         SourceUserRejectedException ( const std::string & msg_r ) : Exception( msg_r ) {}
00061     };
00062 
00066     class SourceMetadataException : public Exception
00067     {
00068       public:
00069         SourceMetadataException ( const std::string & msg_r ) : Exception( msg_r ) {}
00070     };
00071     
00075     class SourceIOException : public Exception
00076     {
00077       public:
00078         SourceIOException ( const std::string & msg_r ) : Exception( msg_r ) {}
00079     };
00080     
00084     class SourceNotFoundException : public Exception
00085     {
00086       public:
00087         SourceNotFoundException ( const std::string & msg_r ) : Exception( msg_r ) {}
00088     };
00089     
00093     class SourceUnknownTypeException : public Exception
00094     {
00095       public:
00096         SourceUnknownTypeException ( const std::string & msg_r ) : Exception( msg_r ) {}
00097     };
00098   }
00099   class ResStore;
00100 
00102   //
00103   //    CLASS NAME : Source
00104   //
00109   class Source_Ref : protected base::SafeBool<Source_Ref> /* private, but gcc refuses */
00110   {
00111     friend std::ostream & operator<<( std::ostream & str, const Source_Ref & obj );
00112     friend bool operator==( const Source_Ref & lhs, const Source_Ref & rhs );
00113     friend bool operator<( const Source_Ref & lhs, const Source_Ref & rhs );
00114 
00115   public:
00116     typedef source::SourceImpl     Impl;
00117     typedef source::SourceImpl_Ptr Impl_Ptr;
00118 
00119   public:
00120 
00124     Source_Ref();
00125 
00129     static const Source_Ref noSource;
00130 
00134     using base::SafeBool<Source_Ref>::operator bool_type;
00135 
00136   public:
00137     typedef unsigned long NumericId;
00138 
00140     NumericId numericId() const;
00141 
00142   public:
00143 
00151     std::string checksum() const;
00152     
00158     Date timestamp() const;
00159     
00164     bool hasResolvablesOfKind( const zypp::Resolvable::Kind &kind ) const;
00165     
00169     std::set<zypp::Resolvable::Kind> resolvableKinds() const;
00170     
00175     bool resStoreInitialized() const;
00176 
00178     const ResStore & resolvables() const;
00179 
00181     const ResStore resolvables(zypp::Resolvable::Kind kind) const;
00182 
00183     const Pathname providePackage( Package::constPtr package );
00184     
00186     const Pathname provideFile(const Pathname & file_r, const unsigned media_nr = 1);
00187     const Pathname provideDirTree(const Pathname & dir_r, const unsigned media_nr = 1);
00188                               
00189     const void releaseFile(const Pathname & file_r, const unsigned media_nr = 1);
00190     const void releaseDir(const Pathname & dir_r, const unsigned media_nr = 1, bool recursive = false);
00191 
00192     bool enabled() const;
00193 
00194     void enable();
00195 
00196     void disable();
00197 
00198     bool autorefresh() const;
00199     void setAutorefresh( bool enable_r );
00200     void refresh();
00201 
00202     void storeMetadata(const Pathname & cache_dir_r);
00203 
00207     std::string alias (void) const;
00211     void setAlias (const std::string & alias_r);
00212 
00216     std::string type (void) const;
00217 
00218     unsigned numberOfMedia(void) const;
00219 
00221     std::string vendor (void) const;
00223     std::string unique_id (void) const;
00224 
00226 
00227 
00228     std::string id (void) const;
00229     void setId (const std::string id_r);
00230     unsigned priority (void) const;
00231     void setPriority (unsigned p);
00232     unsigned priorityUnsubscribed (void) const;
00233     void setPriorityUnsubscribed (unsigned p);
00234     bool subscribed (void) const;
00235     void setSubscribed (bool s);
00236     const Pathname & cacheDir (void) const;
00237     const std::list<Pathname> publicKeys();
00239 
00241 
00242     std::string zmdName (void) const;
00243     void setZmdName (const std::string name_r);
00244     std::string zmdDescription (void) const;
00245     void setZmdDescription (const std::string desc_r);
00247 
00249 
00250     Url url (void) const;
00255     void setUrl( const Url & url );
00256     bool remote() const;
00257     const Pathname & path (void) const;
00258     bool baseSource() const;
00260 
00261   public:
00266     void changeMedia(const media::MediaId & media_r, const Pathname & path_r);
00267 
00271     void redirect(unsigned media_nr, const Url & new_url);
00272 
00276     void release();
00277 
00284     void reattach(const Pathname &attach_point);
00285 
00289     media::MediaVerifierRef verifier(unsigned media_nr);
00290 
00291   private:
00292     friend base::SafeBool<Source_Ref>::operator bool_type() const;
00294     bool boolTest() const
00295     { return _pimpl != noSource._pimpl; }
00296 
00297   private:
00299     friend class SourceFactory;
00300     friend class source::SourceImpl;
00301 
00302   private:
00304     explicit
00305     Source_Ref( const Impl_Ptr & impl_r );
00306 
00307   private:
00309     Impl_Ptr _pimpl;
00310   };
00312 
00314   std::ostream & operator<<( std::ostream & str, const Source_Ref & obj );
00315 
00317   inline bool operator==( const Source_Ref & lhs, const Source_Ref & rhs )
00318   { return lhs._pimpl == rhs._pimpl; }
00319 
00321   inline bool operator!=( const Source_Ref & lhs, const Source_Ref & rhs )
00322   { return ! (lhs == rhs); }
00323 
00325   inline bool operator<( const Source_Ref & lhs, const Source_Ref & rhs )
00326   { return lhs._pimpl < rhs._pimpl; }
00327 
00329 } // namespace zypp
00331 #endif // ZYPP_SOURCE_H

Generated on Tue Nov 28 16:49:32 2006 for zypp by  doxygen 1.5.0