Skip to content

Commit

Permalink
Add pImpl to libdnf5::transaction::Transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
kontura committed Jan 18, 2024
1 parent cd767da commit b170a45
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 69 deletions.
71 changes: 30 additions & 41 deletions include/libdnf5/transaction/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ class Transaction {
public:
using State = TransactionState;

virtual ~Transaction() = default;
virtual ~Transaction();

Transaction(const Transaction & src);
Transaction & operator=(const Transaction & src);

Transaction(Transaction && src) noexcept;
Transaction & operator=(Transaction && src) noexcept;


bool operator==(const Transaction & other) const;
bool operator<(const Transaction & other) const;
Expand All @@ -90,52 +97,52 @@ class Transaction {
/// Return 0 if the id wasn't set yet
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.getId()
int64_t get_id() const noexcept { return id; }
int64_t get_id() const noexcept;

/// Get date and time of the transaction start
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.get_dt_begin()
int64_t get_dt_start() const noexcept { return dt_begin; }
int64_t get_dt_start() const noexcept;

/// Get date and time of the transaction end
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.get_dt_begin()
int64_t get_dt_end() const noexcept { return dt_end; }
int64_t get_dt_end() const noexcept;

/// Get RPM database version before the transaction
/// Format: `<rpm_count>`:`<sha1 of sorted SHA1HEADER fields of installed RPMs>`
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.get_rpmdb_version_begin()
const std::string & get_rpmdb_version_begin() const noexcept { return rpmdb_version_begin; }
const std::string & get_rpmdb_version_begin() const noexcept;

/// Get RPM database version after the transaction
/// Format: `<rpm_count>`:`<sha1 of sorted SHA1HEADER fields of installed RPMs>`
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.get_rpmdb_version_end()
const std::string & get_rpmdb_version_end() const noexcept { return rpmdb_version_end; }
const std::string & get_rpmdb_version_end() const noexcept;

/// Get $releasever variable value that was used during the transaction
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.get_releasever()
const std::string & get_releasever() const noexcept { return releasever; }
const std::string & get_releasever() const noexcept;

/// Get UID of a user that started the transaction
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.get_user_id()
uint32_t get_user_id() const noexcept { return user_id; }
uint32_t get_user_id() const noexcept;

/// Get the description of the transaction (e.g. the CLI command that was executed)
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.get_cmdline()
const std::string & get_description() const noexcept { return description; }
const std::string & get_description() const noexcept;

/// Get a user-specified comment describing the transaction
const std::string & get_comment() const noexcept { return comment; }
const std::string & get_comment() const noexcept;

/// Get transaction state
///
// @replaces libdnf:transaction/Transaction.hpp:method:Transaction.getState()
State get_state() const noexcept { return state; }
State get_state() const noexcept;

/// Return all comps environments associated with the transaction
///
Expand Down Expand Up @@ -182,52 +189,52 @@ class Transaction {
/// Set Transaction database id (primary key)
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setId(int64_t value)
void set_id(int64_t value) { id = value; }
void set_id(int64_t value);

/// Set a user-specified comment describing the transaction
void set_comment(const std::string & value) { comment = value; }
void set_comment(const std::string & value);

/// Set date and time of the transaction start
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setDtBegin(int64_t value)
void set_dt_start(int64_t value) { dt_begin = value; }
void set_dt_start(int64_t value);

/// Set date and time of the transaction end
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setDtEnd(int64_t value)
void set_dt_end(int64_t value) { dt_end = value; }
void set_dt_end(int64_t value);

/// Set the description of the transaction (e.g. the CLI command that was executed)
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setCmdline(const std::string & value)
void set_description(const std::string & value) { description = value; }
void set_description(const std::string & value);

/// Set UID of a user that started the transaction
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setUserId(uint32_t value)
void set_user_id(uint32_t value) { user_id = value; }
void set_user_id(uint32_t value);

/// Set $releasever variable value that was used during the transaction
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setReleasever(const std::string & value)
void set_releasever(const std::string & value) { releasever = value; }
void set_releasever(const std::string & value);

/// Set RPM database version after the transaction
/// Format: `<rpm_count>`:`<sha1 of sorted SHA1HEADER fields of installed RPMs>`
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setRpmdbVersionEnd(const std::string & value)
void set_rpmdb_version_end(const std::string & value) { rpmdb_version_end = value; }
void set_rpmdb_version_end(const std::string & value);

/// Set RPM database version before the transaction
/// Format: `<rpm_count>`:`<sha1 of sorted SHA1HEADER fields of installed RPMs>`
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setRpmdbVersionBegin(const std::string & value)
void set_rpmdb_version_begin(const std::string & value) { rpmdb_version_begin = value; }
void set_rpmdb_version_begin(const std::string & value);

/// Set transaction state
///
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setState(libdnf::TransactionState value)
void set_state(State value) { state = value; }
void set_state(State value);

/// Create a new rpm package in the transaction and return a reference to it.
/// The package is owned by the transaction.
Expand Down Expand Up @@ -274,26 +281,8 @@ class Transaction {
// @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.finish(libdnf::TransactionState state)
void finish(TransactionState state);

int64_t id{0};

int64_t dt_begin = 0;
int64_t dt_end = 0;
std::string rpmdb_version_begin;
std::string rpmdb_version_end;
// TODO(dmach): move to a new "vars" table?
std::string releasever;
uint32_t user_id = 0;
std::string description;
std::string comment;
State state = State::STARTED;

std::optional<std::vector<std::pair<int, std::string>>> console_output;

std::optional<std::vector<CompsEnvironment>> comps_environments;
std::optional<std::vector<CompsGroup>> comps_groups;
std::optional<std::vector<Package>> packages;

BaseWeakPtr base;
class Impl;
std::unique_ptr<Impl> p_impl;
};

} // namespace libdnf5::transaction
Expand Down
Loading

0 comments on commit b170a45

Please sign in to comment.