pkgsystem.cc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgsystem.cc,v 1.3 2004/02/27 00:43:16 mdz Exp $
  4. /* ######################################################################
  5. System - Abstraction for running on different systems.
  6. Basic general structure..
  7. ##################################################################### */
  8. /*}}}*/
  9. // Include Files /*{{{*/
  10. #include<config.h>
  11. #include <apt-pkg/debsystem.h>
  12. #include <apt-pkg/pkgsystem.h>
  13. #include <apt-pkg/macros.h>
  14. #include <cassert>
  15. #include <cstring>
  16. /*}}}*/
  17. pkgSystem *_system = 0;
  18. static pkgSystem *SysList[10];
  19. pkgSystem **pkgSystem::GlobalList = SysList;
  20. unsigned long pkgSystem::GlobalListLen = 0;
  21. // System::pkgSystem - Constructor /*{{{*/
  22. // ---------------------------------------------------------------------
  23. /* Add it to the global list.. */
  24. pkgSystem::pkgSystem(char const * const label, pkgVersioningSystem * const vs) :
  25. Label(label), VS(vs), d(NULL)
  26. {
  27. assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
  28. SysList[GlobalListLen] = this;
  29. ++GlobalListLen;
  30. }
  31. /*}}}*/
  32. // System::GetSystem - Get the named system /*{{{*/
  33. // ---------------------------------------------------------------------
  34. /* */
  35. APT_PURE pkgSystem *pkgSystem::GetSystem(const char *Label)
  36. {
  37. for (unsigned I = 0; I != GlobalListLen; I++)
  38. if (strcmp(SysList[I]->Label,Label) == 0)
  39. return SysList[I];
  40. return 0;
  41. }
  42. /*}}}*/
  43. bool pkgSystem::MultiArchSupported() const /*{{{*/
  44. {
  45. debSystem const * const deb = dynamic_cast<debSystem const *>(this);
  46. if (deb != NULL)
  47. return deb->SupportsMultiArch();
  48. return true;
  49. }
  50. /*}}}*/
  51. std::vector<std::string> pkgSystem::ArchitecturesSupported() const /*{{{*/
  52. {
  53. debSystem const * const deb = dynamic_cast<debSystem const *>(this);
  54. if (deb != NULL)
  55. return deb->SupportedArchitectures();
  56. return {};
  57. }
  58. /*}}}*/
  59. pkgSystem::~pkgSystem() {}