File: comps_environment.hpp

package info (click to toggle)
dnf5 5.4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,960 kB
  • sloc: cpp: 94,312; python: 3,370; xml: 1,073; ruby: 600; sql: 250; ansic: 232; sh: 104; perl: 62; makefile: 30
file content (183 lines) | stat: -rw-r--r-- 8,761 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Copyright Contributors to the DNF5 project.
// Copyright Contributors to the libdnf project.
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
//
// Libdnf is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or
// (at your option) any later version.
//
// Libdnf is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libdnf.  If not, see <https://www.gnu.org/licenses/>.

#ifndef LIBDNF5_TRANSACTION_COMPS_ENVIRONMENT_HPP
#define LIBDNF5_TRANSACTION_COMPS_ENVIRONMENT_HPP

#include "comps_group.hpp"

#include "libdnf5/comps/group/package.hpp"
#include "libdnf5/defs.h"

#include <memory>
#include <vector>


namespace libdnf5::transaction {

class Transaction;
class CompsEnvironmentGroup;
class CompsEnvironmentDbUtils;
class CompsEnvironmentGroupDbUtils;


/// CompsEnvironment contains a copy of important data from comps::CompsEnvironment that is used
/// to perform comps transaction and then stored in the transaction (history) database.
///
// @replaces libdnf:transaction/CompsEnvironmentItem.hpp:class:CompsEnvironmentItem
class LIBDNF_API CompsEnvironment : public TransactionItem {
public:
    /// Get string representation of the object, which equals to environment_id
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.toStr()
    std::string to_string() const;

    CompsEnvironment(const CompsEnvironment & src);
    CompsEnvironment & operator=(const CompsEnvironment & src);
    CompsEnvironment(CompsEnvironment && src) noexcept;
    CompsEnvironment & operator=(CompsEnvironment && src) noexcept;
    ~CompsEnvironment();

private:
    friend Transaction;
    friend CompsEnvironmentDbUtils;
    friend CompsEnvironmentGroupDbUtils;

    LIBDNF_LOCAL explicit CompsEnvironment(const Transaction & trans);

    /// Get text id of the environment (xml element: `<comps><environment><id>VALUE</id>...`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getEnvironmentId()
    LIBDNF_LOCAL const std::string & get_environment_id() const noexcept;

    /// Set text id of the environment (xml element: `<comps><environment><id>VALUE</id>...`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setEnvironmentId(const std::string & value)
    LIBDNF_LOCAL void set_environment_id(const std::string & value);

    /// Get name of the environment (xml element: `<comps><environment><name>VALUE</name>...`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getName()
    LIBDNF_LOCAL const std::string & get_name() const noexcept;

    /// Set name of the environment (xml element: `<comps><environment><name>VALUE</name>...`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setName(const std::string & value)
    LIBDNF_LOCAL void set_name(const std::string & value);

    /// Get translated name of the environment in the current locale (xml element: `<comps><environment><name xml:lang="...">VALUE</name>...`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getTranslatedName()
    LIBDNF_LOCAL const std::string & get_translated_name() const noexcept;

    /// Set translated name of the environment in the current locale (xml element: `<comps><environment><name xml:lang="...">VALUE</name>...`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setTranslatedName(const std::string & value)
    LIBDNF_LOCAL void set_translated_name(const std::string & value);

    /// Get types of the packages to be installed with the environment (related xml elements: `<comps><group><packagelist><packagereq type="VALUE" ...>`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getPackageTypes()
    LIBDNF_LOCAL libdnf5::comps::PackageType get_package_types() const noexcept;

    /// Set types of the packages to be installed with the environment (related xml elements: `<comps><group><packagelist><packagereq type="VALUE" ...>`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setPackageTypes(libdnf::CompsPackageType value)
    LIBDNF_LOCAL void set_package_types(libdnf5::comps::PackageType value);

    /// Create a new CompsEnvironmentGroup object and return a reference to it.
    /// The object is owned by the CompsEnvironment.
    LIBDNF_LOCAL CompsEnvironmentGroup & new_group();

    /// Get list of groups associated with the environment.
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getGroups()
    LIBDNF_LOCAL std::vector<CompsEnvironmentGroup> & get_groups();

    // TODO(dmach): rewrite into TransactionSack.list_installed_environments(); how to deal with references to different transactions? We don't want all of them loaded into memory.
    //static std::vector< TransactionItemPtr > getTransactionItemsByPattern(
    //    libdnf5::utils::SQLite3Ptr conn,
    //    const std::string &pattern);

    class LIBDNF_LOCAL Impl;
    std::unique_ptr<Impl> p_impl;
};


// @replaces libdnf:transaction/CompsEnvironmentItem.hpp:class:CompsEnvironmentGroup
class LIBDNF_API CompsEnvironmentGroup {
public:
    ~CompsEnvironmentGroup();
    CompsEnvironmentGroup(const CompsEnvironmentGroup & src);
    CompsEnvironmentGroup & operator=(const CompsEnvironmentGroup & src);
    CompsEnvironmentGroup(CompsEnvironmentGroup && src) noexcept;
    CompsEnvironmentGroup & operator=(CompsEnvironmentGroup && src) noexcept;
    CompsEnvironmentGroup();

private:
    friend Transaction;
    friend CompsEnvironmentGroupDbUtils;

    /// Get database id (primary key)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getId()
    LIBDNF_LOCAL int64_t get_id() const noexcept;

    /// Set database id (primary key)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setId(int64_t value)
    LIBDNF_LOCAL void set_id(int64_t value);

    /// Get groupid of a group associated with a comps environment (xml element: `<comps><environment><grouplist><groupid>VALUE</groupid>`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getGroupId()
    LIBDNF_LOCAL const std::string & get_group_id() const noexcept;

    /// Set groupid of a group associated with a comps environment (xml element: `<comps><environment><grouplist><groupid>VALUE</groupid>`)
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setGroupId(const std::string & value)
    LIBDNF_LOCAL void set_group_id(const std::string & value);

    /// Get a flag that determines if the group was present after the transaction it's associated with has finished.
    /// If the group was installed before running the transaction, it's still counted as installed.
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getInstalled()
    LIBDNF_LOCAL bool get_installed() const noexcept;

    /// Set a flag that determines if the group was present after the transaction it's associated with has finished.
    /// If the group was installed before running the transaction, it's still counted as installed.
    ///
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setInstalled(bool value)
    LIBDNF_LOCAL void set_installed(bool value);

    // TODO(dmach): this is not entirely clear; investigate and document
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getGroupType()
    LIBDNF_LOCAL libdnf5::comps::PackageType get_group_type() const noexcept;

    // TODO(dmach): this is not entirely clear; investigate and document
    // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setGroupType(libdnf::CompsPackageType value)
    LIBDNF_LOCAL void set_group_type(libdnf5::comps::PackageType value);

    class LIBDNF_LOCAL Impl;
    std::unique_ptr<Impl> p_impl;
};

}  // namespace libdnf5::transaction

#endif  // LIBDNF5_TRANSACTION_COMPS_ENVIRONMENT_HPP