1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoInfo.cc
13 #include "zypp/base/Logger.h"
15 #include "zypp/RepoInfo.h"
18 using namespace boost;
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 // CLASS NAME : RepoInfo::Impl
28 /** RepoInfo implementation. */
33 : enabled (indeterminate),
34 autorefresh(indeterminate),
35 gpgcheck(indeterminate),
36 type(repo::RepoType::NONE_e)
44 boost::tribool enabled;
45 boost::tribool autorefresh;
46 boost::tribool gpgcheck;
50 std::set<Url> baseUrls;
58 friend Impl * rwcowClone<Impl>( const Impl * rhs );
59 /** clone for RWCOW_pointer */
61 { return new Impl( *this ); }
63 ///////////////////////////////////////////////////////////////////
65 /** \relates RepoInfo::Impl Stream output */
66 inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
68 return str << "RepoInfo::Impl";
71 ///////////////////////////////////////////////////////////////////
73 // CLASS NAME : RepoInfo
75 ///////////////////////////////////////////////////////////////////
77 ///////////////////////////////////////////////////////////////////
79 // METHOD NAME : RepoInfo::RepoInfo
83 : _pimpl( new Impl() )
86 ///////////////////////////////////////////////////////////////////
88 // METHOD NAME : RepoInfo::~RepoInfo
96 RepoInfo & RepoInfo::setEnabled( boost::tribool enabled )
98 _pimpl->enabled = enabled;
102 RepoInfo & RepoInfo::setAutorefresh( boost::tribool autorefresh )
104 _pimpl->autorefresh = autorefresh;
108 RepoInfo & RepoInfo::setGpgCheck( boost::tribool check )
110 _pimpl->gpgcheck = check;
114 RepoInfo & RepoInfo::setMirrorListUrl( const Url &url )
116 _pimpl->mirrorlist_url = url;
120 RepoInfo & RepoInfo::setGpgKeyUrl( const Url &url )
122 _pimpl->gpgkey_url = url;
126 RepoInfo & RepoInfo::addBaseUrl( const Url &url )
128 _pimpl->baseUrls.insert(url);
132 RepoInfo & RepoInfo::setBaseUrl( const Url &url )
134 _pimpl->baseUrls.clear();
139 RepoInfo & RepoInfo::setPath( const Pathname &path )
145 RepoInfo & RepoInfo::setAlias( const std::string &alias )
147 _pimpl->alias = alias;
151 RepoInfo & RepoInfo::setType( const repo::RepoType &t )
157 RepoInfo & RepoInfo::setName( const std::string &name )
163 RepoInfo & RepoInfo::setFilepath( const Pathname &filepath )
165 _pimpl->filepath = filepath;
169 tribool RepoInfo::enabled() const
170 { return _pimpl->enabled; }
172 tribool RepoInfo::autorefresh() const
173 { return _pimpl->autorefresh; }
175 tribool RepoInfo::gpgCheck() const
176 { return _pimpl->gpgcheck; }
178 std::string RepoInfo::alias() const
179 { return _pimpl->alias; }
181 std::string RepoInfo::name() const
182 { return _pimpl->name; }
184 Pathname RepoInfo::filepath() const
185 { return _pimpl->filepath; }
187 repo::RepoType RepoInfo::type() const
188 { return _pimpl->type; }
190 Url RepoInfo::mirrorListUrl() const
191 { return _pimpl->mirrorlist_url; }
193 Url RepoInfo::gpgKeyUrl() const
194 { return _pimpl->gpgkey_url; }
196 std::set<Url> RepoInfo::baseUrls() const
197 { return _pimpl->baseUrls; }
199 Pathname RepoInfo::path() const
200 { return _pimpl->path; }
202 RepoInfo::urls_const_iterator RepoInfo::baseUrlsBegin() const
203 { return _pimpl->baseUrls.begin(); }
205 RepoInfo::urls_const_iterator RepoInfo::baseUrlsEnd() const
206 { return _pimpl->baseUrls.end(); }
208 RepoInfo::urls_size_type RepoInfo::baseUrlsSize() const
209 { return _pimpl->baseUrls.size(); }
211 bool RepoInfo::baseUrlsEmpty() const
212 { return _pimpl->baseUrls.empty(); }
214 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
216 str << "--------------------------------------" << std::endl;
217 str << "- alias : " << alias() << std::endl;
218 std::set<Url> url_set(baseUrls());
219 for ( std::set<Url>::const_iterator it = url_set.begin();
223 str << "- url : " << *it << std::endl;
225 str << "- path : " << path() << std::endl;
226 str << "- type : " << type() << std::endl;
227 str << "- enabled : " << enabled() << std::endl;
229 str << "- autorefresh : " << autorefresh() << std::endl;
230 str << "- gpgcheck : " << gpgCheck() << std::endl;
231 str << "- gpgkey : " << gpgKeyUrl() << std::endl;
236 std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const
238 str << "[" << alias() << "]" << endl;
239 str << "name=" << name() << endl;
241 if ( ! baseUrls().empty() )
243 for ( urls_const_iterator it = baseUrlsBegin();
250 if ( ! path().empty() )
251 str << "path="<< path() << endl;
253 if ( ! (mirrorListUrl().asString().empty()) )
254 str << "mirrorlist=" << mirrorListUrl() << endl;
256 str << "type=" << type().asString() << endl;
258 if ( ! indeterminate(enabled()) )
259 str << "enabled=" << (enabled() ? "1" : "0") << endl;
260 if ( ! indeterminate(autorefresh()) )
261 str << "autorefresh=" << (autorefresh() ? "1" : "0") << endl;
262 if ( ! indeterminate(gpgCheck()) )
263 str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
264 if ( ! (gpgKeyUrl().asString().empty()) )
265 str << "gpgkey=" <<gpgKeyUrl() << endl;
270 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
272 return obj.dumpOn(str);
275 /////////////////////////////////////////////////////////////////
277 ///////////////////////////////////////////////////////////////////