LibPkg
component_update.h
Go to the documentation of this file.
1 // This file is part of the LibPkg.
2 //
3 // Copyright 2013-2020 Alan Buckley
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef LIBPKG_COMPONENT_UPDATE
18 #define LIBPKG_COMPONENT_UPDATE
19 
20 #include <vector>
21 #include <string>
22 
23 #include "libpkg/component.h"
24 
25 namespace pkg {
26 
27 using std::string;
28 
31 {
32 public:
33  typedef std::vector<component>::const_iterator const_iterator;
34  class commit_error;
35 private:
38  string _pathname;
39 
41  std::vector<component> _data;
42 public:
47  component_update(const string& pathname=string());
48 
50  virtual ~component_update();
51 
57  const component& operator[](const std::string &name) const;
58 
62  const_iterator begin() const
63  { return _data.begin(); }
64 
68  const_iterator end() const
69  { return _data.end(); }
70 
75  const_iterator find(const std::string& name) const;
76 
82  void insert(const component& value);
83 
85  void insert(const component_update& table);
86 
87 
89  void clear();
90 
95  void commit();
96 
101  void rollback();
102 
104  void done();
105 private:
110  bool read(const string& pathname);
111 };
112 
115  public std::runtime_error
116 {
117 public:
119  commit_error();
120 };
121 
122 }; /* namespace pkg */
123 
124 #endif
const_iterator begin() const
Get const iterator for start of the updates.
Definition: component_update.h:62
const_iterator end() const
Get const iterator for end of the updates.
Definition: component_update.h:68
const_iterator find(const std::string &name) const
Find const iterator for a component name.
Definition: component_update.cc:43
The namespace used to hold the package management library.
Definition: auto_dir.cc:23
const component & operator[](const std::string &name) const
Get component details for a component name The updates cannot be modified using this operator...
Definition: component_update.cc:33
virtual ~component_update()
Destroy component update.
Definition: component_update.cc:30
A class for managing the updating of package components.
Definition: component_update.h:30
void clear()
Clear status of all components.
Definition: component_update.cc:74
component_update(const string &pathname=string())
Construct component update.
Definition: component_update.cc:24
A class to represent a component of a package.
Definition: component.h:38
void rollback()
Roll back changes.
Definition: component_update.cc:119
An exception class for reporting failure to commit table.
Definition: component_update.h:114
void done()
The updates have been completed, so remove the file.
Definition: component_update.cc:130
void commit()
Commit changes.
Definition: component_update.cc:79
A base class to represent a data table.
Definition: table.h:29
std::vector< component >::const_iterator const_iterator
Definition: component_update.h:33
void insert(const component &value)
Add a component.
Definition: component_update.cc:53

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)