1838d6519d4e879698ca6b57c9b9af90a54276af
[platform/upstream/libzypp.git] / zypp2 / RepoInfo.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/RepoInfo.cc
10  *
11 */
12 #include <iostream>
13 #include "zypp/base/Logger.h"
14
15 #include "zypp2/RepoInfo.h"
16
17 using namespace std;
18 using namespace boost;
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   ///////////////////////////////////////////////////////////////////
25   //
26   //    CLASS NAME : RepoInfo::Impl
27   //
28   /** RepoInfo implementation. */
29   struct RepoInfo::Impl
30   {
31     
32     Impl()
33       : enabled (indeterminate),
34         autorefresh(indeterminate)
35     {}
36   public:
37     boost::tribool enabled;
38     boost::tribool autorefresh;
39     std::string type;
40     Url baseurl;
41     std::set<Url> urls;
42     Pathname path;
43     std::string alias;
44     std::string name;
45     CheckSum checksum;
46     Date timestamp;
47
48   public:
49     /** Offer default Impl. */
50     static shared_ptr<Impl> nullimpl()
51     {
52       static shared_ptr<Impl> _nullimpl( new Impl );
53       return _nullimpl;
54     }
55
56   private:
57     friend Impl * rwcowClone<Impl>( const Impl * rhs );
58     /** clone for RWCOW_pointer */
59     Impl * clone() const
60     { return new Impl( *this ); }
61   };
62   ///////////////////////////////////////////////////////////////////
63
64   /** \relates RepoInfo::Impl Stream output */
65   inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
66   {
67     return str << "RepoInfo::Impl";
68   }
69
70   ///////////////////////////////////////////////////////////////////
71   //
72   //    CLASS NAME : RepoInfo
73   //
74   ///////////////////////////////////////////////////////////////////
75
76   ///////////////////////////////////////////////////////////////////
77   //
78   //    METHOD NAME : RepoInfo::RepoInfo
79   //    METHOD TYPE : Ctor
80   //
81   RepoInfo::RepoInfo()
82   : _pimpl( Impl::nullimpl() )
83   {}
84
85   ///////////////////////////////////////////////////////////////////
86   //
87   //    METHOD NAME : RepoInfo::~RepoInfo
88   //    METHOD TYPE : Dtor
89   //
90   RepoInfo::~RepoInfo()
91   {}
92
93   
94   
95   RepoInfo & RepoInfo::setEnabled( boost::tribool enabled )
96   {
97     _pimpl->enabled = enabled;
98     return *this;
99   }
100
101   RepoInfo & RepoInfo::setAutorefresh( boost::tribool autorefresh )
102   {
103     _pimpl->autorefresh = autorefresh;
104     return *this;
105   }
106
107   RepoInfo & RepoInfo::setBaseUrl( const Url &url )
108   {
109     _pimpl->baseurl = url;
110     return *this;
111   }
112
113   RepoInfo & RepoInfo::setPath( const Pathname &p )
114   {
115     _pimpl->path = p;
116     return *this;
117   }
118
119   RepoInfo & RepoInfo::setAlias( const std::string &alias )
120   {
121     _pimpl->alias = alias;
122     return *this;
123   }
124
125   RepoInfo & RepoInfo::setType( const std::string &t )
126   {
127     _pimpl->type = t;
128     return *this;
129   }
130
131   RepoInfo & RepoInfo::setName( const std::string &name )
132   {
133     _pimpl->name = name;
134     return *this;
135   }
136
137   RepoInfo & RepoInfo::setChecksum( const CheckSum &checksum )
138   {
139     _pimpl->checksum = checksum;
140     return *this;
141   }
142
143   RepoInfo & RepoInfo::setTimestamp( const Date &timestamp )
144   {
145     _pimpl->timestamp = timestamp;
146     return *this;
147   }
148
149   tribool RepoInfo::enabled() const
150   { return _pimpl->enabled; }
151
152   tribool RepoInfo::autorefresh() const
153   { return _pimpl->autorefresh; }
154
155   
156   Pathname RepoInfo::path() const
157   { return _pimpl->path; }
158
159   std::string RepoInfo::alias() const
160   { return _pimpl->alias; }
161
162   std::string RepoInfo::name() const
163   { return _pimpl->name; }
164
165   CheckSum RepoInfo::checksum() const
166   { return _pimpl->checksum; }
167
168   Date RepoInfo::timestamp() const
169   { return _pimpl->timestamp; }
170
171   std::string RepoInfo::type() const
172   { return _pimpl->type; }
173
174   Url RepoInfo::baseUrl() const
175   { return _pimpl->baseurl; }
176
177   std::set<Url> RepoInfo::urls() const
178   { return _pimpl->urls; }
179     
180   RepoInfo::urls_const_iterator RepoInfo::urlsBegin() const
181   { return _pimpl->urls.begin(); }
182     
183   RepoInfo::urls_const_iterator RepoInfo::urlsEnd() const
184   { return _pimpl->urls.end(); }
185   
186   std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
187   {
188     str << "--------------------------------------" << std::endl;
189     str << "- alias       : " << alias() << std::endl;
190     str << "- url         : " << baseUrl() << std::endl;
191     str << "- type        : " << type() << std::endl;
192     str << "- enabled     : " << enabled() << std::endl;
193     str << "- autorefresh : " << autorefresh() << std::endl;
194     str << "- path        : " << path() << std::endl;
195     return str;
196   }
197
198   /////////////////////////////////////////////////////////////////
199 } // namespace zypp2
200 ///////////////////////////////////////////////////////////////////