1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoInfo.cc
13 #include <boost/logic/tribool_io.hpp>
15 #include "zypp/base/Logger.h"
17 #include "zypp/RepoInfo.h"
20 using namespace boost;
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
28 // CLASS NAME : RepoInfo::Impl
30 /** RepoInfo implementation. */
35 : enabled (indeterminate),
36 autorefresh(indeterminate),
37 gpgcheck(indeterminate),
38 type(repo::RepoType::NONE_e)
46 boost::tribool enabled;
47 boost::tribool autorefresh;
48 boost::tribool gpgcheck;
52 std::set<Url> baseUrls;
57 Pathname metadatapath;
61 friend Impl * rwcowClone<Impl>( const Impl * rhs );
62 /** clone for RWCOW_pointer */
64 { return new Impl( *this ); }
66 ///////////////////////////////////////////////////////////////////
68 /** \relates RepoInfo::Impl Stream output */
69 inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
71 return str << "RepoInfo::Impl";
74 ///////////////////////////////////////////////////////////////////
76 // CLASS NAME : RepoInfo
78 ///////////////////////////////////////////////////////////////////
80 ///////////////////////////////////////////////////////////////////
82 // METHOD NAME : RepoInfo::RepoInfo
86 : _pimpl( new Impl() )
89 ///////////////////////////////////////////////////////////////////
91 // METHOD NAME : RepoInfo::~RepoInfo
99 RepoInfo & RepoInfo::setEnabled( boost::tribool enabled )
101 _pimpl->enabled = enabled;
105 RepoInfo & RepoInfo::setAutorefresh( boost::tribool autorefresh )
107 _pimpl->autorefresh = autorefresh;
111 RepoInfo & RepoInfo::setGpgCheck( boost::tribool check )
113 _pimpl->gpgcheck = check;
117 RepoInfo & RepoInfo::setMirrorListUrl( const Url &url )
119 _pimpl->mirrorlist_url = url;
123 RepoInfo & RepoInfo::setGpgKeyUrl( const Url &url )
125 _pimpl->gpgkey_url = url;
129 RepoInfo & RepoInfo::addBaseUrl( const Url &url )
131 _pimpl->baseUrls.insert(url);
135 RepoInfo & RepoInfo::setBaseUrl( const Url &url )
137 _pimpl->baseUrls.clear();
142 RepoInfo & RepoInfo::setPath( const Pathname &path )
148 RepoInfo & RepoInfo::setAlias( const std::string &alias )
150 _pimpl->alias = alias;
154 RepoInfo & RepoInfo::setType( const repo::RepoType &t )
160 RepoInfo & RepoInfo::setName( const std::string &name )
166 RepoInfo & RepoInfo::setFilepath( const Pathname &filepath )
168 _pimpl->filepath = filepath;
172 RepoInfo & RepoInfo::setMetadataPath( const Pathname &path )
174 _pimpl->metadatapath = path;
178 tribool RepoInfo::enabled() const
179 { return _pimpl->enabled; }
181 tribool RepoInfo::autorefresh() const
182 { return _pimpl->autorefresh; }
184 tribool RepoInfo::gpgCheck() const
185 { return _pimpl->gpgcheck; }
187 std::string RepoInfo::alias() const
188 { return _pimpl->alias; }
190 std::string RepoInfo::name() const
191 { return _pimpl->name; }
193 Pathname RepoInfo::filepath() const
194 { return _pimpl->filepath; }
196 Pathname RepoInfo::metadataPath() const
197 { return _pimpl->metadatapath; }
199 repo::RepoType RepoInfo::type() const
200 { return _pimpl->type; }
202 Url RepoInfo::mirrorListUrl() const
203 { return _pimpl->mirrorlist_url; }
205 Url RepoInfo::gpgKeyUrl() const
206 { return _pimpl->gpgkey_url; }
208 std::set<Url> RepoInfo::baseUrls() const
209 { return _pimpl->baseUrls; }
211 Pathname RepoInfo::path() const
212 { return _pimpl->path; }
214 RepoInfo::urls_const_iterator RepoInfo::baseUrlsBegin() const
215 { return _pimpl->baseUrls.begin(); }
217 RepoInfo::urls_const_iterator RepoInfo::baseUrlsEnd() const
218 { return _pimpl->baseUrls.end(); }
220 RepoInfo::urls_size_type RepoInfo::baseUrlsSize() const
221 { return _pimpl->baseUrls.size(); }
223 bool RepoInfo::baseUrlsEmpty() const
224 { return _pimpl->baseUrls.empty(); }
226 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
228 str << "--------------------------------------" << std::endl;
229 str << "- alias : " << alias() << std::endl;
230 std::set<Url> url_set(baseUrls());
231 for ( std::set<Url>::const_iterator it = url_set.begin();
235 str << "- url : " << *it << std::endl;
237 str << "- path : " << path() << std::endl;
238 str << "- type : " << type() << std::endl;
239 str << "- enabled : " << enabled() << std::endl;
241 str << "- autorefresh : " << autorefresh() << std::endl;
242 str << "- gpgcheck : " << gpgCheck() << std::endl;
243 str << "- gpgkey : " << gpgKeyUrl() << std::endl;
248 std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const
250 str << "[" << alias() << "]" << endl;
251 str << "name=" << name() << endl;
253 if ( ! baseUrls().empty() )
255 for ( urls_const_iterator it = baseUrlsBegin();
262 if ( ! path().empty() )
263 str << "path="<< path() << endl;
265 if ( ! (mirrorListUrl().asString().empty()) )
266 str << "mirrorlist=" << mirrorListUrl() << endl;
268 str << "type=" << type().asString() << endl;
270 if ( ! indeterminate(enabled()) )
271 str << "enabled=" << (enabled() ? "1" : "0") << endl;
272 if ( ! indeterminate(autorefresh()) )
273 str << "autorefresh=" << (autorefresh() ? "1" : "0") << endl;
274 if ( ! indeterminate(gpgCheck()) )
275 str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
276 if ( ! (gpgKeyUrl().asString().empty()) )
277 str << "gpgkey=" <<gpgKeyUrl() << endl;
282 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
284 return obj.dumpOn(str);
287 /////////////////////////////////////////////////////////////////
289 ///////////////////////////////////////////////////////////////////