Merge pull request #23 from openSUSE/drop_package_manager
[platform/upstream/libzypp.git] / zypp / DownloadMode.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/DownloadMode.h
10  *
11 */
12 #ifndef ZYPP_DOWNLOADMODE_H
13 #define ZYPP_DOWNLOADMODE_H
14
15 #include <iosfwd>
16
17 ///////////////////////////////////////////////////////////////////
18 namespace zypp
19 { /////////////////////////////////////////////////////////////////
20
21   /** Supported commit download policies. */
22   enum DownloadMode
23   {
24     DownloadDefault, //!< libzypp will decide what to do.
25     DownloadOnly,       //!< Just download all packages to the local cache.
26                         //!< Do not install. Implies a dry-run.
27     DownloadInAdvance,  //!< First download all packages to the local cache.
28                         //!< Then start to install.
29     DownloadInHeaps,    //!< Similar to DownloadInAdvance, but try to split
30                         //!< the transaction into heaps, where at the end of
31                         //!< each heap a consistent system state is reached.
32     DownloadAsNeeded    //!< Alternating download and install. Packages are
33                         //!< cached just to avid CD/DVD hopping. This is the
34                         //!< traditional behaviour.
35   };
36
37   /** \relates DownloadMode Parse from string.
38    * On success the \ref DownloadMode is returned via \a result_r,
39    * and the function returns \c true. Otherwise it returns \c false
40    * and \a result_r remains unchanged.
41    */
42   bool deserialize( const std::string & str_r, DownloadMode & result_r );
43
44   /** \relates DownloadMode Parse from string.
45    * Similar as \ref deserialize, but silently return \ref DownloadDefault
46    * in case of a parse error.
47    */
48   inline DownloadMode deserializeDownloadMode( const std::string & str_r )
49   {
50     DownloadMode ret( DownloadDefault );
51     deserialize( str_r, ret );
52     return ret;
53   }
54
55   /** \relates DownloadMode Stream output. */
56   std::ostream & operator<<( std::ostream & str, DownloadMode obj );
57
58   /////////////////////////////////////////////////////////////////
59 } // namespace zypp
60 ///////////////////////////////////////////////////////////////////
61 #endif // ZYPP_DOWNLOADMODE_H