Author: wyoung
Date: Mon Jan 11 17:12:20 2010
New Revision: 2600

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2600&view=rev
Log:
Added ScopedConnection class by Joel Fielder.

Added:
    trunk/lib/scopedconnection.cpp
    trunk/lib/scopedconnection.h
Modified:
    trunk/CREDITS.txt
    trunk/mysql++.bkl

Modified: trunk/CREDITS.txt
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/CREDITS.txt?rev=2600&r1=2599&r2=2600&view=diff
==============================================================================
--- trunk/CREDITS.txt (original)
+++ trunk/CREDITS.txt Mon Jan 11 17:12:20 2010
@@ -1,97 +1,98 @@
-MySQL++ was created by Kevin Atkinson during 1998.  From version
-1.0 (released in June 1999) through 1.7.9 (May 2001), the primary
-maintainer was Sinisa Milivojevic <[email protected]>.  Neither Kevin
-nor Sinisa are currently involved in MySQL++ development.  The current
-maintainer is Warren Young <[email protected]>, starting with
-version 1.7.10 in August of 2004.
-
-For a fuller account of the library's history, see the first chapter
-of the user manual.  For the nitty-gritty details, see the ChangeLog
-in the root package directory.  ChangeLog items since 1.7.9 that
-aren't attributed to anyone else were done by Warren Young.
-
-
-Other contributors of note since 1.7.10:
-
-    Chris Frey <[email protected]>: Lots of GCC warning fixes
-    for the bleeding-edge compiler versions, Gentoo ebuild support,
-    and misc other fixes.
-
-    Mark Meredino <[email protected]>: Several fixes and
-    additions, including a lot of work on Microsoft Visual C++
-    compatibility, and discoveries made while spelunking in the
-    library.
-
-    Evan Wies <[email protected]>: Contributed several C++ code
-    style cleanups.
-
-    Arnon Jalon <[email protected]>: Added the multi-query
-    result set handling features, and examples/multiquery.cpp to
-    demonstrate it.
-
-    Korolyov Ilya has submitted several patches in many different
-    areas of the library.
-
-    Remi Collet <[email protected]> is maintaining offical RPMs
-    for Fedora, with other systems on the way.  His work has improved
-    the RPM spec file we distribute greatly.
-
-    Joel Fielder <[email protected]> came up with the
-    original idea for Query::for_each() and Query::store_in(),
-    provided the basis for examples/for_each.cpp, and provided a fix
-    for exception flag propagation in Query.
-
-    Jim Wallace <[email protected]> demonstrated the need
-    for BadQuery::errnum(), and contributed the patches and also
-    examples/deadlock.cpp to test that this feature does what it is
-    supposed to.
-
-    Jonathan Wakely <[email protected]> rebuilt my original versions
-    of ConnectionPool, RefCountedPointer, and RefCountedBuffer.
-    They're now simpler and safer.  He also created the numeric
-    conversion logic in lib/mystring.h introduced in v3.0.
-
-    Rick Gutleber <[email protected]> contributed the 
-    Query::insertfrom() method and associated InsertPolicy object,
-    as well as the SQLStream class.
-
-Here are the personal credits from the old 1.7.9 documentation,
-apparently written by Kevin Atkinson:
-
-    Chris Halverson - For helping me get it to compile under Solaris.
-
-    Fredric Fredricson - For a long talk about automatic conversions.
-
-    Michael Widenius - MySQL developer who has been very supportive of
-        my efforts.
-
-    Paul J. Lucas - For the original idea of treating the query object
-        like a stream.
-
-    Scott Barron - For helping me with the shared libraries.
-
-    Jools Enticknap - For giving me the Template Queries idea.
-
-    M. S. Sriram - For a detailed dission of how the Template Queries
-        should be implemented, the suggestion to throw exceptions on bad
-        queries, and the idea of having a back-end independent query
-        object (ie SQLQuery).
-
-    Sinisa Milivojevic - For becoming the new offical maintainer.
-
-    D. Hawkins and E. Loic for their autoconf + automake contribution.
-
-
-See the ChangeLog for further credits, and details about the differences
-between the many versions of this library.
-
-
-Please do not email any of these people with general questions about
-MySQL++. All of us who are still active in MySQL++ development read the
-mailing list, so questions sent there do get to us:
-
-    http://lists.mysql.com/plusplus
-
-The mailing list is superior to private email because the answers are
-archived for future questioners to find, and because you are likely to
-get answers from more people.
+MySQL++ was created by Kevin Atkinson during 1998.  From version
+1.0 (released in June 1999) through 1.7.9 (May 2001), the primary
+maintainer was Sinisa Milivojevic <[email protected]>.  Neither Kevin
+nor Sinisa are currently involved in MySQL++ development.  The current
+maintainer is Warren Young <[email protected]>, starting with
+version 1.7.10 in August of 2004.
+
+For a fuller account of the library's history, see the first chapter
+of the user manual.  For the nitty-gritty details, see the ChangeLog
+in the root package directory.  ChangeLog items since 1.7.9 that
+aren't attributed to anyone else were done by Warren Young.
+
+
+Other contributors of note since 1.7.10:
+
+    Chris Frey <[email protected]>: Lots of GCC warning fixes
+    for the bleeding-edge compiler versions, Gentoo ebuild support,
+    and misc other fixes.
+
+    Mark Meredino <[email protected]>: Several fixes and
+    additions, including a lot of work on Microsoft Visual C++
+    compatibility, and discoveries made while spelunking in the
+    library.
+
+    Evan Wies <[email protected]>: Contributed several C++ code
+    style cleanups.
+
+    Arnon Jalon <[email protected]>: Added the multi-query
+    result set handling features, and examples/multiquery.cpp to
+    demonstrate it.
+
+    Korolyov Ilya has submitted several patches in many different
+    areas of the library.
+
+    Remi Collet <[email protected]> is maintaining offical RPMs
+    for Fedora, with other systems on the way.  His work has improved
+    the RPM spec file we distribute greatly.
+
+    Joel Fielder <[email protected]> created the
+    ScopedConnection class, came up with the original idea for
+    Query's for_each() and store_in() methods, provided the basis
+    for examples/for_each.cpp, and provided a fix for exception flag
+    propagation in Query.
+
+    Jim Wallace <[email protected]> demonstrated the need
+    for BadQuery::errnum(), and contributed the patches and also
+    examples/deadlock.cpp to test that this feature does what it is
+    supposed to.
+
+    Jonathan Wakely <[email protected]> rebuilt my original versions
+    of ConnectionPool, RefCountedPointer, and RefCountedBuffer.
+    They're now simpler and safer.  He also created the numeric
+    conversion logic in lib/mystring.h introduced in v3.0.
+
+    Rick Gutleber <[email protected]> contributed the 
+    Query::insertfrom() method and associated InsertPolicy object,
+    as well as the SQLStream class.
+
+Here are the personal credits from the old 1.7.9 documentation,
+apparently written by Kevin Atkinson:
+
+    Chris Halverson - For helping me get it to compile under Solaris.
+
+    Fredric Fredricson - For a long talk about automatic conversions.
+
+    Michael Widenius - MySQL developer who has been very supportive of
+        my efforts.
+
+    Paul J. Lucas - For the original idea of treating the query object
+        like a stream.
+
+    Scott Barron - For helping me with the shared libraries.
+
+    Jools Enticknap - For giving me the Template Queries idea.
+
+    M. S. Sriram - For a detailed dission of how the Template Queries
+        should be implemented, the suggestion to throw exceptions on bad
+        queries, and the idea of having a back-end independent query
+        object (ie SQLQuery).
+
+    Sinisa Milivojevic - For becoming the new offical maintainer.
+
+    D. Hawkins and E. Loic for their autoconf + automake contribution.
+
+
+See the ChangeLog for further credits, and details about the differences
+between the many versions of this library.
+
+
+Please do not email any of these people with general questions about
+MySQL++. All of us who are still active in MySQL++ development read the
+mailing list, so questions sent there do get to us:
+
+    http://lists.mysql.com/plusplus
+
+The mailing list is superior to private email because the answers are
+archived for future questioners to find, and because you are likely to
+get answers from more people.

Added: trunk/lib/scopedconnection.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/scopedconnection.cpp?rev=2600&view=auto
==============================================================================
--- trunk/lib/scopedconnection.cpp (added)
+++ trunk/lib/scopedconnection.cpp Mon Jan 11 17:12:20 2010
@@ -1,0 +1,55 @@
+/***********************************************************************
+ scopedconnection.cpp - Implements the ScopedConnection class.
+
+ Copyright (c) 2010 by Joel Fielder.  Others may also hold copyrights
+ on code in this file.  See the CREDITS.txt file in the top directory
+ of the distribution for details.
+
+ This file is part of MySQL++.
+
+ MySQL++ is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ MySQL++ is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with MySQL++; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ USA
+***********************************************************************/
+
+#include "scopedconnection.h"
+
+#include "cpool.h"
+
+namespace mysqlpp {
+
+ScopedConnection::ScopedConnection(ConnectionPool& pool) :
+pool_(pool),
+connection_(pool.grab())
+{
+}
+
+ScopedConnection::~ScopedConnection()
+{
+    pool_.release(connection_);
+}
+
+Connection*
+ScopedConnection::operator->() const
+{
+    return connection_;
+}
+
+Connection&
+ScopedConnection::operator*() const
+{
+    return *connection_;
+}
+
+} // end namespace mysqlpp

Added: trunk/lib/scopedconnection.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/scopedconnection.h?rev=2600&view=auto
==============================================================================
--- trunk/lib/scopedconnection.h (added)
+++ trunk/lib/scopedconnection.h Mon Jan 11 17:12:20 2010
@@ -1,0 +1,86 @@
+/// \file scopedconnection.h
+/// \brief Declares the ScopedConnection class.
+///
+/// This class lets you grab a connection from a ConnectionPool in a
+/// scoped and therefore RAII way.  The Connection object will always be
+/// returned to the pool when the scope block ends, plugging a potential
+/// leak in the pool.
+
+/***********************************************************************
+ Copyright (c) 2010 by Joel Fielder.  Others may also hold copyrights
+ on code in this file.  See the CREDITS.txt file in the top directory
+ of the distribution for details.
+
+ This file is part of MySQL++.
+
+ MySQL++ is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ MySQL++ is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with MySQL++; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+ USA
+***********************************************************************/
+
+#if !defined(MYSQLPP_SCOPEDCONNECTION_H)
+#define MYSQLPP_SCOPEDCONNECTION_H
+
+#include "common.h"
+
+namespace mysqlpp {
+
+#if !defined(DOXYGEN_IGNORE)
+// Make Doxygen ignore this
+class MYSQLPP_EXPORT Connection;
+class MYSQLPP_EXPORT ConnectionPool;
+#endif
+
+/// \brief Grabs a Connection from a ConnectionPool on construction
+/// and releases it back to the pool on destruction, and provides access
+/// to the relevant Connection pointer.
+class MYSQLPP_EXPORT ScopedConnection
+{
+public:
+    /// \brief Standard constructor
+    ///
+    /// Grabs a Connection from the specified pool.
+    ///
+    /// \param pool The ConnectionPool to use.
+    explicit ScopedConnection(ConnectionPool& pool);
+   
+    /// \brief Destructor
+    ///
+    /// Releases the Connection back to the ConnectionPool.
+    ~ScopedConnection();
+
+    /// \brief Access the Connection pointer
+    Connection* operator->() const;
+
+    /// \brief Dereference
+    Connection& operator*() const;
+
+private:
+    // ScopedConnection objects must not be default-constructed.  RAII.
+       ScopedConnection();
+
+    // ScopedConnection objects cannot be copied.  We want them to be
+       // tightly scoped to their use point, not put in containers or
+       // passed around promiscuously.
+    ScopedConnection(const ScopedConnection& no_copies);   
+    const ScopedConnection& operator=(const ScopedConnection& no_copies);
+
+    ConnectionPool& pool_;
+    Connection* const connection_;
+};
+
+} // end namespace mysqlpp
+
+#endif // !defined(MYSQLPP_SCOPEDCONNECTION_H)
+

Modified: trunk/mysql++.bkl
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/mysql%2B%2B.bkl?rev=2600&r1=2599&r2=2600&view=diff
==============================================================================
--- trunk/mysql++.bkl (original)
+++ trunk/mysql++.bkl Mon Jan 11 17:12:20 2010
@@ -74,6 +74,7 @@
         lib/query.cpp
         lib/result.cpp
         lib/row.cpp
+        lib/scopedconnection.cpp
         lib/sql_buffer.cpp
         lib/sqlstream.cpp
         lib/ssqls2.cpp


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

Reply via email to