[project @ 2005-01-07 18:19:38 by unknown_lamer]
authorunknown_lamer <unknown>
Fri, 7 Jan 2005 18:19:38 +0000 (18:19 +0000)
committerunknown_lamer <unknown>
Fri, 7 Jan 2005 18:19:38 +0000 (18:19 +0000)
Call watchers from BotConfig::set_watcher_list (BotConfig is almost done)

ChangeLog
source/BotConfig.C
source/BotConfig.H

index ebb93ca..ccd7642 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-01-07  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/BotConfig.C (set_option_value): call watcher list
+       (run_fun_): Added to support watcher list calling
+
 2005-01-06  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * source/BotConfig.C (set_option_value): Fuck you STL
index dd478a9..87c3edd 100644 (file)
@@ -99,17 +99,34 @@ namespace
       : lst (l) 
     {}
 
-    void operator()(BotConfig::t_value val)
+    void operator() (BotConfig::t_value val)
     {
       lst->push_back (val);
     }
   };
+  
+  struct run_fun_
+  {
+    std::string key;
+    BotConfig::t_value_list& vals;
+    bool appended;
+    
+    run_fun_ (std::string k, BotConfig::t_value_list& vl, bool a)
+      : key (k), vals (vl), appended (a) 
+    {}
+
+    void operator() (BotConfig::t_watcher w)
+    {
+      w (key, vals, appended);
+    }
+  };
 }
 
 void BotConfig::set_option_value (std::string key, t_value_list values, 
                                  bool append)
 {
   t_options_db::iterator cf_iter = options_db.find (key);
+
   if (cf_iter != options_db.end ())
     {
       if (append)
@@ -118,9 +135,12 @@ void BotConfig::set_option_value (std::string key, t_value_list values,
          std::for_each (values.begin (), values.end (),
                         push_back_ (&cf_iter->second.first));
        }
-         else
-           cf_iter->second.first = values;
+      else
+       cf_iter->second.first = values;
     }
-}
 
-      
+  // Call Watchers
+  std::for_each (cf_iter->second.second.begin (),
+                cf_iter->second.second.end (),
+                run_fun_ (key, values, append));
+}
index 14dcefe..5d6c61d 100644 (file)
@@ -32,7 +32,7 @@ public:
   typedef std::string t_value;
   typedef std::list<t_value> t_value_list;
 
-  typedef void (*t_watcher) (std::string, t_value_list, bool);
+  typedef void (*t_watcher) (std::string key, t_value_list vals, bool appended);
 
   typedef std::list<t_watcher> t_watcher_list;
   typedef std::pair<t_value_list, t_watcher_list> t_option_values;