00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PQXX_OBJECT_TRANSACTION_H
00022 #define PQXX_OBJECT_TRANSACTION_H
00023
00024 #include <pqxx/connection>
00025 #include <pqxx/transaction>
00026
00027 #include <sigc++/signal.h>
00028
00029 #include <pqxx-object/exceptions.h>
00030
00031 namespace pqxxobject
00032 {
00046 class transaction
00047 {
00048 public:
00049 enum state
00050 {
00051 STATE_NONE,
00052 STATE_ABORTED,
00053 STATE_COMMITTED,
00054 STATE_EXECUTING
00055 };
00056
00057 SigC::Signal0<void>& signal_commit();
00058 SigC::Signal0<void>& signal_abort();
00059
00060 protected:
00071 transaction(pqxx::connection& connection,
00072 pqxx::transaction<>*& transaction);
00073
00075 virtual ~transaction();
00076
00088 void begin(const std::string& name);
00089
00098 void end();
00099
00107 pqxx::result *exec(const std::string& query);
00108
00118 pqxx::result::size_type exec_noresult(const std::string& query);
00119
00138 pqxx::result::size_type perform(const std::string& query,
00139 pqxx::result::size_type min_rows,
00140 pqxx::result::size_type max_rows);
00141
00154 void commit();
00155
00156
00168 void abort();
00169
00170
00172 pqxx::connection& m_connection;
00174 pqxx::transaction<>*& m_transaction;
00176 bool m_autocommit;
00177
00178 SigC::Signal0<void> m_signal_commit;
00179 SigC::Signal0<void> m_signal_abort;
00180
00181 state m_state;
00182
00183 };
00184
00185 };
00186
00187 #endif // PQXX_OBJECT_TRANSACTION_H