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 class pkgDepCache;
00045 class pkgPackageManager;
00046 class pkgVersioningSystem;
00047 class Configuration;
00048 class pkgIndexFile;
00049 class PkgFileIterator;
00050 
00051 class pkgSystem
00052 {   
00053    public:
00054 
00055    // Global list of supported systems
00056    static pkgSystem **GlobalList;
00057    static unsigned long GlobalListLen;
00058    static pkgSystem *GetSystem(const char *Label);
00059    
00060    const char *Label;
00061    pkgVersioningSystem *VS;
00062    
00063    /* Prevent other programs from touching shared data not covered by
00064       other locks (cache or state locks) */
00065    virtual bool Lock() = 0;
00066    virtual bool UnLock(bool NoErrors = false) = 0;
00067    
00068    /* Various helper classes to interface with specific bits of this
00069       environment */
00070    virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0;
00071 
00072    /* Load environment specific configuration and perform any other setup
00073       necessary */
00074    virtual bool Initialize(Configuration &/*Cnf*/) {return true;};
00075    
00076    /* Type is some kind of Globally Unique way of differentiating
00077       archive file types.. */
00078    virtual bool ArchiveSupported(const char *Type) = 0;
00079 
00080    // Return a list of system index files..
00081    virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;   
00082    virtual bool FindIndex(pkgCache::PkgFileIterator File,
00083                           pkgIndexFile *&Found) const = 0;
00084    
00085    /* Evauluate how 'right' we are for this system based on the filesystem
00086       etc.. */
00087    virtual signed Score(Configuration const &/*Cnf*/) {return 0;};
00088    
00089    pkgSystem();
00090    virtual ~pkgSystem() {};
00091 };
00092 
00093 // The environment we are operating in.
00094 extern pkgSystem *_system;
00095 
00096 #endif