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

places.h

Go to the documentation of this file.
00001 // tutorial places class                                         -*- C++ -*-
00002 // $Id: places.h,v 1.12 2004/05/22 17:58:18 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 TUTORIAL_PLACES_H
00040 #define TUTORIAL_PLACES_H
00041 
00042 #include <string>
00043 #include <vector>
00044 
00045 #include <pqxxobject/field.h>
00046 #include <pqxxobject/field_proxy.h>
00047 #include <pqxxobject/row.h>
00048 #include <pqxxobject/table.h>
00049 
00058 class Place : public pqxxobject::row<Place>
00059 {
00060 public:
00062   Place();
00063 
00069   Place(const std::string& name,
00070         const std::string& gridref);
00071 
00073   virtual ~Place();
00074 
00079   int get_id() const;
00080 
00081   pqxxobject::field_proxy_readonly< pqxxobject::field<int> >
00082   field_id();
00083 
00088   const std::string& get_name() const;
00089 
00094   void set_name(const std::string& name);
00095 
00096   pqxxobject::field_proxy< pqxxobject::field<std::string> >
00097   field_name();
00098 
00103   const std::string& get_gridref() const;
00104 
00109   void set_gridref(const std::string& gridref);
00110 
00111   pqxxobject::field_proxy< pqxxobject::field<std::string> >
00112   field_gridref();
00113 
00114 protected:
00118   virtual void insert_impl(pqxxobject::transaction& tran);
00119 
00123   virtual void update_impl(pqxxobject::transaction& tran);
00124 
00128   virtual void erase_impl(pqxxobject::transaction& tran);
00129 
00133   virtual void refresh_impl(pqxxobject::transaction& tran);
00134 
00135   virtual void convert_impl(pqxx::result::const_iterator row,
00136                             pqxxobject::transaction& tran);
00137 
00138 private:
00140   pqxxobject::field<int> m_id;
00142   pqxxobject::field<std::string> m_name;
00144   pqxxobject::field<std::string> m_gridref;
00145 
00146   friend class pqxxobject::row<Place>;
00147 
00148 }; // class Place
00149 
00157 class PlaceTable : public pqxxobject::table<Place>
00158 {
00159 public:
00161   typedef pqxxobject::table<Place> table_base;
00162 
00167   PlaceTable(pqxxobject::transaction& tran);
00168 
00170   virtual ~PlaceTable();
00171 
00173   enum sort_order
00174     {
00176       ORDER_ID,
00178       ORDER_NAME,
00180       ORDER_GRIDREF
00181     };
00182 
00188   row_list_ptr get_list(sort_order order = ORDER_NAME);
00189 
00195   row_ptr find(int place_id);
00196 
00202   row_ptr find_name(const std::string& name);
00203 
00211   row_list_ptr find_gridref(const std::string& gridref);
00212 
00213 }; // class PlaceTable
00214 
00215 #endif // TUTORIAL_PLACES_H

Generated on Sat May 22 19:01:36 2004 for places API Reference by doxygen 1.3.6-20040222