]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgsystem.cc
travis: Add coverage testing using codecov.io
[apt.git] / apt-pkg / pkgsystem.cc
CommitLineData
b2e465d6
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
cb063009 3// $Id: pkgsystem.cc,v 1.3 2004/02/27 00:43:16 mdz Exp $
b2e465d6
AL
4/* ######################################################################
5
6 System - Abstraction for running on different systems.
7
8 Basic general structure..
9
10 ##################################################################### */
11 /*}}}*/
12// Include Files /*{{{*/
ea542140
DK
13#include<config.h>
14
8d6d3f00 15#include <apt-pkg/debsystem.h>
b2e465d6 16#include <apt-pkg/pkgsystem.h>
a02db58f
DK
17#include <apt-pkg/macros.h>
18
307d9eb2 19#include <map>
cb063009 20#include <cassert>
4f333a8b 21#include <cstring>
b2e465d6
AL
22 /*}}}*/
23
24pkgSystem *_system = 0;
25static pkgSystem *SysList[10];
26pkgSystem **pkgSystem::GlobalList = SysList;
27unsigned long pkgSystem::GlobalListLen = 0;
28
307d9eb2
DK
29class APT_HIDDEN pkgSystemPrivate /*{{{*/
30{
31public:
32 typedef decltype(pkgCache::Version::ID) idtype;
33 std::map<idtype,idtype> idmap;
34 pkgSystemPrivate() {}
35};
36 /*}}}*/
b2e465d6
AL
37// System::pkgSystem - Constructor /*{{{*/
38// ---------------------------------------------------------------------
39/* Add it to the global list.. */
6c55f07a 40pkgSystem::pkgSystem(char const * const label, pkgVersioningSystem * const vs) :
307d9eb2 41 Label(label), VS(vs), d(new pkgSystemPrivate())
b2e465d6 42{
cb063009 43 assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
b2e465d6 44 SysList[GlobalListLen] = this;
dcaa1185 45 ++GlobalListLen;
b2e465d6
AL
46}
47 /*}}}*/
48// System::GetSystem - Get the named system /*{{{*/
49// ---------------------------------------------------------------------
50/* */
a02db58f 51APT_PURE pkgSystem *pkgSystem::GetSystem(const char *Label)
b2e465d6
AL
52{
53 for (unsigned I = 0; I != GlobalListLen; I++)
54 if (strcmp(SysList[I]->Label,Label) == 0)
55 return SysList[I];
56 return 0;
57}
58 /*}}}*/
8d6d3f00
DK
59bool pkgSystem::MultiArchSupported() const /*{{{*/
60{
61 debSystem const * const deb = dynamic_cast<debSystem const *>(this);
62 if (deb != NULL)
63 return deb->SupportsMultiArch();
64 return true;
65}
66 /*}}}*/
825db890
DK
67std::vector<std::string> pkgSystem::ArchitecturesSupported() const /*{{{*/
68{
69 debSystem const * const deb = dynamic_cast<debSystem const *>(this);
70 if (deb != NULL)
71 return deb->SupportedArchitectures();
72 return {};
73}
74 /*}}}*/
307d9eb2
DK
75// pkgSystem::Set/GetVersionMapping - for internal/external communcation/*{{{*/
76void pkgSystem::SetVersionMapping(map_id_t const in, map_id_t const out)
77{
78 if (in == out)
79 return;
80 d->idmap.emplace(in, out);
81}
82map_id_t pkgSystem::GetVersionMapping(map_id_t const in) const
83{
84 auto const o = d->idmap.find(in);
85 return (o == d->idmap.end()) ? in : o->second;
86}
87 /*}}}*/
c8a4ce6c
DK
88
89pkgSystem::~pkgSystem() {}