1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgsystem.cc,v 1.3 2004/02/27 00:43:16 mdz Exp $
4 /* ######################################################################
6 System - Abstraction for running on different systems.
8 Basic general structure..
10 ##################################################################### */
12 // Include Files /*{{{*/
15 #include <apt-pkg/debsystem.h>
16 #include <apt-pkg/pkgsystem.h>
17 #include <apt-pkg/macros.h>
24 pkgSystem
*_system
= 0;
25 static pkgSystem
*SysList
[10];
26 pkgSystem
**pkgSystem::GlobalList
= SysList
;
27 unsigned long pkgSystem::GlobalListLen
= 0;
29 class APT_HIDDEN pkgSystemPrivate
/*{{{*/
32 typedef decltype(pkgCache::Version::ID
) idtype
;
33 std::map
<idtype
,idtype
> idmap
;
37 // System::pkgSystem - Constructor /*{{{*/
38 // ---------------------------------------------------------------------
39 /* Add it to the global list.. */
40 pkgSystem::pkgSystem(char const * const label
, pkgVersioningSystem
* const vs
) :
41 Label(label
), VS(vs
), d(new pkgSystemPrivate())
43 assert(GlobalListLen
< sizeof(SysList
)/sizeof(*SysList
));
44 SysList
[GlobalListLen
] = this;
48 // System::GetSystem - Get the named system /*{{{*/
49 // ---------------------------------------------------------------------
51 APT_PURE pkgSystem
*pkgSystem::GetSystem(const char *Label
)
53 for (unsigned I
= 0; I
!= GlobalListLen
; I
++)
54 if (strcmp(SysList
[I
]->Label
,Label
) == 0)
59 bool pkgSystem::MultiArchSupported() const /*{{{*/
61 debSystem
const * const deb
= dynamic_cast<debSystem
const *>(this);
63 return deb
->SupportsMultiArch();
67 std::vector
<std::string
> pkgSystem::ArchitecturesSupported() const /*{{{*/
69 debSystem
const * const deb
= dynamic_cast<debSystem
const *>(this);
71 return deb
->SupportedArchitectures();
75 // pkgSystem::Set/GetVersionMapping - for internal/external communcation/*{{{*/
76 void pkgSystem::SetVersionMapping(map_id_t
const in
, map_id_t
const out
)
80 d
->idmap
.emplace(in
, out
);
82 map_id_t
pkgSystem::GetVersionMapping(map_id_t
const in
) const
84 auto const o
= d
->idmap
.find(in
);
85 return (o
== d
->idmap
.end()) ? in
: o
->second
;
89 pkgSystem::~pkgSystem() {}