- prepare for messages and scripts
[platform/upstream/libzypp.git] / zypp / ZConfig.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ZConfig.h
10  *
11 */
12 #ifndef ZYPP_ZCONFIG_H
13 #define ZYPP_ZCONFIG_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/Deprecated.h"
18
19 #include "zypp/base/NonCopyable.h"
20 #include "zypp/base/PtrTypes.h"
21
22 #include "zypp/Arch.h"
23 #include "zypp/Locale.h"
24 #include "zypp/Pathname.h"
25
26 ///////////////////////////////////////////////////////////////////
27 namespace zypp
28 { /////////////////////////////////////////////////////////////////
29
30   ///////////////////////////////////////////////////////////////////
31   //
32   //    CLASS NAME : ZConfig
33   //
34   /** Interim helper class to collect global options and settings.
35    * Use it to avoid hardcoded values and calls to getZYpp() just
36    * to retrieve some value like architecture, languages or tmppath.
37    *
38    * It reads /etc/zypp/zypp.conf, the filename can be overridden by
39    * setting the ZYPP_CONF environment variable to a different file.
40    *
41    * Note, if you add settings to this file, please follow the following
42    * convention:
43    *
44    * namespace.settingname
45    *
46    * should become
47    *
48    * namespace_settingName()
49    *
50    * \ingroup Singleton
51   */
52   class ZConfig : private base::NonCopyable
53   {
54     public:
55       /** Singleton ctor */
56       static ZConfig & instance();
57
58     public:
59
60       /** The autodetected system architecture. */
61       static Arch defaultSystemArchitecture();
62
63       /** The system architecture zypp uses. */
64       Arch systemArchitecture() const;
65
66       /** Override the zypp system architecture.
67        * This is useful for test scenarious. <b>But be warned</b>, zypp does
68        * not expect the system architecture to change at runtime. So
69        * set it at the verry beginning before you acess any other
70        * zypp component.
71       */
72       void setSystemArchitecture( const Arch & arch_r );
73
74       /** Reset the zypp system architecture to the default. */
75       void resetSystemArchitecture()
76       { setSystemArchitecture( defaultSystemArchitecture() ); }
77
78     public:
79       /** The autodetected prefered locale for translated texts.
80        */
81       static Locale defaultTextLocale();
82
83       /** The locale for translated texts zypp uses.
84        */
85       Locale textLocale() const;
86
87       /** Set the prefered locale for translated texts. */
88       void setTextLocale( const Locale & locale_r );
89
90       /** Reset the locale for translated texts to the default. */
91       void resetTextLocale()
92       { setTextLocale( defaultTextLocale() ); }
93
94     public:
95       /**
96        * Path where the caches are kept (/var/cache/zypp)
97        * \ingroup g_ZC_REPOCACHE
98        */
99       Pathname repoCachePath() const;
100
101      /**
102        * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
103         * \ingroup g_ZC_REPOCACHE
104       */
105       Pathname repoMetadataPath() const;
106
107      /**
108        * Path where the repo solv files are created and kept (repoCachePath()/solv).
109         * \ingroup g_ZC_REPOCACHE
110       */
111       Pathname repoSolvfilesPath() const;
112
113       /**
114        * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
115         * \ingroup g_ZC_REPOCACHE
116       */
117       Pathname repoPackagesPath() const;
118
119       /**
120        * Path where the configfiles are kept (/etc/zypp).
121        * \ingroup g_ZC_CONFIGFILES
122        */
123       Pathname configPath() const;
124
125       /**
126        * Path where the known repositories .repo files are kept (configPath()/repos.d).
127        * \ingroup g_ZC_CONFIGFILES
128        */
129       Pathname knownReposPath() const;
130
131       /**
132        * Separator string for storing/reading sets of strings to/from
133        * metadata cache DB.
134        */
135       const std::string & cacheDBSplitJoinSeparator() const;
136
137       /**
138        * Whether repository urls should be probed.
139        / config option
140        * repo.add.probe
141        */
142       bool repo_add_probe() const;
143
144       /**
145        * Amount of time in minutes that must pass before another refresh.
146        */
147       unsigned repo_refresh_delay() const;
148
149       /** Whether to consider using a patchrpm when downloading a package.
150        * Config option <tt>download.use_patchrpm (true)</tt>
151       */
152       bool download_use_patchrpm() const;
153
154       /** Whether to consider using a deltarpm when downloading a package.
155        * Config option <tt>download.use_deltarpm (true)</tt>
156        */
157       bool download_use_deltarpm() const;
158
159       /**
160        * Directory for equivalent vendor definitions  (configPath()/vendors.d)
161        * \ingroup g_ZC_CONFIGFILES
162        */
163       Pathname vendorPath() const;
164
165       /**
166        * Directory for additional product information  (configPath()/products.d)
167        * \ingroup g_ZC_CONFIGFILES
168        */
169       Pathname productsPath() const;
170
171       /**
172        * Solver regards required packages,patterns,... only
173        */
174       bool solver_onlyRequires() const;
175
176       /**
177        * Path where zypp can find or create lock file (configPath()/locks)
178        * \ingroup g_ZC_CONFIGFILES
179        */
180       Pathname locksFile() const;
181
182       /**
183        * Whether locks file should be read and applied after start
184        */
185       bool apply_locks_file() const;
186
187       /**
188        * Path where the update items are kept (/var/adm)
189        */
190       Pathname update_dataPath() const;
191
192      /**
193        * Path where the repo metadata is downloaded and kept (update_dataPath()/).
194         * \ingroup g_ZC_REPOCACHE
195       */
196       Pathname update_scriptsPath() const;
197
198      /**
199        * Path where the repo solv files are created and kept (update_dataPath()/solv).
200         * \ingroup g_ZC_REPOCACHE
201       */
202       Pathname update_messagesPath() const;
203
204     public:
205       class Impl;
206       /** Dtor */
207       ~ZConfig();
208     private:
209       friend class Impl;
210       /** Default ctor. */
211       ZConfig();
212       /** Pointer to implementation */
213       RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
214   };
215   ///////////////////////////////////////////////////////////////////
216
217   /////////////////////////////////////////////////////////////////
218 } // namespace zypp
219 ///////////////////////////////////////////////////////////////////
220 #endif // ZYPP_ZCONFIG_H