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;
47 std::set<Url> baseUrls;
54 friend Impl * rwcowClone<Impl>( const Impl * rhs );
55 /** clone for RWCOW_pointer */
57 { return new Impl( *this ); }
59 ///////////////////////////////////////////////////////////////////
61 /** \relates RepoInfo::Impl Stream output */
62 inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
64 return str << "RepoInfo::Impl";
67 ///////////////////////////////////////////////////////////////////
69 // CLASS NAME : RepoInfo
71 ///////////////////////////////////////////////////////////////////
73 ///////////////////////////////////////////////////////////////////
75 // METHOD NAME : RepoInfo::RepoInfo
79 : _pimpl( new Impl() )
82 ///////////////////////////////////////////////////////////////////
84 // METHOD NAME : RepoInfo::~RepoInfo
94 RepoInfo & RepoInfo::setEnabled( boost::tribool enabled )
96 _pimpl->enabled = enabled;
100 RepoInfo & RepoInfo::setAutorefresh( boost::tribool autorefresh )
102 _pimpl->autorefresh = autorefresh;
106 RepoInfo & RepoInfo::setMirrorListUrl( const Url &url )
108 _pimpl->mirrorlist_url = url;
112 RepoInfo & RepoInfo::addBaseUrl( const Url &url )
114 _pimpl->baseUrls.insert(url);
118 RepoInfo & RepoInfo::setAlias( const std::string &alias )
120 _pimpl->alias = alias;
124 RepoInfo & RepoInfo::setType( const repo::RepoType &t )
130 RepoInfo & RepoInfo::setName( const std::string &name )
136 RepoInfo & RepoInfo::setFilepath( const Pathname &filepath )
138 _pimpl->filepath = filepath;
142 tribool RepoInfo::enabled() const
143 { return _pimpl->enabled; }
145 tribool RepoInfo::autorefresh() const
146 { return _pimpl->autorefresh; }
148 std::string RepoInfo::alias() const
149 { return _pimpl->alias; }
151 std::string RepoInfo::name() const
152 { return _pimpl->name; }
154 Pathname RepoInfo::filepath() const
155 { return _pimpl->filepath; }
157 repo::RepoType RepoInfo::type() const
158 { return _pimpl->type; }
160 Url RepoInfo::mirrorListUrl() const
161 { return _pimpl->mirrorlist_url; }
163 std::set<Url> RepoInfo::baseUrls() const
164 { return _pimpl->baseUrls; }
166 RepoInfo::urls_const_iterator RepoInfo::baseUrlsBegin() const
167 { return _pimpl->baseUrls.begin(); }
169 RepoInfo::urls_const_iterator RepoInfo::baseUrlsEnd() const
170 { return _pimpl->baseUrls.end(); }
172 std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
174 str << "--------------------------------------" << std::endl;
175 str << "- alias : " << alias() << std::endl;
176 std::set<Url> url_set(baseUrls());
177 for ( std::set<Url>::const_iterator it = url_set.begin();
181 str << "- url : " << *it << std::endl;
184 str << "- type : " << type() << std::endl;
185 str << "- enabled : " << enabled() << std::endl;
186 str << "- autorefresh : " << autorefresh() << std::endl;
187 //str << "- path : " << path() << std::endl;
191 std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const
193 str << "[" << alias() << "]" << endl;
194 str << "name = " << name() << endl;
196 if ( ! baseUrls().empty() )
198 for ( urls_const_iterator it = baseUrlsBegin();
204 str << "mirrorlist = " << mirrorListUrl() << endl;
205 str << "type = " << type().asString() << endl;
206 str << "enabled = " << (enabled() ? "1" : "0") << endl;
210 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
212 return obj.dumpOn(str);
215 /////////////////////////////////////////////////////////////////
217 ///////////////////////////////////////////////////////////////////