* apt-pkg/depcache.cc:
[ntk/apt.git] / apt-pkg / acquire.h
index 64dafdc..82be8b8 100644 (file)
@@ -30,7 +30,7 @@
    ##################################################################### */
                                                                        /*}}}*/
 
-/** \defgroup acquire Acquire system
+/** \defgroup acquire Acquire system                                   {{{
  *
  *  \brief The Acquire system is responsible for retrieving files from
  *  local or remote URIs and postprocessing them (for instance,
@@ -54,7 +54,7 @@
  *  once, but it is not clear what its behavior in this case is, and
  *  no subclass of pkgAcquire::Item seems to actually use this
  *  capability.
- */
+ */                                                                    /*}}}*/
 
 /** \addtogroup acquire
  *
 #ifndef PKGLIB_ACQUIRE_H
 #define PKGLIB_ACQUIRE_H
 
+#include <apt-pkg/macros.h>
+#include <apt-pkg/weakptr.h>
+
 #include <vector>
 #include <string>
 
 using std::vector;
 using std::string;
 
-#ifdef __GNUG__
-#pragma interface "apt-pkg/acquire.h"
-#endif 
 
 #include <sys/time.h>
 #include <unistd.h>
 
 class pkgAcquireStatus;
 
-/** \brief The core download scheduler.
+/** \brief The core download scheduler.                                        {{{
  *
  *  This class represents an ongoing download.  It manages the lists
  *  of active and pending downloads and handles setting up and tearing
@@ -164,7 +164,7 @@ class pkgAcquire
      QueueAccess} QueueMode;
 
    /** \brief If \b true, debugging information will be dumped to std::clog. */
-   bool Debug;
+   bool const Debug;
    /** \brief If \b true, a download is currently in progress. */
    bool Running;
 
@@ -323,27 +323,34 @@ class pkgAcquire
    /** \return the total size in bytes of all the items included in
     *  this download.
     */
-   double TotalNeeded();
+   unsigned long long TotalNeeded();
 
    /** \return the size in bytes of all non-local items included in
     *  this download.
     */
-   double FetchNeeded();
+   unsigned long long FetchNeeded();
 
    /** \return the amount of data to be fetched that is already
     *  present on the filesystem.
     */
-   double PartialPresent();
+   unsigned long long PartialPresent();
 
-   /** \brief Construct a new pkgAcquire.
+   /** \brief Delayed constructor
     *
-    *  \param Log The progress indicator associated with this
-    *  download, or \b NULL for none.  This object is not owned by the
+    *  \param Progress indicator associated with this download or
+    *  \b NULL for none.  This object is not owned by the
     *  download process and will not be deleted when the pkgAcquire
     *  object is destroyed.  Naturally, it should live for at least as
     *  long as the pkgAcquire object does.
+    *  \param Lock defines a lock file that should be acquired to ensure
+    *  only one Acquire class is in action at the time or an empty string
+    *  if no lock file should be used.
     */
-   pkgAcquire(pkgAcquireStatus *Log = 0);
+   bool Setup(pkgAcquireStatus *Progress = NULL, string const &Lock = "");
+
+   /** \brief Construct a new pkgAcquire. */
+   pkgAcquire(pkgAcquireStatus *Log) __deprecated;
+   pkgAcquire();
 
    /** \brief Destroy this pkgAcquire object.
     *
@@ -351,6 +358,18 @@ class pkgAcquire
     *  this download.
     */
    virtual ~pkgAcquire();
+
+   private:
+   /** \brief FD of the Lock file we acquire in Setup (if any) */
+   int LockFD;
+
+   /** \brief Ensure the existence of the given Path
+    *
+    *  \param Parent directory of the Path directory - a trailing
+    *  /apt/ will be removed before CreateDirectory call.
+    *  \param Path which should exist after (successful) call
+    */
+   bool CheckDirectory(string const &Parent, string const &Path) const;
 };
 
 /** \brief Represents a single download source from which an item
@@ -358,7 +377,7 @@ class pkgAcquire
  *
  *  An item may have several assocated ItemDescs over its lifetime.
  */
-struct pkgAcquire::ItemDesc
+struct pkgAcquire::ItemDesc : public WeakPointable
 {
    /** \brief The URI from which to download this item. */
    string URI;
@@ -369,8 +388,8 @@ struct pkgAcquire::ItemDesc
    /** brief The underlying item which is to be downloaded. */
    Item *Owner;
 };
-
-/** \brief A single download queue in a pkgAcquire object.
+                                                                       /*}}}*/
+/** \brief A single download queue in a pkgAcquire object.             {{{
  *
  *  \todo Why so many protected values?
  */
@@ -440,8 +459,12 @@ class pkgAcquire::Queue
    
    public:
    
-   /** \brief Insert the given fetch request into this queue. */
-   void Enqueue(ItemDesc &Item);
+   /** \brief Insert the given fetch request into this queue. 
+    *
+    *  \return \b true if the queuing was successful. May return
+    *  \b false if the Item is already in the queue
+    */
+   bool Enqueue(ItemDesc &Item);
 
    /** \brief Remove all fetch requests for the given item from this queue.
     *
@@ -527,8 +550,8 @@ class pkgAcquire::Queue
     */
    ~Queue();
 };
-
-/** \brief Iterates over all the URIs being fetched by a pkgAcquire object. */
+                                                                       /*}}}*/
+/** \brief Iterates over all the URIs being fetched by a pkgAcquire object.    {{{*/
 class pkgAcquire::UriIterator
 {
    /** The next queue to iterate over. */
@@ -538,7 +561,7 @@ class pkgAcquire::UriIterator
    
    public:
    
-   inline void operator ++() {operator ++();};
+   inline void operator ++() {operator ++(0);};
 
    void operator ++(int)
    {
@@ -567,8 +590,8 @@ class pkgAcquire::UriIterator
       }
    }   
 };
-
-/** \brief Information about the properties of a single acquire method. */
+                                                                       /*}}}*/
+/** \brief Information about the properties of a single acquire method.        {{{*/
 struct pkgAcquire::MethodConfig
 {
    /** \brief The next link on the acquire method list.
@@ -620,8 +643,8 @@ struct pkgAcquire::MethodConfig
     */
    MethodConfig();
 };
-
-/** \brief A monitor object for downloads controlled by the pkgAcquire class.
+                                                                       /*}}}*/
+/** \brief A monitor object for downloads controlled by the pkgAcquire class.  {{{
  *
  *  \todo Why protected members?
  *
@@ -761,7 +784,7 @@ class pkgAcquireStatus
    pkgAcquireStatus();
    virtual ~pkgAcquireStatus() {};
 };
-
+                                                                       /*}}}*/
 /** @} */
 
 #endif