Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

pqxx-object/transaction_proxy.h

Go to the documentation of this file.
00001 // database transaction convenience wrapper                      -*- C++ -*-
00002 // $Id: transaction.h,v 1.4 2004/01/07 14:29:39 roger Exp $
00003 //
00004 // Copyright (C) 2003  Roger Leigh <rleigh@debian.org>
00005 //
00006 //
00007 // This program is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation; either version 2 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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     // PostgreSQL connection details
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   }; // class transaction
00184 
00185 }; // namespace pqxxobject
00186 
00187 #endif // PQXX_OBJECT_TRANSACTION_H

Generated on Sat Jan 17 20:58:25 2004 for pqxx-object API Reference by doxygen 1.3.4