- merge Stano's patch to keep downloaded rpms
[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    * \ingroup Singleton
42   */
43   class ZConfig : private base::NonCopyable
44   {
45     public:
46       /** Singleton ctor */
47       static ZConfig & instance();
48
49     public:
50
51       /** The autodetected system architecture. */
52       static Arch defaultSystemArchitecture();
53
54       /** The system architecture zypp uses. */
55       Arch systemArchitecture() const;
56
57       /** Override the zypp system architecture.
58        * This is useful for test scenarious. <b>But be warned</b>, zypp does
59        * not expect the system architecture to change at runtime. So
60        * set it at the verry beginning before you acess any other
61        * zypp component.
62       */
63       void setSystemArchitecture( const Arch & arch_r );
64
65       /** Reset the zypp system architecture to the default. */
66       void resetSystemArchitecture()
67       { setSystemArchitecture( defaultSystemArchitecture() ); }
68
69       /** use setSystemArchitecture */
70       ZYPP_DEPRECATED void overrideSystemArchitecture( const Arch & arch_r )
71       { setSystemArchitecture( arch_r ); }
72
73     public:
74       /** The autodetected prefered locale for translated texts.
75        */
76       static Locale defaultTextLocale();
77
78       /** The locale for translated texts zypp uses.
79        */
80       Locale textLocale() const;
81
82       /** Set the prefered locale for translated texts. */
83       void setTextLocale( const Locale & locale_r );
84
85       /** Reset the locale for translated texts to the default. */
86       void resetTextLocale()
87       { setTextLocale( defaultTextLocale() ); }
88
89     public:
90      /**
91        * Path where the repo metadata is downloaded and kept.
92        */
93       Pathname repoMetadataPath() const;
94
95       /**
96        * Path where the repo packages are downloaded and kept.
97        */
98       Pathname repoPackagesPath() const;
99
100       /**
101        * Path where the processed cache is kept
102        * (this is where zypp.db is located.
103        */
104       Pathname repoCachePath() const;
105
106       /**
107        * Path where the known repositories
108        * .repo files are kept
109        */
110       Pathname knownReposPath() const;
111
112       /**
113        * Separator string for storing/reading sets of strings to/from
114        * metadata cache DB.
115        */
116       const std::string & cacheDBSplitJoinSeparator() const;
117
118       /**
119        * Whether repository urls should be probed.
120        / config option
121        * repo.add.probe
122        */
123       bool repo_add_probe() const;
124
125       /**
126        * Amount of time in minutes that must pass before another refresh.
127        */
128       unsigned repo_refresh_delay() const;
129
130       /** Whether to consider using a patchrpm when downloading a package.
131        * Config option <tt>download.use_patchrpm (true)</tt>
132       */
133       bool download_use_patchrpm() const;
134
135       /** Whether to consider using a deltarpm when downloading a package.
136        * Config option <tt>download.use_deltarpm (true)</tt>
137        */
138       bool download_use_deltarpm() const;
139
140       /**
141        * Directory for equivalent vendor definitions
142        */
143       Pathname vendorPath() const;
144
145     public:
146       class Impl;
147       /** Dtor */
148       ~ZConfig();
149     private:
150       /** Default ctor. */
151       ZConfig();
152       /** Pointer to implementation */
153       RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
154   };
155   ///////////////////////////////////////////////////////////////////
156
157   /////////////////////////////////////////////////////////////////
158 } // namespace zypp
159 ///////////////////////////////////////////////////////////////////
160 #endif // ZYPP_ZCONFIG_H