[ekiga] Action: Changed the Actor code so that it does not inherit from STL.



commit cc49776cdb3516d90b3fb5ac8238833dd6a7757c
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Mar 1 10:59:11 2015 +0100

    Action: Changed the Actor code so that it does not inherit from STL.
    
    STL containers do not have a virtual destructor. It is thus better to
    use STL containers than to inherit from them.

 lib/engine/action/actor.cpp |   34 +++++++++++++++++++++++++++++++---
 lib/engine/action/actor.h   |   21 ++++++++++++++++++++-
 2 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/lib/engine/action/actor.cpp b/lib/engine/action/actor.cpp
index d9ff963..0e317f4 100644
--- a/lib/engine/action/actor.cpp
+++ b/lib/engine/action/actor.cpp
@@ -44,7 +44,7 @@ Actor::add_action (ActionPtr action)
 {
   remove_action (action->get_name ()); // Remove any other action with the same name.
 
-  push_back (action);
+  actions.push_back (action);
 
   conns.add (action->enabled.connect (boost::bind (boost::ref (action_enabled), action->get_name ())));
   conns.add (action->disabled.connect (boost::bind (boost::ref (action_disabled), action->get_name ())));
@@ -61,7 +61,7 @@ Actor::remove_action (const std::string & name)
     return false;
 
   action_removed (name);
-  remove (a);
+  actions.remove (a);
 
   return true;
 }
@@ -112,5 +112,33 @@ Actor::remove_actions ()
   for (iterator it = begin (); it != end () ; ++it) {
     action_removed ((*it)->get_name ());
   }
-  clear ();
+  actions.clear ();
+}
+
+
+Actor::iterator
+Actor::begin ()
+{
+  return actions.begin ();
+}
+
+
+Actor::iterator
+Actor::end ()
+{
+  return actions.end ();
+}
+
+
+Actor::const_iterator
+Actor::begin () const
+{
+  return actions.begin ();
+}
+
+
+Actor::const_iterator
+Actor::end () const
+{
+  return actions.end ();
 }
diff --git a/lib/engine/action/actor.h b/lib/engine/action/actor.h
index 210d2b3..5499c0a 100644
--- a/lib/engine/action/actor.h
+++ b/lib/engine/action/actor.h
@@ -57,7 +57,7 @@ namespace Ekiga {
    * It can remove them using the remove_action and remove_actions methods.
    *
    */
-  class Actor : public std::list< ActionPtr >
+  class Actor
   {
     friend class ActionProvider;
 
@@ -81,6 +81,23 @@ namespace Ekiga {
     boost::signals2::signal<void(const std::string &)> action_removed;
 
 
+    /** Returns an iterator to the first Action of the collection
+     */
+    iterator begin ();
+
+    /** Returns an iterator to the last Action of the collection
+     */
+    iterator end ();
+
+    /** Returns a const iterator to the first Action of the collection
+     */
+    const_iterator begin () const;
+
+    /** Returns a const iterator to the last Action of the collection
+     */
+    const_iterator end () const;
+
+
   protected:
     /** Add an action to the given Actor.
      *
@@ -130,6 +147,7 @@ namespace Ekiga {
      */
     virtual ActionPtr get_action (const std::string & name);
 
+
   private:
 
     /**
@@ -137,6 +155,7 @@ namespace Ekiga {
      * It contains all actions supported by the current Actor.
      */
     Ekiga::scoped_connections conns;
+    std::list< ActionPtr > actions; // FIXME: Use a RefLister here.
   };
   typedef boost::shared_ptr< Actor > ActorPtr;
 


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