00001
00002
00003
00004
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
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
00055
00060 class Source_Ref : protected base::SafeBool<Source_Ref>
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
00100 Date timestamp() const;
00101
00106 bool resStoreInitialized() const;
00107
00109 const ResStore & resolvables() const;
00110
00112 const ResStore resolvables(zypp::Resolvable::Kind kind) const;
00113
00114 const Pathname providePackage( Package::constPtr package );
00115
00117 const Pathname provideFile(const Pathname & file_r,
00118 const unsigned media_nr = 1);
00119 const Pathname provideDirTree(const Pathname & dir_r,
00120 const unsigned media_nr = 1);
00121
00122 const void releaseFile(const Pathname & file_r,
00123 const unsigned media_nr = 1);
00124 const void releaseDir(const Pathname & dir_r,
00125 const unsigned media_nr = 1,
00126 const bool recursive = false);
00127
00128 const bool enabled() const;
00129
00130 void enable();
00131
00132 void disable();
00133
00134 const bool autorefresh() const;
00135 void setAutorefresh( const bool enable_r );
00136 void refresh();
00137
00138 void storeMetadata(const Pathname & cache_dir_r);
00139
00141 std::string alias (void) const;
00142 void setAlias (const std::string & alias_r);
00143
00145 std::string type (void) const;
00146
00147 unsigned numberOfMedia(void) const;
00148
00150 std::string vendor (void) const;
00152 std::string unique_id (void) const;
00153
00155
00156
00157 std::string id (void) const;
00158 void setId (const std::string id_r);
00159 unsigned priority (void) const;
00160 void setPriority (unsigned p);
00161 unsigned priorityUnsubscribed (void) const;
00162 void setPriorityUnsubscribed (unsigned p);
00163 bool subscribed (void) const;
00164 void setSubscribed (bool s);
00165 const Pathname & cacheDir (void) const;
00166 const std::list<Pathname> publicKeys();
00168
00170
00171 std::string zmdName (void) const;
00172 void setZmdName (const std::string name_r);
00173 std::string zmdDescription (void) const;
00174 void setZmdDescription (const std::string desc_r);
00176
00178
00179 Url url (void) const;
00184 void setUrl( const Url & url );
00185 bool remote() const;
00186 const Pathname & path (void) const;
00187 const bool baseSource() const;
00189
00190 public:
00195 void changeMedia(const media::MediaId & media_r, const Pathname & path_r);
00196
00200 void redirect(unsigned media_nr, const Url & new_url);
00201
00205 void release();
00206
00213 void reattach(const Pathname &attach_point);
00214
00218 media::MediaVerifierRef verifier(unsigned media_nr);
00219
00220 private:
00221 friend base::SafeBool<Source_Ref>::operator bool_type() const;
00223 bool boolTest() const
00224 { return _pimpl != noSource._pimpl; }
00225
00226 private:
00228 friend class SourceFactory;
00229 friend class source::SourceImpl;
00230
00231 private:
00233 explicit
00234 Source_Ref( const Impl_Ptr & impl_r );
00235
00236 private:
00238 Impl_Ptr _pimpl;
00239 };
00241
00243 std::ostream & operator<<( std::ostream & str, const Source_Ref & obj );
00244
00246 inline bool operator==( const Source_Ref & lhs, const Source_Ref & rhs )
00247 { return lhs._pimpl == rhs._pimpl; }
00248
00250 inline bool operator!=( const Source_Ref & lhs, const Source_Ref & rhs )
00251 { return ! (lhs == rhs); }
00252
00254 inline bool operator<( const Source_Ref & lhs, const Source_Ref & rhs )
00255 { return lhs._pimpl < rhs._pimpl; }
00256
00258 }
00260 #endif // ZYPP_SOURCE_H