pkgsystem.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgsystem.h,v 1.6 2002/11/11 06:55:50 doogie 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 specialized 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 separate
  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. #include <apt-pkg/pkgcache.h>
  35. #include <vector>
  36. #ifndef APT_8_CLEANER_HEADERS
  37. #include <apt-pkg/depcache.h>
  38. #endif
  39. class pkgDepCache;
  40. class pkgPackageManager;
  41. class pkgVersioningSystem;
  42. class Configuration;
  43. class pkgIndexFile;
  44. class PkgFileIterator;
  45. class pkgSystem
  46. {
  47. public:
  48. // Global list of supported systems
  49. static pkgSystem **GlobalList;
  50. static unsigned long GlobalListLen;
  51. static pkgSystem *GetSystem(const char *Label);
  52. const char *Label;
  53. pkgVersioningSystem *VS;
  54. /* Prevent other programs from touching shared data not covered by
  55. other locks (cache or state locks) */
  56. virtual bool Lock() = 0;
  57. virtual bool UnLock(bool NoErrors = false) = 0;
  58. /* Various helper classes to interface with specific bits of this
  59. environment */
  60. virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0;
  61. /* Load environment specific configuration and perform any other setup
  62. necessary */
  63. virtual bool Initialize(Configuration &/*Cnf*/) {return true;};
  64. /* Type is some kind of Globally Unique way of differentiating
  65. archive file types.. */
  66. virtual bool ArchiveSupported(const char *Type) = 0;
  67. // Return a list of system index files..
  68. virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;
  69. virtual bool FindIndex(pkgCache::PkgFileIterator File,
  70. pkgIndexFile *&Found) const = 0;
  71. /* Evauluate how 'right' we are for this system based on the filesystem
  72. etc.. */
  73. virtual signed Score(Configuration const &/*Cnf*/) {return 0;};
  74. pkgSystem();
  75. virtual ~pkgSystem() {};
  76. };
  77. // The environment we are operating in.
  78. extern pkgSystem *_system;
  79. #endif