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

/home/roger/projects/libpqxx-object-0.1.1/tutorial/places.h

Go to the documentation of this file.
00001 // tutorial places class                                         -*- C++ -*-
00002 // $Id: places.h,v 1.5 2004/01/07 14:29:41 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 TUTORIAL_PLACES_H
00022 #define TUTORIAL_PLACES_H
00023 
00024 #include <string>
00025 #include <vector>
00026 
00027 #include <pqxx-object/column.h>
00028 #include <pqxx-object/row.h>
00029 #include <pqxx-object/table.h>
00030 
00039 class Place : public pqxxobject::row<Place>
00040 {
00041 public:
00043   Place();
00044 
00050   Place(const std::string& name,
00051         const std::string& gridref);
00052 
00054   virtual ~Place();
00055 
00060   int get_id() const;
00061 
00066   const std::string& get_name() const;
00067 
00072   void set_name(const std::string& name);
00073 
00078   const std::string& get_gridref() const;
00079 
00084   void set_gridref(const std::string& gridref);
00085 
00092   virtual void initialise(pqxx::result::const_iterator row,
00093                           pqxxobject::transaction& tran);
00094 
00098   virtual void insert(pqxxobject::transaction& tran);
00099 
00103   virtual void update(pqxxobject::transaction& tran);
00104 
00108   virtual void erase(pqxxobject::transaction& tran);
00109 
00113   virtual void refresh(pqxxobject::transaction& tran);
00114 
00115 private:
00117   pqxxobject::column<int> m_id;
00119   pqxxobject::column<std::string> m_name;
00121   pqxxobject::column<std::string> m_gridref;
00122 
00123 
00124 }; // class Place
00125 
00133 class PlaceTable : public pqxxobject::table<Place>
00134 {
00135 public:
00137   typedef pqxxobject::table<Place> table_base;
00138 
00147   PlaceTable(pqxxobject::transaction& tran);
00148 
00150   virtual ~PlaceTable();
00151 
00153   enum sort_order
00154     {
00156       ORDER_ID,
00158       ORDER_NAME,
00160       ORDER_GRIDREF
00161     };
00162 
00168   row_list_ptr get_list(sort_order order = ORDER_NAME);
00169 
00175   row_ptr find(int place_id);
00176 
00182   row_ptr find_name(const std::string& name);
00183 
00191   row_list_ptr find_gridref(const std::string& gridref);
00192 
00193 }; // class PlaceTable
00194 
00195 #endif // TUTORIAL_PLACES_H

Generated on Sat Jan 17 20:15:56 2004 for places API Reference by doxygen 1.3.4