libzypp  14.48.5
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 
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  Pathname Pool::rootDir() const
52  { return myPool().rootDir(); }
53 
54  void Pool::rootDir( const Pathname & root_r )
55  { return myPool().rootDir( root_r ); }
56 
57  bool Pool::reposEmpty() const
58  { return ! myPool()->urepos; }
59 
61  { return myPool()->urepos; }
62 
64  {
65  if ( myPool()->urepos )
66  { // repos[0] == NULL
67  for_( it, myPool()->repos+1, myPool()->repos+myPool()->nrepos )
68  if ( *it )
69  return RepositoryIterator( it );
70  }
71  return reposEnd();
72  }
73 
75  { return RepositoryIterator( myPool()->repos+myPool()->nrepos ); }
76 
77  bool Pool::solvablesEmpty() const
78  {
79  // return myPool()->nsolvables;
80  // nsolvables is the array size including
81  // invalid Solvables.
82  for_( it, reposBegin(), reposEnd() )
83  {
84  if ( ! it->solvablesEmpty() )
85  return false;
86  }
87  return true;
88  }
89 
91  {
92  // Do not return myPool()->nsolvables;
93  // nsolvables is the array size including
94  // invalid Solvables.
95  size_type ret = 0;
96  for_( it, reposBegin(), reposEnd() )
97  {
98  ret += it->solvablesSize();
99  }
100  return ret;
101  }
102 
104  { return SolvableIterator( myPool().getFirstId() ); }
105 
107  { return SolvableIterator(); }
108 
109  Repository Pool::reposInsert( const std::string & alias_r )
110  {
111  Repository ret( reposFind( alias_r ) );
112  if ( ret )
113  return ret;
114 
115  ret = Repository( myPool()._createRepo( alias_r ) );
116  if ( ret.isSystemRepo() )
117  {
118  // autoprovide (dummy) RepoInfo
119  RepoInfo info;
120  info.setAlias( alias_r );
121  info.setName( alias_r );
122  info.setAutorefresh( true );
123  info.setEnabled( true );
124  ret.setInfo( info );
125  }
126  return ret;
127  }
128 
129  Repository Pool::reposFind( const std::string & alias_r ) const
130  {
131  for_( it, reposBegin(), reposEnd() )
132  {
133  if ( alias_r == it->alias() )
134  return *it;
135  }
136  return Repository();
137  }
138 
140  {
141  return Repository( myPool().systemRepo() );
142  }
143 
145  {
146  if ( myPool().systemRepo() )
147  return Repository( myPool().systemRepo() );
148  return reposInsert( systemRepoAlias() );
149  }
150 
151  Repository Pool::addRepoSolv( const Pathname & file_r, const std::string & alias_r )
152  {
153  // Using a temporay repo! (The additional parenthesis are required.)
155  *tmprepo = reposInsert( alias_r );
156  tmprepo->addSolv( file_r );
157 
158  // no exceptions so we keep it:
159  tmprepo.resetDispose();
160  return tmprepo;
161  }
162 
163  Repository Pool::addRepoSolv( const Pathname & file_r )
164  { return addRepoSolv( file_r, file_r.basename() ); }
165 
166  Repository Pool::addRepoSolv( const Pathname & file_r, const RepoInfo & info_r )
167  {
168  Repository ret( addRepoSolv( file_r, info_r.alias() ) );
169  ret.setInfo( info_r );
170  return ret;
171  }
172 
174 
175  Repository Pool::addRepoHelix( const Pathname & file_r, const std::string & alias_r )
176  {
177  // Using a temporay repo! (The additional parenthesis are required.)
179  *tmprepo = reposInsert( alias_r );
180  tmprepo->addHelix( file_r );
181 
182  // no exceptions so we keep it:
183  tmprepo.resetDispose();
184  return tmprepo;
185  }
186 
187  Repository Pool::addRepoHelix( const Pathname & file_r )
188  { return addRepoHelix( file_r, file_r.basename() ); }
189 
190  Repository Pool::addRepoHelix( const Pathname & file_r, const RepoInfo & info_r )
191  {
192  Repository ret( addRepoHelix( file_r, info_r.alias() ) );
193  ret.setInfo( info_r );
194  return ret;
195  }
196 
198 
199  void Pool::setTextLocale( const Locale & locale_r )
200  { myPool().setTextLocale( locale_r ); }
201 
202  void Pool::setRequestedLocales( const LocaleSet & locales_r )
203  { myPool().setRequestedLocales( locales_r ); }
204 
205  bool Pool::addRequestedLocale( const Locale & locale_r )
206  { return myPool().addRequestedLocale( locale_r ); }
207 
208  bool Pool::eraseRequestedLocale( const Locale & locale_r )
209  { return myPool().eraseRequestedLocale( locale_r ); }
210 
212  { return myPool().getRequestedLocales(); }
213 
214  bool Pool::isRequestedLocale( const Locale & locale_r ) const
215  { return myPool().isRequestedLocale( locale_r ); }
216 
218  { return myPool().getAvailableLocales(); }
219 
220  bool Pool::isAvailableLocale( const Locale & locale_r ) const
221  { return myPool().isAvailableLocale( locale_r ); }
222 
223  bool Pool::multiversionEmpty() const { return myPool().multiversionList().empty(); }
224  size_t Pool::multiversionSize() const { return myPool().multiversionList().size(); }
227  bool Pool::isMultiversion( IdString ident_r ) const { return myPool().isMultiversion( ident_r ); }
228 
230  void Pool::setAutoInstalled( const Queue & autoInstalled_r ){ myPool().setAutoInstalled( autoInstalled_r ); }
231 
232  /******************************************************************
233  **
234  ** FUNCTION NAME : operator<<
235  ** FUNCTION TYPE : std::ostream &
236  */
237  std::ostream & operator<<( std::ostream & str, const Pool & obj )
238  {
239  return str << "sat::pool(" << obj.serial() << ")["
240  << obj.capacity() << "]{"
241  << obj.reposSize() << "repos|"
242  << obj.solvablesSize() << "slov}";
243  }
244 
246  } // namespace sat
249 } // namespace zypp
Repository reposInsert(const std::string &alias_r)
Return a Repository named alias_r.
Definition: Pool.cc:109
Interface to gettext.
Pathname rootDir() const
Get rootdir (for file conflicts check)
Definition: PoolImpl.h:98
std::string alias() const
unique identifier for this source.
bool eraseRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:454
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Definition: Pool.cc:202
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
Definition: RepoInfoBase.cc:91
size_type reposSize() const
Number of repos in Pool.
Definition: Pool.cc:60
void setTextLocale(const Locale &locale_r)
Set the default language for retrieving translated texts.
Definition: Pool.cc:199
void resetDispose()
Set no dispose function.
Definition: AutoDispose.h:162
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition: Pool.cc:106
bool addRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:443
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
Definition: PoolImpl.cc:272
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
void setEnabled(bool enabled)
enable or disable the repository
Definition: RepoInfoBase.cc:88
CPool * getPool() const
Definition: PoolImpl.h:156
::_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:86
void setAlias(const std::string &alias)
set the repository alias
Definition: RepoInfoBase.cc:94
void setAutoInstalled(const Queue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition: Pool.cc:230
bool isRequestedLocale(const Locale &locale_r) const
Whether this Locale is in the set of requested locales.
Definition: Pool.cc:214
detail::CPool * get() const
Expert backdoor.
Definition: Pool.cc:36
bool isMultiversion(IdString ident_r) const
Definition: Pool.cc:227
What is known about a repository.
Definition: RepoInfo.h:72
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:237
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
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:175
bool isSystemRepo() const
Return whether this is the system repository.
Definition: Repository.cc:53
const SerialNumber & serial() const
Housekeeping data serial number.
Definition: Pool.cc:42
const LocaleSet & getRequestedLocales() const
Definition: PoolImpl.h:226
size_type solvablesSize() const
Number of solvables in Pool.
Definition: Pool.cc:90
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:64
RepositoryIterator reposEnd() const
Iterator behind the last Repository.
Definition: Pool.cc:74
size_type capacity() const
Internal array size for stats only.
Definition: Pool.cc:39
const LocaleSet & getAvailableLocales() const
Definition: PoolImpl.cc:495
Repository systemRepo()
Return the system repository, create it if missing.
Definition: Pool.cc:144
Functor removing Repository from it's Pool.
Definition: Repository.h:411
bool isMultiversion(IdString ident_r) const
Definition: PoolImpl.h:257
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:279
zypp::detail::RepositoryIterator RepositoryIterator
Definition: Pool.h:47
void setRequestedLocales(const LocaleSet &locales_r)
Definition: PoolImpl.cc:435
IdStringSet::const_iterator MultiversionIterator
Definition: Pool.h:225
MultiversionIterator multiversionEnd() const
Definition: Pool.cc:226
Queue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition: Pool.cc:229
bool reposEmpty() const
Whether Pool contains repos.
Definition: Pool.cc:57
Repository reposFind(const std::string &alias_r) const
Find a Repository named alias_r.
Definition: Pool.cc:129
RepoInfoList repos
Definition: RepoManager.cc:262
RepositoryIterator reposBegin() const
Iterator to the first Repository.
Definition: Pool.cc:63
Pathname rootDir() const
Get rootdir (for file conflicts check)
Definition: Pool.cc:51
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition: PoolImpl.h:268
bool multiversionEmpty() const
Definition: Pool.cc:223
static PoolImpl & myPool()
Definition: PoolImpl.cc:167
detail::SolvableIterator SolvableIterator
Definition: Pool.h:46
bool addRequestedLocale(const Locale &locale_r)
Add one Locale to the set of requested locales.
Definition: Pool.cc:205
Simple serial number provider.
Definition: SerialNumber.h:44
Libsolv Id queue wrapper.
Definition: Queue.h:34
size_t multiversionSize() const
Definition: Pool.cc:224
detail::size_type size_type
Definition: Pool.h:48
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:418
const LocaleSet & getRequestedLocales() const
Return the requested locales.
Definition: Pool.cc:211
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:250
bool isAvailableLocale(const Locale &locale_r) const
Whether this Locale is in the set of available locales.
Definition: Pool.cc:220
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: PoolImpl.cc:89
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:43
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: Pool.cc:103
const LocaleSet & getAvailableLocales() const
Get the set of available locales.
Definition: Pool.cc:217
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:229
void setName(const std::string &name)
set the repository name
Definition: RepoInfoBase.cc:97
const MultiversionList & multiversionList() const
Definition: PoolImpl.h:250
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:151
bool solvablesEmpty() const
Whether Pool contains solvables.
Definition: Pool.cc:77
MultiversionIterator multiversionBegin() const
Definition: Pool.cc:225
Repository findSystemRepo() const
Return the system repository if it is on the pool.
Definition: Pool.cc:139
bool eraseRequestedLocale(const Locale &locale_r)
Erase one Locale from the set of requested locales.
Definition: Pool.cc:208
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
Definition: Pool.cc:48
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition: PoolImpl.h:272