pkgsystem.h 3.4 KB

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