Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53131 - in trunk: boost/signals2 libs/signals2/doc/reference libs/signals2/test
From: fmhess_at_[hidden]
Date: 2009-05-20 11:16:44


Author: fmhess
Date: 2009-05-20 11:16:37 EDT (Wed, 20 May 2009)
New Revision: 53131
URL: http://svn.boost.org/trac/boost/changeset/53131

Log:
Added shared_connection_block::connection() query, and a
connection::operator!=(). Added a test of shared_connection_block
assignment.

Text files modified:
   trunk/boost/signals2/connection.hpp | 4 ++++
   trunk/boost/signals2/shared_connection_block.hpp | 7 ++++++-
   trunk/libs/signals2/doc/reference/connection.xml | 11 +++++++++++
   trunk/libs/signals2/doc/reference/shared_connection_block.xml | 10 ++++++++++
   trunk/libs/signals2/test/shared_connection_block_test.cpp | 16 +++++++++++++++-
   5 files changed, 46 insertions(+), 2 deletions(-)

Modified: trunk/boost/signals2/connection.hpp
==============================================================================
--- trunk/boost/signals2/connection.hpp (original)
+++ trunk/boost/signals2/connection.hpp 2009-05-20 11:16:37 EDT (Wed, 20 May 2009)
@@ -178,6 +178,10 @@
         boost::shared_ptr<detail::connection_body_base> otherConnectionBody(other._weak_connection_body.lock());
         return connectionBody == otherConnectionBody;
       }
+ bool operator!=(const connection& other) const
+ {
+ return !(*this == other);
+ }
       bool operator<(const connection& other) const
       {
         boost::shared_ptr<detail::connection_body_base> connectionBody(_weak_connection_body.lock());

Modified: trunk/boost/signals2/shared_connection_block.hpp
==============================================================================
--- trunk/boost/signals2/shared_connection_block.hpp (original)
+++ trunk/boost/signals2/shared_connection_block.hpp 2009-05-20 11:16:37 EDT (Wed, 20 May 2009)
@@ -22,7 +22,8 @@
     class shared_connection_block
     {
     public:
- shared_connection_block(const connection &conn = connection(), bool initially_blocked = true):
+ shared_connection_block(const signals2::connection &conn = signals2::connection(),
+ bool initially_blocked = true):
         _weak_connection_body(conn._weak_connection_body)
       {
         if(initially_blocked) block();
@@ -49,6 +50,10 @@
         shared_ptr<void> empty;
         return _blocker < empty || empty < _blocker;
       }
+ signals2::connection connection() const
+ {
+ return signals2::connection(_weak_connection_body);
+ }
     private:
       boost::weak_ptr<detail::connection_body_base> _weak_connection_body;
       shared_ptr<void> _blocker;

Modified: trunk/libs/signals2/doc/reference/connection.xml
==============================================================================
--- trunk/libs/signals2/doc/reference/connection.xml (original)
+++ trunk/libs/signals2/doc/reference/connection.xml 2009-05-20 11:16:37 EDT (Wed, 20 May 2009)
@@ -131,6 +131,17 @@
             <throws><para>Will not throw.</para></throws>
           </method>
 
+ <method name="operator!=" cv="const">
+ <type>bool</type>
+ <parameter name="other">
+ <paramtype>const <classname>connection</classname>&amp;</paramtype>
+ </parameter>
+
+ <returns><para><computeroutput>!(*this == other)</computeroutput></para></returns>
+
+ <throws><para>Will not throw.</para></throws>
+ </method>
+
           <method name="operator&lt;" cv="const">
             <type>bool</type>
             <parameter name="other">

Modified: trunk/libs/signals2/doc/reference/shared_connection_block.xml
==============================================================================
--- trunk/libs/signals2/doc/reference/shared_connection_block.xml (original)
+++ trunk/libs/signals2/doc/reference/shared_connection_block.xml 2009-05-20 11:16:37 EDT (Wed, 20 May 2009)
@@ -81,6 +81,7 @@
             </para>
           </effects>
           <postconditions>
+ <para><code>this->connection() == other.connection()</code></para>
             <para><code>this->blocking() == other.blocking()</code></para>
           </postconditions>
         </constructor>
@@ -98,6 +99,7 @@
             </para>
           </effects>
           <postconditions>
+ <para><code>this->connection() == rhs.connection()</code></para>
             <para><code>this->blocking() == rhs.blocking()</code></para>
           </postconditions>
           <throws><para>Will not throw.</para></throws>
@@ -125,6 +127,14 @@
             blocked by another <code>shared_connection_block</code> object.</para></notes>
           </method>
         </method-group>
+ <method-group name="queries">
+ <method name="connection" cv="const">
+ <type><classname>boost::signals2::connection</classname></type>
+ <returns>
+ <para>A connection object for the connection referenced by <code>this</code>.</para>
+ </returns>
+ </method>
+ </method-group>
       </class>
     </namespace>
    </namespace>

Modified: trunk/libs/signals2/test/shared_connection_block_test.cpp
==============================================================================
--- trunk/libs/signals2/test/shared_connection_block_test.cpp (original)
+++ trunk/libs/signals2/test/shared_connection_block_test.cpp 2009-05-20 11:16:37 EDT (Wed, 20 May 2009)
@@ -86,13 +86,27 @@
   }
 
   {
- // default construction
+ // test default constructed block
     boost::signals2::shared_connection_block block;
     BOOST_CHECK(block.blocking() == true);
     block.unblock();
     BOOST_CHECK(block.blocking() == false);
     block.block();
     BOOST_CHECK(block.blocking() == true);
+
+ // test assignment
+ {
+ block.unblock();
+ boost::signals2::shared_connection_block block2(connections.at(0));
+ BOOST_CHECK(block.connection() != block2.connection());
+ BOOST_CHECK(block.blocking() != block2.blocking());
+ block = block2;
+ BOOST_CHECK(block.connection() == block2.connection());
+ BOOST_CHECK(block.blocking() == block2.blocking());
+ }
+ test_output.str("");
+ s0();
+ BOOST_CHECK(test_output.str() == "123");
   }
   return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk