]>
Commit | Line | Data |
---|---|---|
1 | // -*- mode: cpp; mode: fold -*- | |
2 | // Description /*{{{*/ | |
3 | /* ###################################################################### | |
4 | ||
5 | System - Abstraction for running on different systems. | |
6 | ||
7 | Instances of this class can be thought of as factories or meta-classes | |
8 | for a variety of more specialized classes. Together this class and | |
9 | it's specialized offspring completely define the environment and how | |
10 | to access resources for a specific system. There are several sub | |
11 | areas that are all orthogonal - each system has a unique combination of | |
12 | these sub areas: | |
13 | - Versioning. Different systems have different ideas on versions. | |
14 | Within a system all sub classes must follow the same versioning | |
15 | rules. | |
16 | - Local tool locking to prevent multiple tools from accessing the | |
17 | same database. | |
18 | - Candidate Version selection policy - this is probably almost always | |
19 | managed using a standard APT class | |
20 | - Actual Package installation | |
21 | * Indication of what kind of binary formats are supported | |
22 | - Selection of local 'status' indexes that make up the pkgCache. | |
23 | ||
24 | It is important to note that the handling of index files is not a | |
25 | function of the system. Index files are handled through a separate | |
26 | abstraction - the only requirement is that the index files have the | |
27 | same idea of versioning as the target system. | |
28 | ||
29 | Upon startup each supported system instantiates an instance of the | |
30 | pkgSystem class (using a global constructor) which will make itself | |
31 | available to the main APT init routine. That routine will select the | |
32 | proper system and make it the global default. | |
33 | ||
34 | ##################################################################### */ | |
35 | /*}}}*/ | |
36 | #ifndef PKGLIB_PKGSYSTEM_H | |
37 | #define PKGLIB_PKGSYSTEM_H | |
38 | ||
39 | #include <apt-pkg/pkgcache.h> | |
40 | #include <apt-pkg/cacheiterators.h> | |
41 | ||
42 | #include <vector> | |
43 | ||
44 | #ifndef APT_8_CLEANER_HEADERS | |
45 | #include <apt-pkg/depcache.h> | |
46 | #endif | |
47 | ||
48 | class pkgDepCache; | |
49 | class pkgPackageManager; | |
50 | class pkgVersioningSystem; | |
51 | class Configuration; | |
52 | class pkgIndexFile; | |
53 | ||
54 | class pkgSystem | |
55 | { | |
56 | public: | |
57 | ||
58 | // Global list of supported systems | |
59 | static pkgSystem **GlobalList; | |
60 | static unsigned long GlobalListLen; | |
61 | static pkgSystem *GetSystem(const char *Label); | |
62 | ||
63 | const char * const Label; | |
64 | pkgVersioningSystem * const VS; | |
65 | ||
66 | /* Prevent other programs from touching shared data not covered by | |
67 | other locks (cache or state locks) */ | |
68 | virtual bool Lock() = 0; | |
69 | virtual bool UnLock(bool NoErrors = false) = 0; | |
70 | ||
71 | /* Various helper classes to interface with specific bits of this | |
72 | environment */ | |
73 | virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0; | |
74 | ||
75 | /* Load environment specific configuration and perform any other setup | |
76 | necessary */ | |
77 | virtual bool Initialize(Configuration &/*Cnf*/) {return true;}; | |
78 | ||
79 | /* Type is some kind of Globally Unique way of differentiating | |
80 | archive file types.. */ | |
81 | virtual bool ArchiveSupported(const char *Type) = 0; | |
82 | ||
83 | // Return a list of system index files.. | |
84 | virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0; | |
85 | ||
86 | virtual bool FindIndex(pkgCache::PkgFileIterator File, | |
87 | pkgIndexFile *&Found) const = 0; | |
88 | ||
89 | /* Evauluate how 'right' we are for this system based on the filesystem | |
90 | etc.. */ | |
91 | virtual signed Score(Configuration const &/*Cnf*/) { | |
92 | return 0; | |
93 | }; | |
94 | ||
95 | //FIXME: these methods should be virtual | |
96 | /** does this system has support for MultiArch? | |
97 | * | |
98 | * Systems supporting only single arch (not systems which are single arch) | |
99 | * are considered legacy systems and support for it will likely degrade over | |
100 | * time. | |
101 | * | |
102 | * The default implementation returns always \b true. | |
103 | * | |
104 | * @return \b true if the system supports MultiArch, \b false if not. | |
105 | */ | |
106 | bool MultiArchSupported() const; | |
107 | /** architectures supported by this system | |
108 | * | |
109 | * A MultiArch capable system might be configured to use | |
110 | * this capability. | |
111 | * | |
112 | * @return a list of all architectures (native + foreign) configured | |
113 | * for on this system (aka: which can be installed without force) | |
114 | */ | |
115 | std::vector<std::string> ArchitecturesSupported() const; | |
116 | ||
117 | pkgSystem(char const * const Label, pkgVersioningSystem * const VS); | |
118 | virtual ~pkgSystem(); | |
119 | private: | |
120 | void * const d; | |
121 | }; | |
122 | ||
123 | // The environment we are operating in. | |
124 | extern pkgSystem *_system; | |
125 | ||
126 | #endif |