Sync
[ntk/apt.git] / apt-pkg / acquire-worker.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: acquire-worker.h,v 1.3 1998/10/22 04:56:42 jgg Exp $
4 /* ######################################################################
5
6 Acquire Worker - Worker process manager
7
8 Each worker class is associated with exaclty one subprocess.
9
10 ##################################################################### */
11 /*}}}*/
12 #ifndef PKGLIB_ACQUIRE_WORKER_H
13 #define PKGLIB_ACQUIRE_WORKER_H
14
15 #include <apt-pkg/acquire.h>
16
17 #ifdef __GNUG__
18 #pragma interface "apt-pkg/acquire-worker.h"
19 #endif
20
21 // Interfacing to the method process
22 class pkgAcquire::Worker
23 {
24 friend pkgAcquire;
25
26 protected:
27 friend Queue;
28
29 /* Linked list starting at a Queue and a linked list starting
30 at Acquire */
31 Worker *NextQueue;
32 Worker *NextAcquire;
33
34 // The access association
35 Queue *OwnerQ;
36 MethodConfig *Config;
37 string Access;
38
39 // This is the subprocess IPC setup
40 pid_t Process;
41 int InFd;
42 int OutFd;
43 bool InReady;
44 bool OutReady;
45
46 // Various internal things
47 bool Debug;
48 vector<string> MessageQueue;
49 string OutQueue;
50
51 // Private constructor helper
52 void Construct();
53
54 // Message handling things
55 bool ReadMessages();
56 bool RunMessages();
57 bool InFdReady();
58 bool OutFdReady();
59
60 // The message handlers
61 bool Capabilities(string Message);
62 bool SendConfiguration();
63
64 bool MethodFailure();
65
66 public:
67
68 pkgAcquire::Queue::QItem *CurrentItem;
69
70 string Status;
71
72 // Load the method and do the startup
73 bool QueueItem(pkgAcquire::Queue::QItem *Item);
74 bool Start();
75
76 Worker(Queue *OwnerQ,MethodConfig *Config);
77 Worker(MethodConfig *Config);
78 ~Worker();
79 };
80
81 #endif