ekiga r5935 - in trunk: . lib/engine/addressbook/call-history lib/engine/addressbook/evolution lib/engine/addressbook/ldap lib/engine/addressbook/skel lib/engine/framework lib/engine/presence/avahi lib/engine/presence/local-roster lib/engine/presence/skel



Author: jpuydt
Date: Wed Jan 23 15:05:11 2008
New Revision: 5935
URL: http://svn.gnome.org/viewvc/ekiga?rev=5935&view=rev

Log:
Made a more generalized use of Ekiga::Lister to avoid code duplication
(AKA : maintain as little as possible)
(AKA : make bugs more widely available, so we can squash them more easily)

Modified:
   trunk/ChangeLog
   trunk/lib/engine/addressbook/call-history/history-source.h
   trunk/lib/engine/addressbook/evolution/evolution-source.h
   trunk/lib/engine/addressbook/ldap/ldap-source.h
   trunk/lib/engine/addressbook/skel/book-impl.h
   trunk/lib/engine/addressbook/skel/source-impl.h
   trunk/lib/engine/framework/lister.h
   trunk/lib/engine/presence/avahi/avahi-cluster.h
   trunk/lib/engine/presence/local-roster/local-cluster.h
   trunk/lib/engine/presence/local-roster/local-roster-bridge.cpp
   trunk/lib/engine/presence/skel/cluster-impl.h
   trunk/lib/engine/presence/skel/heap-impl.h

Modified: trunk/lib/engine/addressbook/call-history/history-source.h
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-source.h	(original)
+++ trunk/lib/engine/addressbook/call-history/history-source.h	Wed Jan 23 15:05:11 2008
@@ -49,7 +49,7 @@
  */
 
   class Source :
-    public Ekiga::SourceImpl<Book, Ekiga::delete_book_management<Book> >,
+    public Ekiga::SourceImpl<Book>,
     public Ekiga::Service
   {
   public:

Modified: trunk/lib/engine/addressbook/evolution/evolution-source.h
==============================================================================
--- trunk/lib/engine/addressbook/evolution/evolution-source.h	(original)
+++ trunk/lib/engine/addressbook/evolution/evolution-source.h	Wed Jan 23 15:05:11 2008
@@ -54,7 +54,7 @@
  * @{
  */
 
-  class Source: public Ekiga::SourceImpl<Book, Ekiga::delete_book_management<Book> >
+  class Source: public Ekiga::SourceImpl<Book>
   {
   public:
 

Modified: trunk/lib/engine/addressbook/ldap/ldap-source.h
==============================================================================
--- trunk/lib/engine/addressbook/ldap/ldap-source.h	(original)
+++ trunk/lib/engine/addressbook/ldap/ldap-source.h	Wed Jan 23 15:05:11 2008
@@ -55,7 +55,7 @@
  */
 
   class Source:
-    public Ekiga::SourceImpl<Book, Ekiga::delete_book_management<Book> >,
+    public Ekiga::SourceImpl<Book>,
     public Ekiga::Service
   {
   public:

Modified: trunk/lib/engine/addressbook/skel/book-impl.h
==============================================================================
--- trunk/lib/engine/addressbook/skel/book-impl.h	(original)
+++ trunk/lib/engine/addressbook/skel/book-impl.h	Wed Jan 23 15:05:11 2008
@@ -97,12 +97,20 @@
 
   protected:
 
-    /** More STL-like ways to access the contacts within this Ekiga::BookImpl
-     *
+    /** Returns an iterator to the first Contact of the collection
      */
     iterator begin ();
+
+    /** Returns an iterator to the last Contact of the collection
+     */
     iterator end ();
+
+    /** Returns a const iterator to the first Contact of the collection
+     */
     const_iterator begin () const;
+
+    /** Returns a const iterator to the last Contact of the collection
+     */
     const_iterator end () const;
 
     /** Adds a contact to the Ekiga::Book.
@@ -163,8 +171,7 @@
 void
 Ekiga::BookImpl<ContactType>::visit_contacts (sigc::slot<void, Contact &> visitor)
 {
-  for (iterator iter = begin (); iter != end (); iter++)
-    visitor (*iter);
+  Lister<ContactType>::visit_objects (visitor);
 }
 
 

Modified: trunk/lib/engine/addressbook/skel/source-impl.h
==============================================================================
--- trunk/lib/engine/addressbook/skel/source-impl.h	(original)
+++ trunk/lib/engine/addressbook/skel/source-impl.h	Wed Jan 23 15:05:11 2008
@@ -40,8 +40,7 @@
 
 #include <vector>
 
-#include "map-key-reference-iterator.h"
-#include "map-key-const-reference-iterator.h"
+#include "lister.h"
 #include "source.h"
 
 
@@ -54,29 +53,12 @@
    * @{
    */
 
-  template<typename BookType>
-  struct no_book_management
-  {
-    static void announced_release (BookType &);
-
-    static void release (BookType &);
-
-  };
-
-  template<typename BookType>
-  struct delete_book_management
-  {
-    static void announced_release (BookType &book);
-
-    static void release (BookType &book);
-  };
-
   /** Generic implementation for the Ekiga::Source abstract class.
    *
    * This class is there to make it easy to implement a new type of
    * addressbook source: it will take care of implementing the external api,
    * you just have to decide when to add and remove books.
-   * 
+   *
    * It also provides basic memory management for books, with the second
    * (optional) template argument:
    *  - either no management (the default) ;
@@ -96,21 +78,24 @@
    *  - when the signal is received, then do a remove_book followed by calling
    *    the appropriate api function to delete the Book in your backend.
    */
- template<typename BookType = Book,
-	   typename BookManagementTrait = no_book_management <BookType> >
-  class SourceImpl: public Source
+  template<typename BookType = Book>
+  class SourceImpl:
+    public Source,
+    protected Lister<BookType>
   {
 
   public:
 
-    typedef MapKeyReferenceIterator<BookType,
-				    std::vector<sigc::connection> > iterator;
-    typedef MapKeyConstReferenceIterator<BookType,
-					 std::vector<sigc::connection> > const_iterator;
+    typedef typename Lister<BookType>::iterator iterator;
+    typedef typename Lister<BookType>::const_iterator const_iterator;
+
+    /** The constructor
+     */
+    SourceImpl ();
 
     /** The destructor.
      */
-    virtual ~SourceImpl ();
+    ~SourceImpl ();
 
 
     /** Visit all books of the source and trigger the given callback.
@@ -118,27 +103,6 @@
      */
     void visit_books (sigc::slot<void, Book &> visitor);
 
-
-    /** Returns a const iterator to the first Contact of the collection.
-     */
-    const_iterator begin () const;
-
-
-    /** Returns an iterator to the first Contact of the collection.
-     */
-    iterator begin ();
-
-
-    /** Returns a const iterator to the first Contact of the collection.
-     */
-    const_iterator end () const;
-
-
-    /** Returns an iterator to the last Contact of the collection.
-     */
-    iterator end ();
-
-
   protected:
 
     /** Adds a book to the Ekiga::Source.
@@ -155,9 +119,7 @@
     /** Removes a book from the Ekiga::Source.
      * @param: The Ekiga::Book to be removed.
      * @return: The Ekiga::Source 'book_removed' signal is emitted when the
-     * Ekiga::Book has been removed. The BookManagementTrait associated with
-     * the Ekiga::Source will determine the memory management policy for that
-     * Ekiga::Book.
+     * Ekiga::Book has been removed.
      */
     void remove_book (BookType &book);
 
@@ -166,8 +128,7 @@
 
     /** Disconnects the signals for the Ekiga::Book, emits the 'book_removed'
      * signal on the Ekiga::Source and takes care of the release of that
-     * Ekiga::Book following the policy of the BookManagementTrait associated
-     * with the Ekiga::Source.
+     * Ekiga::Book.
      * @param: The Book to remove.
      */
     void common_removal_steps (BookType &book);
@@ -183,8 +144,7 @@
 
     /** This callback is triggered when the 'removed' signal is emitted on an
      * Ekiga::Book. Emits the Ekiga::Source 'book_removed' signal for that book
-     * and takes care of the deletion of the book or not following the
-     * BookManagementTrait associated with the Ekiga::Source.
+     * and takes care of the deletion of the book.
      * @param: The removed book.
      */
     void on_book_removed (BookType *book);
@@ -216,222 +176,87 @@
     void on_contact_updated (Contact &contact,
 			     BookType *book);
 
-
-    /** Map of books and signals.
-     */
-    std::map<BookType *, std::vector<sigc::connection> > connections;
   };
 
-/**
- * @}
- */
+  /**
+   * @}
+   */
 
 };
 
 
 /* here comes the implementation of the template functions */
-template<typename BookType>
-void
-Ekiga::no_book_management<BookType>::announced_release (BookType &)
-{
-  // nothing
-}
 
 
 template<typename BookType>
-void
-Ekiga::no_book_management<BookType>::release (BookType &)
+Ekiga::SourceImpl<BookType>::SourceImpl ()
 {
-  // nothing
+  /* signal forwarding */
+  Lister<BookType>::object_added.connect (book_added.make_slot ());
+  Lister<BookType>::object_removed.connect (book_removed.make_slot ());
+  Lister<BookType>::object_updated.connect (book_updated.make_slot ());
 }
 
-
 template<typename BookType>
-void
-Ekiga::delete_book_management<BookType>::announced_release (BookType &book)
+Ekiga::SourceImpl<BookType>::~SourceImpl ()
 {
-  book.removed.emit ();
-  release (book);
 }
 
 
 template<typename BookType>
 void
-Ekiga::delete_book_management<BookType>::release (BookType &book)
-{
-  delete &book;
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
-Ekiga::SourceImpl<BookType, BookManagementTrait>::~SourceImpl ()
-{
-  iterator iter = begin ();
-
-  while (iter != end ()) {
-
-    remove_book (*iter); // here iter becomes invalid
-    iter = begin ();
-  }
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
-void
-Ekiga::SourceImpl<BookType,
-		  BookManagementTrait>::visit_books (sigc::slot<void, Book &> visitor)
-{
-  for (iterator iter = begin (); iter != end (); iter++)
-    visitor (*iter);
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
-typename Ekiga::SourceImpl<BookType, BookManagementTrait>::const_iterator
-Ekiga::SourceImpl<BookType, BookManagementTrait>::begin () const
-{
-  return const_iterator (connections.begin ());
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
-typename Ekiga::SourceImpl<BookType, BookManagementTrait>::const_iterator
-Ekiga::SourceImpl<BookType, BookManagementTrait>::end () const
+Ekiga::SourceImpl<BookType>::visit_books (sigc::slot<void, Book &> visitor)
 {
-  return const_iterator (connections.end ());
+  Lister<BookType>::visit_objects (visitor);
 }
 
 
-template<typename BookType,
-	 typename BookManagementTrait>
-typename Ekiga::SourceImpl<BookType, BookManagementTrait>::iterator
-Ekiga::SourceImpl<BookType, BookManagementTrait>::begin ()
-{
-  return iterator (connections.begin ());
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
-typename Ekiga::SourceImpl<BookType, BookManagementTrait>::iterator
-Ekiga::SourceImpl<BookType, BookManagementTrait>::end ()
-{
-  return iterator (connections.end ());
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
-void
-Ekiga::SourceImpl<BookType, BookManagementTrait>::add_book (BookType &book)
-{
-  std::vector<sigc::connection> conns;
-  sigc::connection conn;
-
-  conn = book.removed.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_book_removed), &book));
-  conns.push_back (conn);
-
-  conn = book.updated.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_book_updated), &book));
-  conns.push_back (conn);
-
-  conn = book.contact_added.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_contact_added), &book));
-  conns.push_back (conn);
-
-  conn = book.contact_removed.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_contact_removed), &book));
-  conns.push_back (conn);
-
-  conn = book.contact_updated.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_contact_updated), &book));
-  conns.push_back (conn);
-
-  conn = book.questions.add_handler (questions.make_slot ());
-  conns.push_back (conn);
-
-  connections[&book] = conns;
-  book_added.emit (book);
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
-void
-Ekiga::SourceImpl<BookType, BookManagementTrait>::remove_book (BookType &book)
-{
-  common_removal_steps (book);
-  BookManagementTrait::announced_release (book);
-}
-
-
-template<typename BookType,
-	 typename BookManagementTrait>
+template<typename BookType>
 void
-Ekiga::SourceImpl<BookType,
-		  BookManagementTrait>::common_removal_steps (BookType &book)
+Ekiga::SourceImpl<BookType>::add_book (BookType &book)
 {
-  std::vector<sigc::connection> conns = connections[&book];
+  book.contact_added.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_contact_added), &book));
 
-  for (std::vector<sigc::connection>::iterator iter = conns.begin ();
-       iter != conns.end ();
-       iter++)
-    iter->disconnect ();
+  book.contact_removed.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_contact_removed), &book));
 
-  connections.erase (&book);
-  book_removed.emit (book);
-}
+  book.contact_updated.connect (sigc::bind (sigc::mem_fun (this, &SourceImpl::on_contact_updated), &book));
 
+  book.questions.add_handler (questions.make_slot ());
 
-template<typename BookType,
-	 typename BookManagementTrait>
-void
-Ekiga::SourceImpl<BookType,
-		  BookManagementTrait>::on_book_updated (BookType *book)
-{
-  book_updated.emit (*book);
+  add_object (book);
 }
 
 
-template<typename BookType,
-	 typename BookManagementTrait>
+template<typename BookType>
 void
-Ekiga::SourceImpl<BookType,
-		  BookManagementTrait>::on_book_removed (BookType *book)
+Ekiga::SourceImpl<BookType>::remove_book (BookType &book)
 {
-  common_removal_steps (*book);
-  BookManagementTrait::release (*book);
+  remove_object (book);
 }
 
 
-template<typename BookType,
-	 typename BookManagementTrait>
+template<typename BookType>
 void
-Ekiga::SourceImpl<BookType,
-		  BookManagementTrait>::on_contact_added (Contact &contact,
-							  BookType *book)
+Ekiga::SourceImpl<BookType>::on_contact_added (Contact &contact,
+					       BookType *book)
 {
   contact_added.emit (*book, contact);
 }
 
 
-template<typename BookType,
-	 typename BookManagementTrait>
+template<typename BookType>
 void
-Ekiga::SourceImpl<BookType,
-		  BookManagementTrait>::on_contact_removed (Contact &contact,
-							    BookType *book)
+Ekiga::SourceImpl<BookType>::on_contact_removed (Contact &contact,
+						 BookType *book)
 {
   contact_removed.emit (*book, contact);
 }
 
 
-template<typename BookType,
-	 typename BookManagementTrait>
+template<typename BookType>
 void
-Ekiga::SourceImpl<BookType,
-		  BookManagementTrait>::on_contact_updated (Contact &contact,
-							    BookType *book)
+Ekiga::SourceImpl<BookType>::on_contact_updated (Contact &contact,
+						 BookType *book)
 {
   contact_updated.emit (*book, contact);
 }

Modified: trunk/lib/engine/framework/lister.h
==============================================================================
--- trunk/lib/engine/framework/lister.h	(original)
+++ trunk/lib/engine/framework/lister.h	Wed Jan 23 15:05:11 2008
@@ -79,6 +79,10 @@
     ~Lister ();
 
 
+    /** Allows listing all objects
+     */
+    void visit_objects (sigc::slot<void, ObjectType &> visitor);
+
     /** Returns a const iterator to the first object of the collection.
      */
     const_iterator begin () const;
@@ -184,6 +188,15 @@
 
 
 template<typename ObjectType>
+void
+Ekiga::Lister<ObjectType>::visit_objects (sigc::slot<void, ObjectType &> visitor)
+{
+  for (iterator iter = begin (); iter != end (); iter++)
+    visitor (*iter);
+}
+
+
+template<typename ObjectType>
 typename Ekiga::Lister<ObjectType>::const_iterator
 Ekiga::Lister<ObjectType>::begin () const
 {

Modified: trunk/lib/engine/presence/avahi/avahi-cluster.h
==============================================================================
--- trunk/lib/engine/presence/avahi/avahi-cluster.h	(original)
+++ trunk/lib/engine/presence/avahi/avahi-cluster.h	Wed Jan 23 15:05:11 2008
@@ -51,7 +51,7 @@
  */
 
   class Cluster:
-    public Ekiga::ClusterImpl<Heap, Ekiga::delete_heap_management<Heap> >
+    public Ekiga::ClusterImpl<Heap>
   {
   public:
 

Modified: trunk/lib/engine/presence/local-roster/local-cluster.h
==============================================================================
--- trunk/lib/engine/presence/local-roster/local-cluster.h	(original)
+++ trunk/lib/engine/presence/local-roster/local-cluster.h	Wed Jan 23 15:05:11 2008
@@ -49,7 +49,7 @@
  */
 
   class Cluster :
-    public Ekiga::ClusterImpl<Heap, Ekiga::delete_heap_management<Heap> >,
+    public Ekiga::ClusterImpl<Heap>,
     public Ekiga::Trigger
   {
   public:
@@ -72,6 +72,9 @@
 
     const std::set<std::string> existing_groups () const;
 
+    Heap &get_heap ()
+    { return *heap; }
+
   private:
 
     Ekiga::ServiceCore &core;

Modified: trunk/lib/engine/presence/local-roster/local-roster-bridge.cpp
==============================================================================
--- trunk/lib/engine/presence/local-roster/local-roster-bridge.cpp	(original)
+++ trunk/lib/engine/presence/local-roster/local-roster-bridge.cpp	Wed Jan 23 15:05:11 2008
@@ -93,12 +93,12 @@
 
     if (cluster.is_supported_uri (iter->second)) {
 
-      Cluster::iterator heapiter = cluster.begin (); // no loop : only one
+      Heap &heap = cluster.get_heap ();
 
-      if (!heapiter->has_presentity_with_uri (iter->second)) {
+      if (!heap.has_presentity_with_uri (iter->second)) {
 
 	builder.add_action ("add", _("Add to local roster"),
-			    sigc::bind (sigc::mem_fun (*heapiter, &Local::Heap::new_presentity),
+			    sigc::bind (sigc::mem_fun (heap, &Local::Heap::new_presentity),
 					contact.get_name (), iter->second));
 	populated = true;
       }

Modified: trunk/lib/engine/presence/skel/cluster-impl.h
==============================================================================
--- trunk/lib/engine/presence/skel/cluster-impl.h	(original)
+++ trunk/lib/engine/presence/skel/cluster-impl.h	Wed Jan 23 15:05:11 2008
@@ -38,8 +38,7 @@
 
 #include <vector>
 
-#include "map-key-reference-iterator.h"
-#include "map-key-const-reference-iterator.h"
+#include "lister.h"
 #include "cluster.h"
 
 namespace Ekiga
@@ -50,37 +49,12 @@
  * @{
  */
 
-  template<typename HeapType>
-  struct no_heap_management
-  {
-    static void announced_release (HeapType &);
-
-    static void release (HeapType &);
-  };
-
-  template<typename HeapType>
-  struct delete_heap_management
-  {
-    static void announced_release (HeapType &heap);
-
-    static void release (HeapType &heap);
-
-  };
-
   /** Generic implementation for the Ekiga::Cluster abstract class.
    *
    * This class is there to make it easy to implement a new type of
    * cluster: it will take care of implementing the external api, you
    * just have to decide when to add and remove heaps.
    *
-   * It also provides basic memory management for heaps, with the second
-   * (optional) template argument:
-   *  - either no management (the default);
-   *  - or the heap is considered bound to one cluster, which will trigger its
-   *    destruction (using delete) when removed from it, which can happen in
-   *    two ways: either by calling the remove_heap method, or by emission of
-   *    the Heap's removed signal.
-   *
    * Notice that this class won't take care of removing the heap from a
    * backend -- only from the cluster. If you want the heap <b>deleted</b> then
    * you probably should have an organization like:
@@ -91,28 +65,23 @@
    */
 
 
-  template<typename HeapType = Heap,
-	   typename HeapManagementTrait = no_heap_management <HeapType> >
-  class ClusterImpl: public Cluster
+  template<typename HeapType = Heap>
+  class ClusterImpl:
+    public Cluster,
+    protected Lister<HeapType>
   {
 
   public:
 
-    typedef MapKeyReferenceIterator<HeapType, std::vector<sigc::connection> > iterator;
-    typedef MapKeyConstReferenceIterator<HeapType, std::vector<sigc::connection> > const_iterator;
+    typedef typename Lister<HeapType>::iterator iterator;
+    typedef typename Lister<HeapType>::const_iterator const_iterator;
+
+    ClusterImpl ();
 
     virtual ~ClusterImpl ();
 
     void visit_heaps (sigc::slot<void, Heap &> visitor);
 
-    const_iterator begin () const;
-
-    iterator begin ();
-
-    const_iterator end () const;
-
-    iterator end ();
-
   protected:
 
     void add_heap (HeapType &heap);
@@ -123,17 +92,11 @@
 
     void common_removal_steps (HeapType &heap);
 
-    void on_heap_updated (HeapType *heap);
-
-    void on_heap_removed (HeapType *heap);
-
     void on_presentity_added (Presentity &presentity, HeapType *heap);
 
     void on_presentity_updated (Presentity &presentity, HeapType *heap);
 
     void on_presentity_removed (Presentity &presentity, HeapType *heap);
-
-    std::map<HeapType *, std::vector<sigc::connection> > connections;
   };
 
 /**
@@ -145,160 +108,65 @@
 /* here are the implementations of the template methods */
 
 template<typename HeapType>
-void
-Ekiga::no_heap_management<HeapType>::announced_release (HeapType &)
+Ekiga::ClusterImpl<HeapType>::ClusterImpl ()
 {
-  // nothing
+  /* signal forwarding */
+  Lister<HeapType>::object_added.connect (heap_added.make_slot ());
+  Lister<HeapType>::object_removed.connect (heap_removed.make_slot ());
+  Lister<HeapType>::object_updated.connect (heap_updated.make_slot ());
 }
 
 template<typename HeapType>
-void
-Ekiga::no_heap_management<HeapType>::release (HeapType &)
+Ekiga::ClusterImpl<HeapType>::~ClusterImpl ()
 {
-  // nothing
 }
 
 template<typename HeapType>
 void
-Ekiga::delete_heap_management<HeapType>::announced_release (HeapType &heap)
+Ekiga::ClusterImpl<HeapType>::visit_heaps (sigc::slot<void, Heap &> visitor)
 {
-  heap.removed.emit ();
-  release (heap);
+  Lister<HeapType>::visit_objects (visitor);
 }
 
 template<typename HeapType>
 void
-Ekiga::delete_heap_management<HeapType>::release (HeapType &heap)
-{
-  delete &heap;
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::~ClusterImpl ()
-{
-  iterator iter = begin ();
-
-  while (iter != end ()) {
-
-    remove_heap (*iter); // here iter becomes invalid
-    iter = begin ();
-  }
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::visit_heaps (sigc::slot<void, Heap &> visitor)
-{
-  for (iterator iter = begin (); iter != end (); iter++)
-    visitor (*iter);
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-typename Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::const_iterator
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::begin () const
-{
-  return const_iterator (connections.begin ());
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-typename Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::iterator
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::begin ()
-{
-  return iterator (connections.begin ());
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-typename Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::const_iterator
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::end () const
-{
-  return const_iterator (connections.end ());
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-typename Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::iterator
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::end ()
-{
-  return iterator (connections.end ());
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::add_heap (HeapType &heap)
+Ekiga::ClusterImpl<HeapType>::add_heap (HeapType &heap)
 {
-  sigc::connection conn;
-  std::vector<sigc::connection> conns;
+  heap.presentity_added.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_presentity_added), &heap));
 
-  conn = heap.removed.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_heap_removed), &heap));
-  conns.push_back (conn);
-  conn = heap.updated.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_heap_updated), &heap));
-  conns.push_back (conn);
-  conn = heap.presentity_added.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_presentity_added), &heap));
-  conns.push_back (conn);
-  conn = heap.presentity_updated.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_presentity_updated), &heap));
-  conns.push_back (conn);
-  conn = heap.presentity_removed.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_presentity_removed), &heap));
-  conns.push_back (conn);
-  conn = heap.questions.add_handler (questions.make_slot ());
-  conns.push_back (conn);
+  heap.presentity_updated.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_presentity_updated), &heap));
 
-  connections[&heap] = conns;
-  heap_added.emit (heap);
-}
-
-template<typename HeapType, typename HeapManagementTrait>
-void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::remove_heap (HeapType &heap)
-{
-  common_removal_steps (heap);
-  HeapManagementTrait::announced_release (heap);
-}
+  heap.presentity_removed.connect (sigc::bind (sigc::mem_fun (this, &ClusterImpl::on_presentity_removed), &heap));
 
-template<typename HeapType, typename HeapManagementTrait>
-void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::common_removal_steps (HeapType &heap)
-{
-  std::vector<sigc::connection> conns = connections[&heap];
+  heap.questions.add_handler (questions.make_slot ());
 
-  for (std::vector<sigc::connection>::iterator iter = conns.begin ();
-       iter != conns.end ();
-       iter++)
-    iter->disconnect ();
-  connections.erase (&heap);
-  heap_removed.emit (heap);
+  add_object (heap);
 }
 
-template<typename HeapType, typename HeapManagementTrait>
-void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::on_heap_updated (HeapType *heap)
-{
-  heap_updated.emit (*heap);
-}
-
-template<typename HeapType, typename HeapManagementTrait>
+template<typename HeapType>
 void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::on_heap_removed (HeapType *heap)
+Ekiga::ClusterImpl<HeapType>::remove_heap (HeapType &heap)
 {
-  common_removal_steps (*heap);
-  HeapManagementTrait::release (*heap);
+  remove_object (heap);
 }
 
-template<typename HeapType, typename HeapManagementTrait>
+template<typename HeapType>
 void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::on_presentity_added (Presentity &presentity, HeapType *heap)
+Ekiga::ClusterImpl<HeapType>::on_presentity_added (Presentity &presentity, HeapType *heap)
 {
   presentity_added.emit (*heap, presentity);
 }
 
-template<typename HeapType, typename HeapManagementTrait>
+template<typename HeapType>
 void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::on_presentity_updated (Presentity &presentity, HeapType *heap)
+Ekiga::ClusterImpl<HeapType>::on_presentity_updated (Presentity &presentity, HeapType *heap)
 {
   presentity_updated.emit (*heap, presentity);
 }
 
-template<typename HeapType, typename HeapManagementTrait>
+template<typename HeapType>
 void
-Ekiga::ClusterImpl<HeapType, HeapManagementTrait>::on_presentity_removed (Presentity &presentity, HeapType *heap)
+Ekiga::ClusterImpl<HeapType>::on_presentity_removed (Presentity &presentity, HeapType *heap)
 {
   presentity_removed.emit (*heap, presentity);
 }

Modified: trunk/lib/engine/presence/skel/heap-impl.h
==============================================================================
--- trunk/lib/engine/presence/skel/heap-impl.h	(original)
+++ trunk/lib/engine/presence/skel/heap-impl.h	Wed Jan 23 15:05:11 2008
@@ -121,8 +121,7 @@
 void
 Ekiga::HeapImpl<PresentityType>::visit_presentities (sigc::slot<void, Presentity &> visitor)
 {
-  for (iterator iter = begin (); iter != end (); iter++)
-    visitor (*iter);
+  Lister<PresentityType>::visit_objects (visitor);
 }
 
 template<typename PresentityType>
@@ -158,6 +157,7 @@
 Ekiga::HeapImpl<PresentityType>::add_presentity (PresentityType &presentity)
 {
   presentity.questions.add_handler (questions.make_slot ());
+
   add_object (presentity);
 }
 



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