- Create the cache directly from the schema (installed) file.
[platform/upstream/libzypp.git] / zypp / Fetcher.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9
10 #ifndef ZYPP_FETCHER_H
11 #define ZYPP_FETCHER_H
12
13 #include <list>
14 #include "zypp/Pathname.h"
15 #include "zypp/Url.h"
16 #include "zypp/OnMediaLocation.h"
17
18 namespace zypp
19 {
20   
21   /** 
22   * Edition represents <code>[epoch:]version[-release]</code>
23   *
24   * This class allows to retrieve a group of files which can
25   * be cached already on the local disk.
26   *
27   * \code
28   * Fetcher fetcher(url, path);
29   * fetcher.enqueue( OnMediaLocation().filename("/content") );
30   * fetcher.insertCache("/tmp/cache")
31   * fetcher.start( "/download-dir );
32   * fetcher.reset();
33   * \endcode
34   */
35   class Fetcher
36   {
37   public:
38     /**
39     * Constructs a fetcher from a url and path
40     */
41     Fetcher( const Url &url, const Pathname &path );
42     
43     /**
44     * Enqueue a object for transferal, they will not
45     * be transfered until \ref start() is called
46     */
47     void enqueue( const OnMediaLocation &resource );
48     /**
49     * adds a directory to the list of directories
50     * where to look for cached files
51     */
52     void insertCache( const Pathname &cache_dir );
53     /**
54     * Reset the transfer list and cache list
55     */
56     void reset();
57     /**
58     * start the transfer to a destination directory
59     * The file tree will be replicated inside this
60     * directory
61     */
62     void start( const Pathname &dest_dir );
63   
64   private:
65     Url _url;
66     Pathname _path;
67     std::list<OnMediaLocation> _resources;
68     std::list<Pathname> _caches;
69   };
70
71 } // ns zypp
72 #endif