LibPkg
env_packages_table.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 // Copyright � 2003-2005 Graham Shaw.
3 // Copyright � 2018 Alan Buckley.
4 // Distribution and use are subject to the GNU Lesser General Public License,
5 // a copy of which may be found in the file !LibPkg.Copyright.
6 
7 #ifndef LIBPKG_ENV_PACKAGES_TABLE
8 #define LIBPKG_ENV_PACKAGES_TABLE
9 
10 #include "libpkg/version.h"
12 #include "libpkg/env_checker.h"
13 #include <map>
14 
15 namespace pkg {
16 
24  public table,
25  private table::watcher,
26  private env_checker::watcher
27 {
28 public:
29  struct best
30  {
34  string pkgenv;
35 
36  best() {}
41  best(const version& _pkgvrsn, const string &_pkgenv) : pkgvrsn(_pkgvrsn), pkgenv(_pkgenv) {}
42  };
43  typedef std::string key_type;
44  typedef best mapped_type;
45  typedef std::map<key_type,mapped_type>::const_iterator const_iterator;
46 
47 private:
49  binary_control_table *_control;
51  std::map<key_type,mapped_type> _data;
52 
53 public:
55  virtual ~env_packages_table();
56 
60  const_iterator begin() const
61  { return _data.begin(); }
62 
66  const_iterator end() const
67  { return _data.end(); }
68 
73  const_iterator find(const std::string &pkgname) const
74  { return _data.find(pkgname);}
75 
79  const binary_control &control(const std::string &pkgname) const;
80 
84  const best &operator[](const std::string &pkgname) const;
85 
86 private:
87  virtual void handle_change(table& t);
88  virtual void handle_change(env_checker& e);
89  void rebuild();
90 };
91 
92 } /* namespace pkg */
93 
94 #endif /* LIBPKG_LIBPKG_LATEST_CONTROL_TABLE */
const binary_control & control(const std::string &pkgname) const
Get the control record for the "best" package for the environment.
Definition: env_packages_table.cc:25
Class to check environment and convert a string environment specification into a pkg_env There is onl...
Definition: env_checker.h:144
env_packages_table(binary_control_table *control)
Definition: env_packages_table.cc:12
best()
Definition: env_packages_table.h:36
const_iterator begin() const
Get const iterator for start of table.
Definition: env_packages_table.h:60
The namespace used to hold the package management library.
Definition: auto_dir.cc:12
A class that filters the binary control table to create a list of the packages available in the curre...
Definition: env_packages_table.h:23
A mixin class to allow an object to watch one or more tables.
Definition: table.h:51
best mapped_type
Definition: env_packages_table.h:44
version pkgvrsn
The package version.
Definition: env_packages_table.h:32
string pkgenv
The package environment id.
Definition: env_packages_table.h:34
virtual ~env_packages_table()
Definition: env_packages_table.cc:20
A mixin class to allow an object to watch the environment checker.
Definition: env_checker.h:207
best(const version &_pkgvrsn, const string &_pkgenv)
Contruct best type from package name and version.
Definition: env_packages_table.h:41
std::string key_type
Definition: env_packages_table.h:43
Definition: env_packages_table.h:29
A class to represent the content of a RiscPkg control file.
Definition: control.h:24
A class for mapping package name and version to binary control record.
Definition: binary_control_table.h:21
A class to represent a package version.
Definition: version.h:21
std::map< key_type, mapped_type >::const_iterator const_iterator
Definition: env_packages_table.h:45
A class to represent the content of a RiscPkg binary control file.
Definition: binary_control.h:24
const_iterator find(const std::string &pkgname) const
Find a package in the list.
Definition: env_packages_table.h:73
const best & operator[](const std::string &pkgname) const
Get information on the "best" package for the environment.
Definition: env_packages_table.cc:37
const_iterator end() const
Get const iterator for end of table.
Definition: env_packages_table.h:66
A base class to represent a data table.
Definition: table.h:18

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)