// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire.h,v 1.29.2.1 2003/12/24 23:09:17 mdz Exp $
/* ######################################################################
Acquire - File Acquiration
#include <apt-pkg/macros.h>
#include <apt-pkg/weakptr.h>
+#include <apt-pkg/hashes.h>
-#include <vector>
#include <string>
+#include <vector>
#include <stddef.h>
#include <sys/time.h>
/** \brief FD of the Lock file we acquire in Setup (if any) */
int LockFD;
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
public:
struct MethodConfig;
struct ItemDesc;
friend class Item;
+ friend class pkgAcqMetaBase;
friend class Queue;
typedef std::vector<Item *>::iterator ItemIterator;
bool GetLock(std::string const &Lock);
/** \brief Construct a new pkgAcquire. */
- pkgAcquire(pkgAcquireStatus *Log);
+ explicit pkgAcquire(pkgAcquireStatus *Log);
pkgAcquire();
/** \brief Destroy this pkgAcquire object.
*/
struct pkgAcquire::ItemDesc : public WeakPointable
{
- /** \brief The URI from which to download this item. */
+ /** \brief URI from which to download this item. */
std::string URI;
- /** brief A description of this item. */
+ /** \brief description of this item. */
std::string Description;
- /** brief A shorter description of this item. */
+ /** \brief shorter description of this item. */
std::string ShortDesc;
- /** brief The underlying item which is to be downloaded. */
+ /** \brief underlying item which is to be downloaded. */
Item *Owner;
};
/*}}}*/
friend class pkgAcquire::Worker;
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
/** \brief The next queue in the pkgAcquire object's list of queues. */
Queue *Next;
protected:
/** \brief A single item placed in this queue. */
- struct QItem : pkgAcquire::ItemDesc
+ struct QItem : public ItemDesc
{
/** \brief The next item in the queue. */
QItem *Next;
/** \brief The worker associated with this item, if any. */
pkgAcquire::Worker *Worker;
+ /** \brief The underlying items interested in the download */
+ std::vector<Item*> Owners;
+
+ typedef std::vector<Item*>::const_iterator owner_iterator;
+
/** \brief Assign the ItemDesc portion of this QItem from
* another ItemDesc
*/
URI = I.URI;
Description = I.Description;
ShortDesc = I.ShortDesc;
+ Owners.clear();
+ Owners.push_back(I.Owner);
Owner = I.Owner;
};
+
+ /** @return the sum of all expected hashes by all owners */
+ HashStringList GetExpectedHashes() const;
+
+ /** @return smallest maximum size of all owners */
+ unsigned long long GetMaximumSize() const;
+
+ /** \brief get partial files in order */
+ void SyncDestinationFiles() const;
+
+ /** @return the custom headers to use for this item */
+ std::string Custom600Headers() const;
};
-
+
/** \brief The name of this queue. */
std::string Name;
* \param Name The name of the new queue.
* \param Owner The download process that owns the new queue.
*/
- Queue(std::string Name,pkgAcquire *Owner);
+ Queue(std::string const &Name,pkgAcquire * const Owner);
/** Shut down all the worker processes associated with this queue
* and empty the queue.
class pkgAcquire::UriIterator
{
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
/** The next queue to iterate over. */
pkgAcquire::Queue *CurQ;
}
};
- inline pkgAcquire::ItemDesc const *operator ->() const {return CurItem;};
+ inline pkgAcquire::Queue::QItem const *operator ->() const {return CurItem;};
inline bool operator !=(UriIterator const &rhs) const {return rhs.CurQ != CurQ || rhs.CurItem != CurItem;};
inline bool operator ==(UriIterator const &rhs) const {return rhs.CurQ == CurQ && rhs.CurItem == CurItem;};
*
* \param Q The queue over which this UriIterator should iterate.
*/
- UriIterator(pkgAcquire::Queue *Q) : d(NULL), CurQ(Q), CurItem(0)
- {
- while (CurItem == 0 && CurQ != 0)
- {
- CurItem = CurQ->Items;
- CurQ = CurQ->Next;
- }
- }
+ explicit UriIterator(pkgAcquire::Queue *Q);
virtual ~UriIterator();
};
/*}}}*/
struct pkgAcquire::MethodConfig
{
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
/** \brief The next link on the acquire method list.
*
class pkgAcquireStatus
{
/** \brief dpointer placeholder (for later in case we need it) */
- void *d;
+ void * const d;
protected: