2828#include " ./internal/export.hpp"
2929#include " ./sender.hpp"
3030#include " ./tracker.hpp"
31+ #include " ./container.hpp"
3132
3233// / @file
3334// / @copybrief proton::transaction
@@ -36,16 +37,57 @@ namespace proton {
3637
3738class transaction_handler ;
3839
40+ // TODO: This should not be accessible to users.
41+ class transaction_impl {
42+ public:
43+ proton::sender *txn_ctrl = nullptr ;
44+ proton::transaction_handler *handler = nullptr ;
45+ proton::binary id;
46+ proton::tracker _declare;
47+ proton::tracker _discharge;
48+ bool failed = false ;
49+ std::vector<proton::tracker> pending;
50+
51+ void commit ();
52+ void abort ();
53+ void declare ();
54+ proton::tracker send (proton::sender s, proton::message msg);
55+
56+ void discharge (bool failed);
57+ proton::tracker send_ctrl (proton::symbol descriptor, proton::value _value);
58+ void handle_outcome (proton::tracker t);
59+ transaction_impl (proton::sender &_txn_ctrl,
60+ proton::transaction_handler &_handler,
61+ bool _settle_before_discharge);
62+
63+ // delete copy and assignment operator to ensure no copy of this object is
64+ // every made transaction_impl(const transaction_impl&) = delete;
65+ // transaction_impl& operator=(const transaction_impl&) = delete;
66+ };
67+
3968class
4069PN_CPP_CLASS_EXTERN transaction {
70+ // private:
71+ // PN_CPP_EXTERN transaction(proton::sender& _txn_ctrl,
72+ // proton::transaction_handler& _handler, bool _settle_before_discharge);
73+
74+ static transaction mk_transaction_impl (sender &s, transaction_handler &h,
75+ bool f);
76+ PN_CPP_EXTERN transaction (transaction_impl* impl);
4177 public:
78+ transaction_impl* _impl;
4279 // TODO:
43- PN_CPP_EXTERN virtual ~transaction ();
44- PN_CPP_EXTERN virtual void commit ();
45- PN_CPP_EXTERN virtual void abort ();
46- PN_CPP_EXTERN virtual void declare ();
47- PN_CPP_EXTERN virtual void handle_outcome (proton::tracker);
48- PN_CPP_EXTERN virtual proton::tracker send (proton::sender s, proton::message msg);
80+ // PN_CPP_EXTERN transaction(transaction &o);
81+ PN_CPP_EXTERN transaction ();
82+ PN_CPP_EXTERN ~transaction ();
83+ PN_CPP_EXTERN void commit ();
84+ PN_CPP_EXTERN void abort ();
85+ PN_CPP_EXTERN void declare ();
86+ PN_CPP_EXTERN void handle_outcome (proton::tracker);
87+ PN_CPP_EXTERN proton::tracker send (proton::sender s, proton::message msg);
88+
89+ friend class transaction_impl ;
90+ friend class container ::impl;
4991};
5092
5193class
@@ -54,19 +96,19 @@ PN_CPP_CLASS_EXTERN transaction_handler {
5496 PN_CPP_EXTERN virtual ~transaction_handler ();
5597
5698 // / Called when a local transaction is declared.
57- PN_CPP_EXTERN virtual void on_transaction_declared (transaction& );
99+ PN_CPP_EXTERN virtual void on_transaction_declared (transaction);
58100
59101 // / Called when a local transaction is discharged successfully.
60- PN_CPP_EXTERN virtual void on_transaction_committed (transaction& );
102+ PN_CPP_EXTERN virtual void on_transaction_committed (transaction);
61103
62104 // / Called when a local transaction is discharged unsuccessfully (aborted).
63- PN_CPP_EXTERN virtual void on_transaction_aborted (transaction& );
105+ PN_CPP_EXTERN virtual void on_transaction_aborted (transaction);
64106
65107 // / Called when a local transaction declare fails.
66- PN_CPP_EXTERN virtual void on_transaction_declare_failed (transaction& );
108+ PN_CPP_EXTERN virtual void on_transaction_declare_failed (transaction);
67109
68110 // / Called when the commit of a local transaction fails.
69- PN_CPP_EXTERN virtual void on_transaction_commit_failed (transaction& );
111+ PN_CPP_EXTERN virtual void on_transaction_commit_failed (transaction);
70112};
71113
72114} // namespace proton
0 commit comments