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 type(repo::RepoType::NONE_e)
43 boost::tribool enabled;
44 boost::tribool autorefresh;
45 boost::tribool gpgcheck;
49 std::set<Url> baseUrls;
57 friend Impl * rwcowClone<Impl>( const Impl * rhs );
58 /** clone for RWCOW_pointer */
60 { return new Impl( *this ); }
62 ///////////////////////////////////////////////////////////////////
64 /** \relates RepoInfo::Impl Stream output */
65 inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
67 return str << "RepoInfo::Impl";
70 ///////////////////////////////////////////////////////////////////
72 // CLASS NAME : RepoInfo
74 ///////////////////////////////////////////////////////////////////
76 ///////////////////////////////////////////////////////////////////
78 // METHOD NAME : RepoInfo::RepoInfo
82 : _pimpl( new Impl() )
85 ///////////////////////////////////////////////////////////////////
87 // METHOD NAME : RepoInfo::~RepoInfo
95 RepoInfo & RepoInfo::setEnabled( boost::tribool enabled )
97 _pimpl->enabled = enabled;
101 RepoInfo & RepoInfo::setAutorefresh( boost::tribool autorefresh )
103 _pimpl->autorefresh = autorefresh;
107 RepoInfo & RepoInfo::setGpgCheck( boost::tribool check )
109 _pimpl->gpgcheck = check;
113 RepoInfo & RepoInfo::setMirrorListUrl( const Url &url )
115 _pimpl->mirrorlist_url = url;
119 RepoInfo & RepoInfo::setGpgKeyUrl( const Url &url )
121 _pimpl->gpgkey_url = url;
125 RepoInfo & RepoInfo::addBaseUrl( const Url &url )
127 _pimpl->baseUrls.insert(url);
131 RepoInfo & RepoInfo::setBaseUrl( const Url &url )
133 _pimpl->baseUrls.clear();
138 RepoInfo & RepoInfo::setPath( const Pathname &path )
144 RepoInfo & RepoInfo::setAlias( const std::string &alias )
146 _pimpl->alias = alias;
150 RepoInfo & RepoInfo::setType( const repo::RepoType &t )
156 RepoInfo & RepoInfo::setName( const std::string &name )
162 RepoInfo & RepoInfo::setFilepath( const Pathname &filepath )
164 _pimpl->filepath = filepath;
168 tribool RepoInfo::enabled() const
169 { return _pimpl->enabled; }
171 tribool RepoInfo::autorefresh() const
172 { return _pimpl->autorefresh; }
174 tribool RepoInfo::gpgCheck() const
175 { return _pimpl->gpgcheck; }
177 std::string RepoInfo::alias() const
178 { return _pimpl->alias; }
180 std::string RepoInfo::name() const
181 { return _pimpl->name; }
183 Pathname RepoInfo::filepath() const
184 { return _pimpl->filepath; }
186 repo::RepoType RepoInfo::type() const
187 { return _pimpl->type; }
189 Url RepoInfo::mirrorListUrl() const
190 { return _pimpl->mirrorlist_url; }
192 Url RepoInfo::gpgKeyUrl() const
193 { return _pimpl->gpgkey_url; }
195 std::set<Url> RepoInfo::baseUrls() const
196 { return _pimpl->baseUrls; }
198 Pathname RepoInfo::path() const
199 { return _pimpl->path; }
201 RepoInfo::urls_const_iterator RepoInfo::baseUrlsBegin() const
202 { return _pimpl->baseUrls.begin(); }
204 RepoInfo::urls_const_iterator RepoInfo::baseUrlsEnd() const
205 { return _pimpl->baseUrls.end(); }
207 RepoInfo::urls_size_type RepoInfo::baseUrlsSize() const
208 { return _pimpl->baseUrls.size(); }
210 bool RepoInfo::baseUrlsEmpty() const
211 { return _pimpl->baseUrls.empty(); }
213 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
215 str << "--------------------------------------" << std::endl;
216 str << "- alias : " << alias() << std::endl;
217 std::set<Url> url_set(baseUrls());
218 for ( std::set<Url>::const_iterator it = url_set.begin();
222 str << "- url : " << *it << std::endl;
224 str << "- path : " << path() << std::endl;
225 str << "- type : " << type() << std::endl;
226 str << "- enabled : " << enabled() << std::endl;
228 str << "- autorefresh : " << autorefresh() << std::endl;
229 str << "- gpgcheck : " << gpgCheck() << std::endl;
230 str << "- gpgkey : " << gpgKeyUrl() << std::endl;
235 std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const
237 str << "[" << alias() << "]" << endl;
238 str << "name=" << name() << endl;
240 if ( ! baseUrls().empty() )
242 for ( urls_const_iterator it = baseUrlsBegin();
249 if ( ! path().empty() )
250 str << "path="<< path() << endl;
252 if ( ! (mirrorListUrl().asString().empty()) )
253 str << "mirrorlist=" << mirrorListUrl() << endl;
255 str << "type=" << type().asString() << endl;
257 if ( enabled() != indeterminate )
258 str << "enabled=" << (enabled() ? "1" : "0") << endl;
259 if ( autorefresh() != indeterminate )
260 str << "autorefresh=" << (autorefresh() ? "1" : "0") << endl;
261 if ( autorefresh() != indeterminate )
262 str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
263 if ( ! (gpgKeyUrl().asString().empty()) )
264 str << "gpgkey=" <<gpgKeyUrl() << endl;
269 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
271 return obj.dumpOn(str);
274 /////////////////////////////////////////////////////////////////
276 ///////////////////////////////////////////////////////////////////