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

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

Go to the documentation of this file.
00001 // tutorial places class                                         -*- C++ -*-
00002 // $Id: places.h,v 1.7 2004/01/18 00:11:17 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   static row_ptr create(pqxx::result::const_iterator row,
00093                         pqxxobject::transaction& tran);
00094 
00095 protected:
00099   virtual void insert_impl(pqxxobject::transaction& tran);
00100 
00104   virtual void update_impl(pqxxobject::transaction& tran);
00105 
00109   virtual void erase_impl(pqxxobject::transaction& tran);
00110 
00114   virtual void refresh_impl(pqxxobject::transaction& tran);
00115 
00116 private:
00118   pqxxobject::column<int> m_id;
00120   pqxxobject::column<std::string> m_name;
00122   pqxxobject::column<std::string> m_gridref;
00123 
00124 
00125 }; // class Place
00126 
00134 class PlaceTable : public pqxxobject::table<Place>
00135 {
00136 public:
00138   typedef pqxxobject::table<Place> table_base;
00139 
00144   PlaceTable(pqxxobject::transaction& tran);
00145 
00147   virtual ~PlaceTable();
00148 
00150   enum sort_order
00151     {
00153       ORDER_ID,
00155       ORDER_NAME,
00157       ORDER_GRIDREF
00158     };
00159 
00165   row_list_ptr get_list(sort_order order = ORDER_NAME);
00166 
00172   row_ptr find(int place_id);
00173 
00179   row_ptr find_name(const std::string& name);
00180 
00188   row_list_ptr find_gridref(const std::string& gridref);
00189 
00190 }; // class PlaceTable
00191 
00192 #endif // TUTORIAL_PLACES_H

Generated on Sun Jan 18 12:35:48 2004 for places API Reference by doxygen 1.3.4