]> git.saurik.com Git - apt.git/blame_incremental - apt-pkg/pkgsystem.cc
close server if parsing of header field failed
[apt.git] / apt-pkg / pkgsystem.cc
... / ...
CommitLineData
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3// $Id: pkgsystem.cc,v 1.3 2004/02/27 00:43:16 mdz Exp $
4/* ######################################################################
5
6 System - Abstraction for running on different systems.
7
8 Basic general structure..
9
10 ##################################################################### */
11 /*}}}*/
12// Include Files /*{{{*/
13#include<config.h>
14
15#include <apt-pkg/debsystem.h>
16#include <apt-pkg/pkgsystem.h>
17#include <apt-pkg/macros.h>
18
19#include <map>
20#include <cassert>
21#include <cstring>
22 /*}}}*/
23
24pkgSystem *_system = 0;
25static pkgSystem *SysList[10];
26pkgSystem **pkgSystem::GlobalList = SysList;
27unsigned long pkgSystem::GlobalListLen = 0;
28
29class APT_HIDDEN pkgSystemPrivate /*{{{*/
30{
31public:
32 typedef decltype(pkgCache::Version::ID) idtype;
33 std::map<idtype,idtype> idmap;
34 pkgSystemPrivate() {}
35};
36 /*}}}*/
37// System::pkgSystem - Constructor /*{{{*/
38// ---------------------------------------------------------------------
39/* Add it to the global list.. */
40pkgSystem::pkgSystem(char const * const label, pkgVersioningSystem * const vs) :
41 Label(label), VS(vs), d(new pkgSystemPrivate())
42{
43 assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList));
44 SysList[GlobalListLen] = this;
45 ++GlobalListLen;
46}
47 /*}}}*/
48// System::GetSystem - Get the named system /*{{{*/
49// ---------------------------------------------------------------------
50/* */
51APT_PURE pkgSystem *pkgSystem::GetSystem(const char *Label)
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 /*}}}*/
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 /*}}}*/
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 /*}}}*/
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 /*}}}*/
88
89pkgSystem::~pkgSystem() {}