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

pqxx-object/row_base.h

Go to the documentation of this file.
00001 // database row base class                                       -*- C++ -*-
00002 // $Id: row_base.h,v 1.7 2004/02/20 22:49:15 roger Exp $
00003 //
00004 // Copyright (C) 2003  Roger Leigh <rleigh@debian.org>
00005 //
00006 //
00007 //  All rights reserved.
00008 //
00009 //  Redistribution and use in source and binary forms, with or without
00010 //  modification, are permitted provided that the following conditions
00011 //  are met:
00012 //
00013 //  * Redistributions of source code must retain the above copyright
00014 //    notice, this list of conditions and the following disclaimer.
00015 //  * Redistributions in binary form must reproduce the above
00016 //    copyright notice, this list of conditions and the following
00017 //    disclaimer in the documentation and/or other materials provided
00018 //    with the distribution.
00019 //  * Neither the name of the author, nor the names of other
00020 //    contributors may be used to endorse or promote products derived
00021 //    from this software without specific prior written permission.
00022 //
00023 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
00024 //  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
00025 //  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00026 //  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027 //  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
00028 //  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00029 //  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00030 //  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00031 //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00032 //  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00033 //  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00034 //  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00035 //  SUCH DAMAGE.
00036 //
00038 
00039 #ifndef PQXX_OBJECT_ROW_BASE_H
00040 #define PQXX_OBJECT_ROW_BASE_H
00041 
00042 #include <sigc++/object.h>
00043 #include <sigc++/signal.h>
00044 #include <sigc++/object_slot.h>
00045 
00046 #include <pqxx-object/transaction.h>
00047 
00048 namespace pqxxobject
00049 {
00056   class row_base : public SigC::Object
00057   {
00058   public:
00060     enum row_state
00061       {
00066         STATE_UNINITIALISED,
00068         STATE_INITIALISED,
00073         STATE_INCONSISTENT
00074       };
00075 
00076   protected:
00078     row_state m_state;
00080     bool m_modified;
00081 
00083     SigC::Signal0<void> m_signal_changed;
00085     SigC::Signal0<void> m_signal_refreshed;
00087     SigC::Signal0<void> m_signal_inserted;
00089     SigC::Signal0<void> m_signal_updated;
00091     SigC::Signal0<void> m_signal_erased;
00092 
00094     row_base();
00095 
00101     explicit row_base(row_state status,
00102                       bool modified=false);
00103 
00107     row_base(const row_base& rhs);
00108 
00109   public:
00111     virtual ~row_base();
00112 
00117     row_base& operator = (const row_base& rhs);
00118 
00123     row_state get_state() const;
00124 
00129     bool is_modified() const;
00130 
00135     void refresh(pqxxobject::transaction& tran);
00136 
00141     void insert(pqxxobject::transaction& tran);
00142 
00147     void update(pqxxobject::transaction& tran);
00148 
00153     void erase(pqxxobject::transaction& tran);
00154 
00159     void abort(pqxxobject::transaction& tran);
00160 
00165     void commit(pqxxobject::transaction& tran);
00166 
00171     SigC::Signal0<void>& signal_changed();
00172 
00177     SigC::Signal0<void>& signal_refreshed();
00178 
00183     SigC::Signal0<void>& signal_inserted();
00184 
00189     SigC::Signal0<void>& signal_updated();
00190 
00195     SigC::Signal0<void>& signal_erased();
00196 
00198     void raise_changed();
00199 
00201     void raise_refreshed();
00202 
00204     void raise_inserted();
00205 
00207     void raise_updated();
00208 
00210     void raise_erased();
00211 
00212 
00213   protected:
00219     void begin(pqxxobject::transaction& tran);
00220 
00227     virtual void refresh_impl(pqxxobject::transaction& tran);
00228 
00235     virtual void insert_impl(pqxxobject::transaction& tran);
00236 
00243     virtual void update_impl(pqxxobject::transaction& tran);
00244 
00251     virtual void erase_impl(pqxxobject::transaction& tran);
00252 
00259     virtual void begin_impl(pqxxobject::transaction& tran) = 0;
00260 
00267     virtual void abort_impl(pqxxobject::transaction& tran) = 0;
00268 
00275     virtual void commit_impl(pqxxobject::transaction& tran) = 0;
00276 
00281     virtual bool get_checkpoint() const = 0;
00282 
00287     void unset_checkpoint(pqxxobject::transaction& tran);
00288 
00289   private:
00294     void connect_signal_handlers(pqxxobject::transaction& tran);
00295 
00302     void connect_safe_signal_handlers(pqxxobject::transaction& tran);
00303 
00304   }; // class row_base
00305 
00306 }; // namespace pqxxobject
00307 
00308 #endif // PQXX_OBJECT_ROW_BASE_H

Generated on Thu Apr 1 10:37:56 2004 for pqxx-object API Reference by doxygen 1.3.5