apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pkgsystem.cc
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  System - Abstraction for running on different systems.
6 
7  Basic general structure..
8 
9  ##################################################################### */
10  /*}}}*/
11 // Include Files /*{{{*/
12 #include <config.h>
13 
14 #include <apt-pkg/debsystem.h>
15 #include <apt-pkg/error.h>
16 #include <apt-pkg/macros.h>
17 #include <apt-pkg/pkgsystem.h>
18 
19 #include <cassert>
20 #include <cstring>
21 #include <map>
22  /*}}}*/
23 
25 static pkgSystem *SysList[10];
27 unsigned long pkgSystem::GlobalListLen = 0;
28 
30 {
31 public:
32  typedef decltype(pkgCache::Version::ID) idtype;
33  std::map<idtype,idtype> idmap;
35 };
36  /*}}}*/
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())
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 /* */
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  /*}}}*/
59 // pkgSystem::Set/GetVersionMapping - for internal/external communication/*{{{*/
61 {
62  if (in == out)
63  return;
64  d->idmap.emplace(in, out);
65 }
67 {
68  auto const o = d->idmap.find(in);
69  return (o == d->idmap.end()) ? in : o->second;
70 }
71  /*}}}*/
static bool std::string const metaIndex const *const pkgAcqMetaClearSig *const pkgAcquire::Item *const I
std::map< idtype, idtype > idmap
Definition: pkgsystem.cc:33
decltype(pkgCache::Version::ID) typedef idtype
Definition: pkgsystem.cc:32
static pkgSystem ** GlobalList
Definition: pkgsystem.h:57
pkgSystem(char const *const Label, pkgVersioningSystem *const VS)
Definition: pkgsystem.cc:40
APT_HIDDEN map_id_t GetVersionMapping(map_id_t const in) const
Definition: pkgsystem.cc:66
pkgSystemPrivate *const d
Definition: pkgsystem.h:133
const char *const Label
Definition: pkgsystem.h:61
static unsigned long GlobalListLen
Definition: pkgsystem.h:58
virtual ~pkgSystem()
Definition: pkgsystem.cc:72
static pkgSystem * GetSystem(const char *Label)
Definition: pkgsystem.cc:51
APT_HIDDEN void SetVersionMapping(map_id_t const in, map_id_t const out)
Definition: pkgsystem.cc:60
#define APT_PURE
Definition: macros.h:56
#define APT_HIDDEN
Definition: macros.h:78
uint32_t map_id_t
Definition: pkgcache.h:93
static pkgSystem * SysList[10]
Definition: pkgsystem.cc:25
pkgSystem * _system
Definition: pkgsystem.cc:24
map_id_t ID
unique sequel ID
Definition: pkgcache.h:686