]> git.saurik.com Git - apt.git/blob - apt-pkg/acquire.cc
Early mehods
[apt.git] / apt-pkg / acquire.cc
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: acquire.cc,v 1.2 1998/10/20 02:39:15 jgg Exp $
4 /* ######################################################################
5
6 Acquire - File Acquiration
7
8 ##################################################################### */
9 /*}}}*/
10 // Include Files /*{{{*/
11 #ifdef __GNUG__
12 #pragma implementation "apt-pkg/acquire.h"
13 #endif
14 #include <apt-pkg/acquire.h>
15 #include <apt-pkg/acquire-item.h>
16 #include <apt-pkg/acquire-worker.h>
17 #include <strutl.h>
18 /*}}}*/
19
20 // Acquire::pkgAcquire - Constructor /*{{{*/
21 // ---------------------------------------------------------------------
22 /* */
23 pkgAcquire::pkgAcquire()
24 {
25 Queues = 0;
26 Configs = 0;
27 }
28 /*}}}*/
29 // Acquire::~pkgAcquire - Destructor /*{{{*/
30 // ---------------------------------------------------------------------
31 /* Free our memory */
32 pkgAcquire::~pkgAcquire()
33 {
34 while (Items.size() != 0)
35 delete Items[0];
36
37 while (Configs != 0)
38 {
39 MethodConfig *Jnk = Configs;
40 Configs = Configs->Next;
41 delete Jnk;
42 }
43 }
44 /*}}}*/
45 // Acquire::Add - Add a new item /*{{{*/
46 // ---------------------------------------------------------------------
47 /* */
48 void pkgAcquire::Add(Item *Itm)
49 {
50 Items.push_back(Itm);
51 }
52 /*}}}*/
53 // Acquire::Remove - Remove a item /*{{{*/
54 // ---------------------------------------------------------------------
55 /* */
56 void pkgAcquire::Remove(Item *Itm)
57 {
58 for (vector<Item *>::iterator I = Items.begin(); I < Items.end(); I++)
59 {
60 if (*I == Itm)
61 Items.erase(I);
62 }
63 }
64 /*}}}*/
65 // Acquire::Enqueue - Queue an URI for fetching /*{{{*/
66 // ---------------------------------------------------------------------
67 /* */
68 void pkgAcquire::Enqueue(Item *Item,string URI)
69 {
70 cout << "Fetching " << URI << endl;
71 cout << " to " << Item->ToFile() << endl;
72 cout << " Queue is: " << QueueName(URI) << endl;
73 }
74 /*}}}*/
75 // Acquire::QueueName - Return the name of the queue for this URI /*{{{*/
76 // ---------------------------------------------------------------------
77 /* */
78 string pkgAcquire::QueueName(string URI)
79 {
80 const MethodConfig *Config = GetConfig(URIAccess(URI));
81 return string();
82 }
83 /*}}}*/
84 // Acquire::GetConfig - Fetch the configuration information /*{{{*/
85 // ---------------------------------------------------------------------
86 /* This locates the configuration structure for an access method. If
87 a config structure cannot be found a Worker will be created to
88 retrieve it */
89 const pkgAcquire::MethodConfig *pkgAcquire::GetConfig(string Access)
90 {
91 // Search for an existing config
92 MethodConfig *Conf;
93 for (Conf = Configs; Conf != 0; Conf = Conf->Next)
94 if (Conf->Access == Access)
95 return Conf;
96
97 // Create the new config class
98 Conf = new MethodConfig;
99 Conf->Access = Access;
100 Conf->Next = Configs;
101 Configs = Conf;
102
103 // Create the worker to fetch the configuration
104 Worker Work(Conf);
105 if (Work.Start() == false)
106 return 0;
107
108 return Conf;
109 }
110 /*}}}*/
111
112 // Acquire::MethodConfig::MethodConfig - Constructor /*{{{*/
113 // ---------------------------------------------------------------------
114 /* */
115 pkgAcquire::MethodConfig::MethodConfig()
116 {
117 SingleInstance = false;
118 PreScan = false;
119 }
120 /*}}}*/