[libsigcplusplus] signal: Rename iterator to connection.



commit 50e53f5e4fbc676f9c7697e5cd20cda93a23aac2
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Apr 21 13:56:12 2016 +0200

    signal: Rename iterator to connection.
    
    It is still actually an iterator, but we can change that later.

 sigc++/signal.h          |   15 +++++----------
 tests/benchmark.cc       |    7 +++----
 tests/test_disconnect.cc |    4 ++--
 tests/test_size.cc       |    2 +-
 4 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/sigc++/signal.h b/sigc++/signal.h
index c8409fd..0118c9f 100644
--- a/sigc++/signal.h
+++ b/sigc++/signal.h
@@ -618,12 +618,7 @@ class signal_with_accumulator : public signal_base
 public:
   using emitter_type = internal::signal_emit<T_return, T_accumulator, T_arg...>;
   using slot_type = slot<T_return(T_arg...)>;
-
-private:
-  using slot_list_type = slot_list<slot_type>;
-
-public:
-  using iterator = typename slot_list_type::iterator;
+  using connection = slot_iterator<slot_type>;
 
   /** Add a slot to the list of slots.
    * Any functor or slot may be passed into connect().
@@ -646,9 +641,9 @@ public:
    * @param slot_ The slot to add to the list of slots.
    * @return An iterator pointing to the new slot in the list.
    */
-  iterator connect(const slot_type& slot_)
+  connection connect(const slot_type& slot_)
   {
-    return iterator(signal_base::connect(slot_));
+    return connection(signal_base::connect(slot_));
   }
 
   /** Add a slot to the list of slots.
@@ -656,9 +651,9 @@ public:
    *
    * @newin{2,8}
    */
-  iterator connect(slot_type&& slot_)
+  connection connect(slot_type&& slot_)
   {
-    return iterator(signal_base::connect(std::move(slot_)));
+    return connection(signal_base::connect(std::move(slot_)));
   }
 
   /** Triggers the emission of the signal.
diff --git a/tests/benchmark.cc b/tests/benchmark.cc
index a9b5945..7c42451 100644
--- a/tests/benchmark.cc
+++ b/tests/benchmark.cc
@@ -25,7 +25,6 @@ int foo::bar(int a)
 void test_slot_call()
 {
   foo foobar1;
-  sigc::signal<int(int)>::iterator it;
 
   // slot benchmark ...
 
@@ -83,15 +82,15 @@ void test_connect_disconnect()
 {
   foo foobar1;
   sigc::signal<int(int)> emitter;
-  sigc::signal<int(int)>::iterator it;
+  sigc::signal<int(int)>::connection conn;
 
   std::cout << "elapsed time for " << COUNT << " connections/disconnections:" << std::endl;
   boost::timer::auto_cpu_timer timer;
 
   for (int i=0; i < COUNT; ++i)
     {
-      it = emitter.connect(mem_fun(foobar1, &foo::bar));
-      it->disconnect();
+      conn = emitter.connect(mem_fun(foobar1, &foo::bar));
+      conn->disconnect();
     }
 }
 
diff --git a/tests/test_disconnect.cc b/tests/test_disconnect.cc
index 1046371..caadfaf 100644
--- a/tests/test_disconnect.cc
+++ b/tests/test_disconnect.cc
@@ -81,8 +81,8 @@ main(int argc, char* argv[])
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
   sigc::signal<int(int)> sig;
-  sigc::signal<int(int)>::iterator confoo;
-  sigc::signal<int(int)>::iterator conbar;
+  sigc::signal<int(int)>::connection confoo;
+  sigc::signal<int(int)>::connection conbar;
   sigc::connection cona; // connection objects are safe to use beyond the life time of a signal.
 
   {
diff --git a/tests/test_size.cc b/tests/test_size.cc
index 3075b16..414d6ec 100644
--- a/tests/test_size.cc
+++ b/tests/test_size.cc
@@ -35,7 +35,7 @@ main(int argc, char* argv[])
     std::cout << "  trackable:               " << sizeof(sigc::trackable) << std::endl;
     std::cout << "  slot<void()>:              " << sizeof(sigc::slot<void()>) << std::endl;
     std::cout << "  signal<void()>:            " << sizeof(sigc::signal<void()>) << std::endl;
-    std::cout << "  signal<void()>::iterator:  " << sizeof(sigc::signal<void()>::iterator)
+    std::cout << "  signal<void()>::connection:  " << sizeof(sigc::signal<void()>::connection)
               << std::endl;
     std::cout << "  connection:              " << sizeof(sigc::connection) << std::endl;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]