Author: wyoung
Date: Fri Feb 27 19:10:56 2009
New Revision: 2461

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2461&view=rev
Log:
Removed DefaultInsertPolicy.  Apparently template methods can't have
default template parameters, the reason for creating this in the first
place.  If it turns out that someone wants a way to turn insertfrom()
into insert(iter, iter), we can put it back, but with a different name.

Modified:
    trunk/Wishlist
    trunk/lib/insertpolicy.h

Modified: trunk/Wishlist
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/Wishlist?rev=2461&r1=2460&r2=2461&view=diff
==============================================================================
--- trunk/Wishlist (original)
+++ trunk/Wishlist Fri Feb 27 19:10:56 2009
@@ -12,8 +12,6 @@
 
   o Write RowCountInsertPolicy
   
-  o Make DefaultInsertPolicy the default!
-
 
 v3.1 Tentative Plan
 -------------------

Modified: trunk/lib/insertpolicy.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/insertpolicy.h?rev=2461&r1=2460&r2=2461&view=diff
==============================================================================
--- trunk/lib/insertpolicy.h (original)
+++ trunk/lib/insertpolicy.h Fri Feb 27 19:10:56 2009
@@ -1,18 +1,38 @@
 /// \file insertpolicy.h
 /// \brief Declares the InsertPolicy classes.
 ///
-/// These objects are used by the Query::insertfrom() method to insert
-/// collections of SSQLS objects when certain constraints in the raw
-/// SQL command, such as a maximum are required.
+/// One creates an insert policy object to control how
+/// Query::insertfrom() builds queries from collections of SSQLS
+/// objects.  Policy objects are what cause Query::insertfrom() to
+/// have different insertion behavior than Query::insert(iter, iter)
 ///
+/// These templates use a class called the AccessController, which
+/// is a stand-in for the mysqlpp::Transaction class and defaults to 
+/// the Transaction class.  Since some of the InsertPolicy objects
+/// (SizeThresholdInsertPolicy and MaxPacketInsertPolicy) may cause 
+/// Query::insertfrom() to issue multiple SQL statements to perform
+/// the insertion of all the objects in the container, and a failure in
+/// one of these statements would leave the table in an indeterminate
+/// state, the whole operation is wrapped in a transaction.
+///
+/// However, a transaction may not be desired if the calling code
+/// is managing transactions, or transactions are not being used for 
+/// some other reason.  In this case, the template can be instantiated
+/// with the NoTransaction class.  It provides the complete Transaction
+/// class interface, while doing nothing.
+///
+/// Where possible, you should use one of the provided insert
+/// policy classes, but you can define your own if you need a behavior
+/// that the provided set doesn't include.
+/// 
 /// This file is not meant to be included in end-user code.  It's
 /// included in Query's public interface, since it is only used with
 /// Query::insertfrom().  You access it as Query::InsertPolicy<T>
 
 /***********************************************************************
- Copyright (c) 2008 by AboveNet, Inc.  Others may also hold copyrights 
- on code in this file.  See the CREDITS file in the top directory of 
- the distribution for details.
+ Copyright (c) 2008-2009 by AboveNet, Inc.  Others may also hold
+ copyrights on code in this file.  See the CREDITS file in the top
+ directory of the distribution for details.
 
  This file is part of MySQL++.
 
@@ -34,62 +54,6 @@
 
 #if !defined(MYSQLPP_INSERTPOLICY_H)
 #define MYSQLPP_INSERTPOLICY_H
-
-/// \brief The default policy object for doing bulk inserts.
-///
-/// InsertPolicy objects work hand-in-hand with Query::insertfrom().
-///
-/// The InsertPolicy object determines if another object can be added
-/// to the INSERT statement using either internal state variables or
-/// by looking at the length of the query, which is one of the
-/// arguments passed in.
-///
-/// This policy simply creates a single SQL statement regardless
-/// of how big it gets.
-///
-/// These templates use a class called the AccessController, which
-/// is a stand-in for the mysqlpp::Transaction class and defaults to 
-/// the Transaction class.  Since some of the InsertPolicy objects
-/// (SizeThresholdInsertPolicy and MaxPacketInsertPolicy) may cause 
-/// Query::insertfrom() to issue multiple SQL statements to perform
-/// the insertion of all the objects in the container, and a failure in
-/// one of these statements would leave the table in an indeterminate
-/// state, the whole operation is wrapped in a transaction.
-///
-/// However, a transaction may not be desired if the calling code
-/// is managing transactions, or transactions are not being used for 
-/// some other reason.  In this case, the template can be used
-/// with the provided NoTransaction object defined above.  That object
-/// matches the Transaction object's interface but does nothing.
-///
-/// The decision to use the InsertPolicy object was made in order to 
-/// allow the possibility of a user-created object that uses some 
-/// other criterion to determine how many objects to include in a 
-/// single INSERT statement.
-template <class AccessController = Transaction>
-class MYSQLPP_EXPORT DefaultInsertPolicy
-{
-public:
-       /// \brief Constructor
-       DefaultInsertPolicy() { }
-
-       /// \brief Destructor
-       ~DefaultInsertPolicy() { }
-
-       /// \brief Can we add another object to the query?
-       ///
-       /// \param size current length of the INSERT statement
-       /// \param object the SSQLS object to be added
-       ///
-       /// \retval true if the object is allowed to be added to the
-       /// INSERT statement
-       template <class RowT>
-       bool can_add(int size, const RowT& object) const { return true; }
-
-       /// \brief Alias for our access controller type
-       typedef AccessController access_controller;
-};
-
 
 /// \brief A policy object that triggers a new INSERT statement
 /// after a size threshold for the length of the INSERT statement
@@ -119,7 +83,8 @@
        /// \retval true if the object is allowed to be added to the
        /// INSERT statement
        template <class RowT>
-       bool can_add(int size, const RowT& object) const {
+       bool can_add(int size, const RowT& object) const
+       {
                return (size < size_);
        }
 
@@ -176,7 +141,8 @@
        /// \retval true if the object is allowed to be added to the
        ///     INSERT statement
        template <class RowT>
-       bool can_add(int size, const RowT& object) const {
+       bool can_add(int size, const RowT& object) const
+       {
                if (size < size_) {
                        // Haven't hit size threshold yet, so see if this next
                        // item pushes it over the line.


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to