Skip to content

Commit

Permalink
Remove boost::optional in Transaction_Owner, get_transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
mmd-osm committed Jul 26, 2019
1 parent 4434438 commit 966a354
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 deletions include/cgimap/backend/apidb/transaction_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Transaction_Owner_Base
{
public:
Transaction_Owner_Base() {}
virtual boost::optional<pqxx::transaction_base&> get_transaction() = 0;
virtual pqxx::transaction_base& get_transaction() = 0;
virtual ~Transaction_Owner_Base() {}
};

Expand All @@ -23,7 +23,7 @@ class Transaction_Owner_ReadOnly : public Transaction_Owner_Base
{
public:
explicit Transaction_Owner_ReadOnly(pqxx::connection &conn);
virtual boost::optional<pqxx::transaction_base&> get_transaction();
virtual pqxx::transaction_base& get_transaction();
~Transaction_Owner_ReadOnly() {}

private:
Expand All @@ -35,7 +35,7 @@ class Transaction_Owner_ReadWrite : public Transaction_Owner_Base
{
public:
explicit Transaction_Owner_ReadWrite(pqxx::connection &conn);
virtual boost::optional<pqxx::transaction_base&> get_transaction();
virtual pqxx::transaction_base& get_transaction();
~Transaction_Owner_ReadWrite() {}

private:
Expand All @@ -46,11 +46,11 @@ class Transaction_Owner_Void : public Transaction_Owner_Base
{
public:
explicit Transaction_Owner_Void();
virtual boost::optional<pqxx::transaction_base&> get_transaction();
virtual pqxx::transaction_base& get_transaction();
~Transaction_Owner_Void() {}
};

/******************************************************************************************/


class Transaction_Manager {

Expand Down
6 changes: 3 additions & 3 deletions src/backend/apidb/transaction_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

Transaction_Owner_ReadOnly::Transaction_Owner_ReadOnly( pqxx::connection &conn) : m_txn{ conn } {};

boost::optional<pqxx::transaction_base&> Transaction_Owner_ReadOnly::get_transaction() { return m_txn; }
pqxx::transaction_base& Transaction_Owner_ReadOnly::get_transaction() { return m_txn; }

Transaction_Owner_ReadWrite::Transaction_Owner_ReadWrite( pqxx::connection &conn) : m_txn{ conn } {};

boost::optional<pqxx::transaction_base&> Transaction_Owner_ReadWrite::get_transaction() { return m_txn; }
pqxx::transaction_base& Transaction_Owner_ReadWrite::get_transaction() { return m_txn; }


Transaction_Manager::Transaction_Manager(Transaction_Owner_Base &to) : m_txn{ *to.get_transaction() } {}
Transaction_Manager::Transaction_Manager(Transaction_Owner_Base &to) : m_txn{ to.get_transaction() } {}

void Transaction_Manager::prepare(const std::string &name,
const std::string &definition) {
Expand Down
4 changes: 3 additions & 1 deletion src/backend/staticxml/staticxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ using api06::id_version;

Transaction_Owner_Void::Transaction_Owner_Void() {};

boost::optional<pqxx::transaction_base&>Transaction_Owner_Void::get_transaction() { return boost::none; }
pqxx::transaction_base& Transaction_Owner_Void::get_transaction() {
throw std::runtime_error ("get_transaction is not supported by Transaction_Owner_Void");
}


namespace {
Expand Down
4 changes: 3 additions & 1 deletion test/test_basicauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

Transaction_Owner_Void::Transaction_Owner_Void() {};

boost::optional<pqxx::transaction_base&>Transaction_Owner_Void::get_transaction() { return boost::none; }
pqxx::transaction_base& Transaction_Owner_Void::get_transaction() {
throw std::runtime_error("get_transaction is not supported by Transaction_Owner_Void");
}

namespace {

Expand Down

0 comments on commit 966a354

Please # to comment.