libzypp  13.10.6
Pool.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <iostream>
14 
15 #include "zypp/base/Easy.h"
16 #include "zypp/base/Logger.h"
17 #include "zypp/base/Gettext.h"
18 #include "zypp/base/Exception.h"
19 
20 #include "zypp/AutoDispose.h"
21 
23 #include "zypp/sat/Pool.h"
24 #include "zypp/sat/LookupAttr.h"
25 
27 namespace zypp
28 {
29  namespace sat
31  {
32 
33  const std::string & Pool::systemRepoAlias()
35 
36  ::_Pool * Pool::get() const
37  { return myPool().getPool(); }
38 
40  { return myPool()->nsolvables; }
41 
42  const SerialNumber & Pool::serial() const
43  { return myPool().serial(); }
44 
45  void Pool::prepare() const
46  { return myPool().prepare(); }
47 
49  { return myPool().prepareForSolving(); }
50 
51  bool Pool::reposEmpty() const
52  { return ! myPool()->urepos; }
53 
55  { return myPool()->urepos; }
56 
58  {
59  if ( myPool()->urepos )
60  { // repos[0] == NULL
61  for_( it, myPool()->repos+1, myPool()->repos+myPool()->nrepos )
62  if ( *it )
63  return RepositoryIterator( it );
64  }
65  return reposEnd();
66  }
67 
69  { return RepositoryIterator( myPool()->repos+myPool()->nrepos ); }
70 
71  bool Pool::solvablesEmpty() const
72  {
73  // return myPool()->nsolvables;
74  // nsolvables is the array size including
75  // invalid Solvables.
76  for_( it, reposBegin(), reposEnd() )
77  {
78  if ( ! it->solvablesEmpty() )
79  return false;
80  }
81  return true;
82  }
83 
85  {
86  // Do not return myPool()->nsolvables;
87  // nsolvables is the array size including
88  // invalid Solvables.
89  size_type ret = 0;
90  for_( it, reposBegin(), reposEnd() )
91  {
92  ret += it->solvablesSize();
93  }
94  return ret;
95  }
96 
98  { return SolvableIterator( myPool().getFirstId() ); }
99 
101  { return SolvableIterator(); }
102 
103  Repository Pool::reposInsert( const std::string & alias_r )
104  {
105  Repository ret( reposFind( alias_r ) );
106  if ( ret )
107  return ret;
108 
109  ret = Repository( myPool()._createRepo( alias_r ) );
110  if ( ret.isSystemRepo() )
111  {
112  // autoprovide (dummy) RepoInfo
113  RepoInfo info;
114  info.setAlias( alias_r );
115  info.setName( alias_r );
116  info.setAutorefresh( true );
117  info.setEnabled( true );
118  ret.setInfo( info );
119  }
120  return ret;
121  }
122 
123  Repository Pool::reposFind( const std::string & alias_r ) const
124  {
125  for_( it, reposBegin(), reposEnd() )
126  {
127  if ( alias_r == it->alias() )
128  return *it;
129  }
130  return Repository();
131  }
132 
134  {
135  return Repository( myPool().systemRepo() );
136  }
137 
139  {
140  if ( myPool().systemRepo() )
141  return Repository( myPool().systemRepo() );
142  return reposInsert( systemRepoAlias() );
143  }
144 
145  Repository Pool::addRepoSolv( const Pathname & file_r, const std::string & alias_r )
146  {
147  // Using a temporay repo! (The additional parenthesis are required.)
149  *tmprepo = reposInsert( alias_r );
150  tmprepo->addSolv( file_r );
151 
152  // no exceptions so we keep it:
153  tmprepo.resetDispose();
154  return tmprepo;
155  }
156 
157  Repository Pool::addRepoSolv( const Pathname & file_r )
158  { return addRepoSolv( file_r, file_r.basename() ); }
159 
160  Repository Pool::addRepoSolv( const Pathname & file_r, const RepoInfo & info_r )
161  {
162  Repository ret( addRepoSolv( file_r, info_r.alias() ) );
163  ret.setInfo( info_r );
164  return ret;
165  }
166 
168 
169  Repository Pool::addRepoHelix( const Pathname & file_r, const std::string & alias_r )
170  {
171  // Using a temporay repo! (The additional parenthesis are required.)
173  *tmprepo = reposInsert( alias_r );
174  tmprepo->addHelix( file_r );
175 
176  // no exceptions so we keep it:
177  tmprepo.resetDispose();
178  return tmprepo;
179  }
180 
181  Repository Pool::addRepoHelix( const Pathname & file_r )
182  { return addRepoHelix( file_r, file_r.basename() ); }
183 
184  Repository Pool::addRepoHelix( const Pathname & file_r, const RepoInfo & info_r )
185  {
186  Repository ret( addRepoHelix( file_r, info_r.alias() ) );
187  ret.setInfo( info_r );
188  return ret;
189  }
190 
192 
193  void Pool::setTextLocale( const Locale & locale_r )
194  { myPool().setTextLocale( locale_r ); }
195 
196  void Pool::setRequestedLocales( const LocaleSet & locales_r )
197  { myPool().setRequestedLocales( locales_r ); }
198 
199  bool Pool::addRequestedLocale( const Locale & locale_r )
200  { return myPool().addRequestedLocale( locale_r ); }
201 
202  bool Pool::eraseRequestedLocale( const Locale & locale_r )
203  { return myPool().eraseRequestedLocale( locale_r ); }
204 
206  { return myPool().getRequestedLocales(); }
207 
208  bool Pool::isRequestedLocale( const Locale & locale_r ) const
209  { return myPool().isRequestedLocale( locale_r ); }
210 
212  { return myPool().getAvailableLocales(); }
213 
214  bool Pool::isAvailableLocale( const Locale & locale_r ) const
215  { return myPool().isAvailableLocale( locale_r ); }
216 
217  bool Pool::multiversionEmpty() const { return myPool().multiversionList().empty(); }
218  size_t Pool::multiversionSize() const { return myPool().multiversionList().size(); }
221  bool Pool::isMultiversion( IdString ident_r ) const { return myPool().isMultiversion( ident_r ); }
222 
223  bool Pool::onSystemByUserEmpty() const { return myPool().onSystemByUserList().empty(); }
224  size_t Pool::onSystemByUserSize() const { return myPool().onSystemByUserList().size(); }
227  bool Pool::isOnSystemByUser( IdString ident_r ) const { return myPool().isOnSystemByUser( ident_r ); }
228 
229  /******************************************************************
230  **
231  ** FUNCTION NAME : operator<<
232  ** FUNCTION TYPE : std::ostream &
233  */
234  std::ostream & operator<<( std::ostream & str, const Pool & obj )
235  {
236  return str << "sat::pool(" << obj.serial() << ")["
237  << obj.capacity() << "]{"
238  << obj.reposSize() << "repos|"
239  << obj.solvablesSize() << "slov}";
240  }
241 
243  } // namespace sat
246 } // namespace zypp
::_Pool * get() const
Expert backdoor.
Definition: Pool.cc:36
Repository reposInsert(const std::string &alias_r)
Return a Repository named alias_r.
Definition: Pool.cc:103
Interface to gettext.
std::string alias() const
unique identifier for this source.
bool eraseRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:449
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Definition: Pool.cc:196
OnSystemByUserIterator onSystemByUserBegin() const
Definition: Pool.cc:225
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
Definition: RepoInfoBase.cc:94
size_type reposSize() const
Number of repos in Pool.
Definition: Pool.cc:54
std::ostream & operator<<(std::ostream &str, const LocaleSupport &obj)
void setTextLocale(const Locale &locale_r)
Set the default language for retrieving translated texts.
Definition: Pool.cc:193
void resetDispose()
Set no dispose function.
Definition: AutoDispose.h:162
bool onSystemByUserEmpty() const
Definition: Pool.cc:223
::_Pool * getPool() const
Definition: PoolImpl.h:139
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition: Pool.cc:100
bool addRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:438
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
Definition: PoolImpl.cc:259
void setEnabled(bool enabled)
enable or disable the repository
Definition: RepoInfoBase.cc:89
void setAlias(const std::string &alias)
set the repository alias
Definition: RepoInfoBase.cc:99
bool isRequestedLocale(const Locale &locale_r) const
Whether this Locale is in the set of requested locales.
Definition: Pool.cc:208
bool isMultiversion(IdString ident_r) const
Definition: Pool.cc:221
What is known about a repository.
Definition: RepoInfo.h:66
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:220
Access to the sat-pools string space.
Definition: IdString.h:39
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
IdStringSet::const_iterator OnSystemByUserIterator
Definition: Pool.h:233
Repository addRepoHelix(const Pathname &file_r, const std::string &name_r)
Load Solvables from a helix-file into a Repository named name_r.
Definition: Pool.cc:169
bool isSystemRepo() const
Return whether this is the system repository.
Definition: Repository.cc:51
const SerialNumber & serial() const
Housekeeping data serial number.
Definition: Pool.cc:42
const LocaleSet & getRequestedLocales() const
Definition: PoolImpl.h:209
size_type solvablesSize() const
Number of solvables in Pool.
Definition: Pool.cc:84
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:63
size_t onSystemByUserSize() const
Definition: Pool.cc:224
RepositoryIterator reposEnd() const
Iterator behind the last Repository.
Definition: Pool.cc:68
size_type capacity() const
Internal array size for stats only.
Definition: Pool.cc:39
const LocaleSet & getAvailableLocales() const
Definition: PoolImpl.cc:490
Repository systemRepo()
Return the system repository, create it if missing.
Definition: Pool.cc:138
Functor removing Repository from it&#39;s Pool.
Definition: Repository.h:385
bool isMultiversion(IdString ident_r) const
Definition: PoolImpl.h:240
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: Pool.cc:33
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
Definition: Repository.cc:207
zypp::detail::RepositoryIterator RepositoryIterator
Definition: Pool.h:46
void setRequestedLocales(const LocaleSet &locales_r)
Definition: PoolImpl.cc:430
bool isOnSystemByUser(IdString ident_r) const
Definition: PoolImpl.h:259
bool isOnSystemByUser(IdString ident_r) const
Definition: Pool.cc:227
IdStringSet::const_iterator MultiversionIterator
Definition: Pool.h:218
MultiversionIterator multiversionEnd() const
Definition: Pool.cc:220
bool reposEmpty() const
Whether Pool contains repos.
Definition: Pool.cc:51
Repository reposFind(const std::string &alias_r) const
Find a Repository named alias_r.
Definition: Pool.cc:123
RepoInfoList repos
Definition: RepoManager.cc:192
RepositoryIterator reposBegin() const
Iterator to the first Repository.
Definition: Pool.cc:57
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
bool multiversionEmpty() const
Definition: Pool.cc:217
static PoolImpl & myPool()
Definition: PoolImpl.cc:164
detail::SolvableIterator SolvableIterator
Definition: Pool.h:45
bool addRequestedLocale(const Locale &locale_r)
Add one Locale to the set of requested locales.
Definition: Pool.cc:199
Simple serial number provider.
Definition: SerialNumber.h:44
const OnSystemByUserList & onSystemByUserList() const
Definition: PoolImpl.h:252
OnSystemByUserIterator onSystemByUserEnd() const
Definition: Pool.cc:226
size_t multiversionSize() const
Definition: Pool.cc:218
detail::size_type size_type
Definition: Pool.h:47
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:413
const LocaleSet & getRequestedLocales() const
Return the requested locales.
Definition: Pool.cc:205
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:237
bool isAvailableLocale(const Locale &locale_r) const
Whether this Locale is in the set of available locales.
Definition: Pool.cc:214
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: PoolImpl.cc:79
Reference counted access to a _Tp object calling a custom Dispose function when the last AutoDispose ...
Definition: AutoDispose.h:92
void prepare() const
Update housekeeping data if necessary (e.g.
Definition: Pool.cc:45
Global sat-pool.
Definition: Pool.h:42
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: Pool.cc:97
const LocaleSet & getAvailableLocales() const
Get the set of available locales.
Definition: Pool.cc:211
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:212
void setName(const std::string &name)
set the repository name
const MultiversionList & multiversionList() const
Definition: PoolImpl.h:233
Repository addRepoSolv(const Pathname &file_r, const std::string &name_r)
Load Solvables from a solv-file into a Repository named name_r.
Definition: Pool.cc:145
bool solvablesEmpty() const
Whether Pool contains solvables.
Definition: Pool.cc:71
MultiversionIterator multiversionBegin() const
Definition: Pool.cc:219
Repository findSystemRepo() const
Return the system repository if it is on the pool.
Definition: Pool.cc:133
bool eraseRequestedLocale(const Locale &locale_r)
Erase one Locale from the set of requested locales.
Definition: Pool.cc:202
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
Definition: Pool.cc:48