apt  @VERSION@
pkgsystem.h
00001 // -*- mode: cpp; mode: fold -*-
00002 // Description                                                          /*{{{*/
00003 // $Id: pkgsystem.h,v 1.6 2002/11/11 06:55:50 doogie Exp $
00004 /* ######################################################################
00005 
00006    System - Abstraction for running on different systems.
00007    
00008    Instances of this class can be thought of as factories or meta-classes
00009    for a variety of more specialized classes. Together this class and 
00010    it's speciallized offspring completely define the environment and how
00011    to access resources for a specific system. There are several sub
00012    areas that are all orthogonal - each system has a unique combination of
00013    these sub areas:
00014        - Versioning. Different systems have different ideas on versions.
00015          Within a system all sub classes must follow the same versioning 
00016          rules.
00017        - Local tool locking to prevent multiple tools from accessing the
00018          same database.
00019        - Candidate Version selection policy - this is probably almost always
00020          managed using a standard APT class
00021        - Actual Package installation 
00022          * Indication of what kind of binary formats are supported
00023        - Selection of local 'status' indexes that make up the pkgCache.
00024       
00025    It is important to note that the handling of index files is not a 
00026    function of the system. Index files are handled through a seperate 
00027    abstraction - the only requirement is that the index files have the
00028    same idea of versioning as the target system.
00029    
00030    Upon startup each supported system instantiates an instance of the
00031    pkgSystem class (using a global constructor) which will make itself
00032    available to the main APT init routine. That routine will select the
00033    proper system and make it the global default.
00034    
00035    ##################################################################### */
00036                                                                         /*}}}*/
00037 #ifndef PKGLIB_PKGSYSTEM_H
00038 #define PKGLIB_PKGSYSTEM_H
00039 
00040 #include <apt-pkg/pkgcache.h>
00041 
00042 #include <vector>
00043 
00044 #ifndef APT_8_CLEANER_HEADERS
00045 #include <apt-pkg/depcache.h>
00046 #endif
00047 
00048 class pkgDepCache;
00049 class pkgPackageManager;
00050 class pkgVersioningSystem;
00051 class Configuration;
00052 class pkgIndexFile;
00053 class PkgFileIterator;
00054 
00055 class pkgSystem
00056 {   
00057    public:
00058 
00059    // Global list of supported systems
00060    static pkgSystem **GlobalList;
00061    static unsigned long GlobalListLen;
00062    static pkgSystem *GetSystem(const char *Label);
00063    
00064    const char *Label;
00065    pkgVersioningSystem *VS;
00066    
00067    /* Prevent other programs from touching shared data not covered by
00068       other locks (cache or state locks) */
00069    virtual bool Lock() = 0;
00070    virtual bool UnLock(bool NoErrors = false) = 0;
00071    
00072    /* Various helper classes to interface with specific bits of this
00073       environment */
00074    virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0;
00075 
00076    /* Load environment specific configuration and perform any other setup
00077       necessary */
00078    virtual bool Initialize(Configuration &/*Cnf*/) {return true;};
00079    
00080    /* Type is some kind of Globally Unique way of differentiating
00081       archive file types.. */
00082    virtual bool ArchiveSupported(const char *Type) = 0;
00083 
00084    // Return a list of system index files..
00085    virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;   
00086    virtual bool FindIndex(pkgCache::PkgFileIterator File,
00087                           pkgIndexFile *&Found) const = 0;
00088    
00089    /* Evauluate how 'right' we are for this system based on the filesystem
00090       etc.. */
00091    virtual signed Score(Configuration const &/*Cnf*/) {return 0;};
00092    
00093    pkgSystem();
00094    virtual ~pkgSystem() {};
00095 };
00096 
00097 // The environment we are operating in.
00098 extern pkgSystem *_system;
00099 
00100 #endif