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