]>
Commit | Line | Data |
---|---|---|
b2e465d6 AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
584e4558 | 3 | // $Id: pkgsystem.h,v 1.6 2002/11/11 06:55:50 doogie Exp $ |
b2e465d6 AL |
4 | /* ###################################################################### |
5 | ||
6 | System - Abstraction for running on different systems. | |
7 | ||
8 | Instances of this class can be thought of as factories or meta-classes | |
9 | for a variety of more specialized classes. Together this class and | |
10 | it's speciallized offspring completely define the environment and how | |
11 | to access resources for a specific system. There are several sub | |
12 | areas that are all orthogonal - each system has a unique combination of | |
13 | these sub areas: | |
14 | - Versioning. Different systems have different ideas on versions. | |
15 | Within a system all sub classes must follow the same versioning | |
16 | rules. | |
17 | - Local tool locking to prevent multiple tools from accessing the | |
18 | same database. | |
19 | - Candidate Version selection policy - this is probably almost always | |
20 | managed using a standard APT class | |
21 | - Actual Package installation | |
22 | * Indication of what kind of binary formats are supported | |
23 | - Selection of local 'status' indexes that make up the pkgCache. | |
24 | ||
25 | It is important to note that the handling of index files is not a | |
26 | function of the system. Index files are handled through a seperate | |
27 | abstraction - the only requirement is that the index files have the | |
28 | same idea of versioning as the target system. | |
29 | ||
30 | Upon startup each supported system instantiates an instance of the | |
31 | pkgSystem class (using a global constructor) which will make itself | |
32 | available to the main APT init routine. That routine will select the | |
33 | proper system and make it the global default. | |
34 | ||
35 | ##################################################################### */ | |
36 | /*}}}*/ | |
37 | #ifndef PKGLIB_PKGSYSTEM_H | |
38 | #define PKGLIB_PKGSYSTEM_H | |
39 | ||
472ff00e | 40 | #include <apt-pkg/pkgcache.h> |
b2e465d6 | 41 | |
90f057fd | 42 | #include <vector> |
472ff00e DK |
43 | |
44 | class pkgDepCache; | |
b2e465d6 AL |
45 | class pkgPackageManager; |
46 | class pkgVersioningSystem; | |
47 | class Configuration; | |
48 | class pkgIndexFile; | |
472ff00e | 49 | class PkgFileIterator; |
b2e465d6 AL |
50 | |
51 | class pkgSystem | |
52 | { | |
53 | public: | |
54 | ||
55 | // Global list of supported systems | |
56 | static pkgSystem **GlobalList; | |
57 | static unsigned long GlobalListLen; | |
58 | static pkgSystem *GetSystem(const char *Label); | |
59 | ||
60 | const char *Label; | |
61 | pkgVersioningSystem *VS; | |
62 | ||
63 | /* Prevent other programs from touching shared data not covered by | |
64 | other locks (cache or state locks) */ | |
65 | virtual bool Lock() = 0; | |
66 | virtual bool UnLock(bool NoErrors = false) = 0; | |
67 | ||
68 | /* Various helper classes to interface with specific bits of this | |
69 | environment */ | |
70 | virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0; | |
71 | ||
72 | /* Load environment specific configuration and perform any other setup | |
73 | necessary */ | |
db5c1b54 | 74 | virtual bool Initialize(Configuration &/*Cnf*/) {return true;}; |
b2e465d6 AL |
75 | |
76 | /* Type is some kind of Globally Unique way of differentiating | |
77 | archive file types.. */ | |
78 | virtual bool ArchiveSupported(const char *Type) = 0; | |
79 | ||
80 | // Return a list of system index files.. | |
584e4558 | 81 | virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0; |
af87ab54 AL |
82 | virtual bool FindIndex(pkgCache::PkgFileIterator File, |
83 | pkgIndexFile *&Found) const = 0; | |
b2e465d6 AL |
84 | |
85 | /* Evauluate how 'right' we are for this system based on the filesystem | |
86 | etc.. */ | |
db5c1b54 | 87 | virtual signed Score(Configuration const &/*Cnf*/) {return 0;}; |
b2e465d6 AL |
88 | |
89 | pkgSystem(); | |
90 | virtual ~pkgSystem() {}; | |
91 | }; | |
92 | ||
93 | // The environment we are operating in. | |
94 | extern pkgSystem *_system; | |
95 | ||
96 | #endif |