1 /* 2 * Copyright (C) 2017-2018 Red Hat, Inc. 3 * 4 * Licensed under the GNU Lesser General Public License Version 2.1 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef LIBDNF_TRANSACTION_TRANSACTION_PRIVATE_HPP 22 #define LIBDNF_TRANSACTION_TRANSACTION_PRIVATE_HPP 23 24 #include "../Transaction.hpp" 25 26 namespace libdnf { 27 namespace swdb_private { 28 29 class Transaction; 30 typedef std::shared_ptr< Transaction > TransactionPtr; 31 32 class Transaction : public libdnf::Transaction { 33 public: 34 // create an empty object, don't read from db 35 explicit Transaction(SQLite3Ptr conn); 36 setId(int64_t value)37 void setId(int64_t value) { id = value; } setDtBegin(int64_t value)38 void setDtBegin(int64_t value) { dtBegin = value; } setDtEnd(int64_t value)39 void setDtEnd(int64_t value) { dtEnd = value; } setRpmdbVersionBegin(const std::string & value)40 void setRpmdbVersionBegin(const std::string &value) { rpmdbVersionBegin = value; } setRpmdbVersionEnd(const std::string & value)41 void setRpmdbVersionEnd(const std::string &value) { rpmdbVersionEnd = value; } setReleasever(const std::string & value)42 void setReleasever(const std::string &value) { releasever = value; } setUserId(uint32_t value)43 void setUserId(uint32_t value) { userId = value; } setCmdline(const std::string & value)44 void setCmdline(const std::string &value) { cmdline = value; } setState(TransactionState value)45 void setState(TransactionState value) { state = value; } setComment(const std::string & value)46 void setComment(const std::string &value) { comment = value; } 47 48 std::vector< TransactionItemPtr > getItems() override; 49 50 void begin(); 51 void finish(TransactionState state); 52 TransactionItemPtr addItem(std::shared_ptr< Item > item, 53 const std::string &repoid, 54 TransactionItemAction action, 55 TransactionItemReason reason); 56 57 void addConsoleOutputLine(int fileDescriptor, const std::string &line); 58 void addSoftwarePerformedWith(std::shared_ptr< RPMItem > software); 59 60 protected: 61 void saveItems(); 62 std::vector< TransactionItemPtr > items; 63 64 void dbInsert(); 65 void dbUpdate(); 66 }; 67 68 } 69 } 70 71 #endif // LIBDNF_TRANSACTION_TRANSACTION_PRIVATE_HPP 72