[ekiga] Actor: Improved and simplified API.



commit a6cf81c31eee7b9df04e1db15fc058ecff3bc33c
Author: Damien Sandras <dsandras seconix com>
Date:   Mon Jan 5 19:46:14 2015 +0100

    Actor: Improved and simplified API.
    
    - Instead of using an internal object to store Actions, we inherit from
      a std::list, which simplifies things.
    - Consequently, we can remove our custom iterators.
    - Removed friend GActorMenu. It was a leftover from previous tests and
      is useless.

 lib/engine/action/actor.cpp |   46 ++++--------------------------------------
 lib/engine/action/actor.h   |   29 ++++----------------------
 2 files changed, 10 insertions(+), 65 deletions(-)
---
diff --git a/lib/engine/action/actor.cpp b/lib/engine/action/actor.cpp
index de9eab1..d13f7f3 100644
--- a/lib/engine/action/actor.cpp
+++ b/lib/engine/action/actor.cpp
@@ -45,7 +45,7 @@ Actor::add_action (ActionPtr action)
 {
   remove_action (action->get_name ()); // Remove any other action with the same name.
 
-  actions.push_back (action);
+  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 ())));
@@ -54,14 +54,6 @@ Actor::add_action (ActionPtr action)
 }
 
 
-void
-Actor::add_action (const ActionStore & _actions)
-{
-  for (ActionStore::const_iterator it = _actions.begin (); it != _actions.end () ; ++it)
-    add_action (*it);
-}
-
-
 bool
 Actor::remove_action (const std::string & name)
 {
@@ -70,7 +62,7 @@ Actor::remove_action (const std::string & name)
     return false;
 
   action_removed (name);
-  actions.remove (a);
+  remove (a);
 
   return true;
 }
@@ -105,7 +97,7 @@ Actor::disable_action (const std::string & name)
 ActionPtr
 Actor::get_action (const std::string & name)
 {
-  for (ActionStore::iterator it = actions.begin (); it != actions.end () ; ++it) {
+  for (iterator it = begin (); it != end () ; ++it) {
     if ((*it)->get_name () == name) {
       return (*it);
     }
@@ -118,36 +110,8 @@ Actor::get_action (const std::string & name)
 void
 Actor::remove_actions ()
 {
-  for (ActionStore::iterator it = actions.begin (); it != actions.end () ; ++it) {
+  for (iterator it = begin (); it != end () ; ++it) {
     action_removed ((*it)->get_name ());
   }
-  actions.clear ();
-}
-
-
-Actor::const_iterator
-Actor::begin () const
-{
-  return actions.begin ();
-}
-
-
-Actor::const_iterator
-Actor::end () const
-{
-  return actions.end ();
-}
-
-
-Actor::iterator
-Actor::begin ()
-{
-  return actions.begin ();
-}
-
-
-Actor::iterator
-Actor::end ()
-{
-  return actions.end ();
+  clear ();
 }
diff --git a/lib/engine/action/actor.h b/lib/engine/action/actor.h
index afa8f2b..c3303ca 100644
--- a/lib/engine/action/actor.h
+++ b/lib/engine/action/actor.h
@@ -58,13 +58,13 @@ namespace Ekiga {
    * It can remove them using the remove_action and remove_actions methods.
    *
    */
-  class Actor
+  class Actor : public std::list< ActionPtr >
   {
-    friend class GActorMenu;
-    typedef ActionStore::const_iterator const_iterator;
-    typedef ActionStore::iterator iterator;
+    friend class Action;
 
   public:
+    typedef std::list < ActionPtr >::const_iterator const_iterator;
+    typedef std::list < ActionPtr >::iterator iterator;
 
     /** Add an action to the given Actor.
      *
@@ -76,16 +76,6 @@ namespace Ekiga {
     virtual void add_action (ActionPtr action);
 
 
-    /** Add actions from an ActionStore to the given Actor.
-     *
-     * Actions that are not "added" using this method will not be usable
-     * from menus.
-     *
-     * @param An ActionStore.
-     */
-    virtual void add_action (const ActionStore & actions);
-
-
     /** Remove an action from the given Actor.
      *
      * @param An Action name.
@@ -125,14 +115,6 @@ namespace Ekiga {
     virtual ActionPtr get_action (const std::string & name);
 
 
-    /** Iterators (able to iterate through actions)
-     */
-    const_iterator begin () const;
-    const_iterator end () const;
-    iterator begin ();
-    iterator end ();
-
-
     /**
      * Those signals are emitted when an Action is enabled/disabled
      * in the ActionMap.
@@ -149,13 +131,12 @@ namespace Ekiga {
     boost::signals2::signal<void(const std::string &)> action_removed;
 
 
-  protected:
+  private:
 
     /**
      * This is the Actor ActionStore.
      * It contains all actions supported by the current Actor.
      */
-    ActionStore actions;
     Ekiga::scoped_connections conns;
   };
   typedef boost::shared_ptr< Actor > ActorPtr;


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