1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoInfo.cc
14 #include "zypp/base/Logger.h"
16 #include "zypp/RepoInfo.h"
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 // CLASS NAME : RepoInfo::Impl
28 /** RepoInfo implementation. */
36 type(repo::RepoType::NONE_e)
50 std::set<Url> baseUrls;
55 Pathname metadatapath;
59 friend Impl * rwcowClone<Impl>( const Impl * rhs );
60 /** clone for RWCOW_pointer */
62 { return new Impl( *this ); }
64 ///////////////////////////////////////////////////////////////////
66 /** \relates RepoInfo::Impl Stream output */
67 inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
69 return str << "RepoInfo::Impl";
72 ///////////////////////////////////////////////////////////////////
74 // CLASS NAME : RepoInfo
76 ///////////////////////////////////////////////////////////////////
78 ///////////////////////////////////////////////////////////////////
80 // METHOD NAME : RepoInfo::RepoInfo
84 : _pimpl( new Impl() )
87 ///////////////////////////////////////////////////////////////////
89 // METHOD NAME : RepoInfo::~RepoInfo
97 RepoInfo & RepoInfo::setEnabled( bool enabled )
99 _pimpl->enabled = enabled;
103 RepoInfo & RepoInfo::setAutorefresh( bool autorefresh )
105 _pimpl->autorefresh = autorefresh;
109 RepoInfo & RepoInfo::setGpgCheck( bool check )
111 _pimpl->gpgcheck = check;
115 RepoInfo & RepoInfo::setMirrorListUrl( const Url &url )
117 _pimpl->mirrorlist_url = url;
121 RepoInfo & RepoInfo::setGpgKeyUrl( const Url &url )
123 _pimpl->gpgkey_url = url;
127 RepoInfo & RepoInfo::addBaseUrl( const Url &url )
129 _pimpl->baseUrls.insert(url);
133 RepoInfo & RepoInfo::setBaseUrl( const Url &url )
135 _pimpl->baseUrls.clear();
140 RepoInfo & RepoInfo::setPath( const Pathname &path )
146 RepoInfo & RepoInfo::setAlias( const std::string &alias )
148 _pimpl->alias = alias;
152 RepoInfo & RepoInfo::setType( const repo::RepoType &t )
158 RepoInfo & RepoInfo::setName( const std::string &name )
164 RepoInfo & RepoInfo::setFilepath( const Pathname &filepath )
166 _pimpl->filepath = filepath;
170 RepoInfo & RepoInfo::setMetadataPath( const Pathname &path )
172 _pimpl->metadatapath = path;
176 bool RepoInfo::enabled() const
177 { return _pimpl->enabled; }
179 bool RepoInfo::autorefresh() const
180 { return _pimpl->autorefresh; }
182 bool RepoInfo::gpgCheck() const
183 { return _pimpl->gpgcheck; }
185 std::string RepoInfo::alias() const
186 { return _pimpl->alias; }
188 std::string RepoInfo::name() const
189 { return _pimpl->name; }
191 Pathname RepoInfo::filepath() const
192 { return _pimpl->filepath; }
194 Pathname RepoInfo::metadataPath() const
195 { return _pimpl->metadatapath; }
197 repo::RepoType RepoInfo::type() const
198 { return _pimpl->type; }
200 Url RepoInfo::mirrorListUrl() const
201 { return _pimpl->mirrorlist_url; }
203 Url RepoInfo::gpgKeyUrl() const
204 { return _pimpl->gpgkey_url; }
206 std::set<Url> RepoInfo::baseUrls() const
207 { return _pimpl->baseUrls; }
209 Pathname RepoInfo::path() const
210 { return _pimpl->path; }
212 RepoInfo::urls_const_iterator RepoInfo::baseUrlsBegin() const
214 return make_transform_iterator( _pimpl->baseUrls.begin(),
215 repo::RepoVariablesUrlReplacer() );
216 //return _pimpl->baseUrls.begin();
219 RepoInfo::urls_const_iterator RepoInfo::baseUrlsEnd() const
221 //return _pimpl->baseUrls.end();
222 return make_transform_iterator( _pimpl->baseUrls.end(),
223 repo::RepoVariablesUrlReplacer() );
226 RepoInfo::urls_size_type RepoInfo::baseUrlsSize() const
227 { return _pimpl->baseUrls.size(); }
229 bool RepoInfo::baseUrlsEmpty() const
230 { return _pimpl->baseUrls.empty(); }
232 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
234 str << "--------------------------------------" << std::endl;
235 str << "- alias : " << alias() << std::endl;
236 std::set<Url> url_set(baseUrls());
237 for ( std::set<Url>::const_iterator it = url_set.begin();
241 str << "- url : " << *it << std::endl;
243 str << "- path : " << path() << std::endl;
244 str << "- type : " << type() << std::endl;
245 str << "- enabled : " << enabled() << std::endl;
247 str << "- autorefresh : " << autorefresh() << std::endl;
248 str << "- gpgcheck : " << gpgCheck() << std::endl;
249 str << "- gpgkey : " << gpgKeyUrl() << std::endl;
254 std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const
256 str << "[" << alias() << "]" << endl;
257 str << "name=" << name() << endl;
259 if ( ! baseUrls().empty() )
261 for ( urls_const_iterator it = baseUrlsBegin();
268 if ( ! path().empty() )
269 str << "path="<< path() << endl;
271 if ( ! (mirrorListUrl().asString().empty()) )
272 str << "mirrorlist=" << mirrorListUrl() << endl;
274 str << "type=" << type().asString() << endl;
275 str << "enabled=" << (enabled() ? "1" : "0") << endl;
276 str << "autorefresh=" << (autorefresh() ? "1" : "0") << endl;
277 str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
278 if ( ! (gpgKeyUrl().asString().empty()) )
279 str << "gpgkey=" <<gpgKeyUrl() << endl;
284 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
286 return obj.dumpOn(str);
289 /////////////////////////////////////////////////////////////////
291 ///////////////////////////////////////////////////////////////////