gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. 09cac2a8aff7b2013ddc


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 09cac2a8aff7b2013ddcde3302643a149e18adb4
Date: Thu, 13 Jan 2011 09:07:32 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  09cac2a8aff7b2013ddcde3302643a149e18adb4 (commit)
       via  af2ba2af1ecd48e68f71250f5ae4d2f5ed9fd895 (commit)
      from  dca3e820747d26bc0790224b04100c063e2b3163 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=09cac2a8aff7b2013ddcde3302643a149e18adb4


commit 09cac2a8aff7b2013ddcde3302643a149e18adb4
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Jan 13 10:04:25 2011 +0100

    Add accumulator in dist.

diff --git a/libbase/Makefile.am b/libbase/Makefile.am
index 11262ab..b90294f 100644
--- a/libbase/Makefile.am
+++ b/libbase/Makefile.am
@@ -164,6 +164,7 @@ noinst_HEADERS =
 
 inst_HEADERS = \
        $(LIBLTDLHEAD) \
+       accumulator.h \
        SimpleBuffer.h \
        extension.h \
        GnashNumeric.h \

http://git.savannah.gnu.org/cgit//commit/?id=af2ba2af1ecd48e68f71250f5ae4d2f5ed9fd895


commit af2ba2af1ecd48e68f71250f5ae4d2f5ed9fd895
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Jan 13 09:34:08 2011 +0100

    Move accumulator into separate file.

diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index 4407e94..16d5761 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -47,6 +47,7 @@
 #include "revno.h"
 #include "MediaHandler.h"
 #include "utility.h"
+#include "accumulator.h"
 
 using std::endl;
 using std::cout;
@@ -79,84 +80,6 @@ namespace {
     void version_and_copyright(std::ostream& os);
 }
 
-namespace {
-
-/// An accumulating option value to handle multiple -v options.
-template<typename T>
-class accumulator_type : public po::value_semantic {
-public:
-
-    accumulator_type() : _interval(1), _default(0) {}
-
-    /// Set the notifier function.
-    accumulator_type* notifier(boost::function1<void, const T&> f) {
-        _notifier = f;
-        return this;
-    }
-
-    /// Set the default value for this option.
-    accumulator_type* default_value(const T& t) {
-        _default = t;
-        return this;
-    }
-
-    /// Set the implicit value for this option.
-    //
-    /// Unlike for program_options::value, this specifies a value
-    /// to be applied on each occurence of the option.
-    accumulator_type* implicit_value(const T& t) {
-        _interval = t;
-        return this;
-    }
-
-    virtual std::string name() const {
-        return std::string();
-    }
-
-    /// There are no tokens for an accumulator_type
-    virtual unsigned min_tokens() const { return 0; }
-    virtual unsigned max_tokens() const { return 0; }
-
-    // Accumulating from different sources is silly.
-    virtual bool is_composing() const {
-        return false;
-    }
-
-    virtual bool is_required() const { return false; }
-    
-    virtual void parse(boost::any& value_store, 
-                       const std::vector<std::string>& new_tokens,
-                       bool /*utf8*/) const
-    {
-        assert(new_tokens.empty());
-        if (value_store.empty()) value_store = T();
-        boost::any_cast<T&>(value_store) += _interval;
-    }
-
-    virtual bool apply_default(boost::any& value_store) const {
-        value_store = _default;
-        return true;
-    }
-                               
-    virtual void notify(const boost::any& value_store) const {
-        _notifier(boost::any_cast<T>(value_store));
-    }
-    
-    virtual ~accumulator_type() {}
-
-private:
-    boost::function1<void, const T&> _notifier;
-    T _interval;
-    T _default;
-};
-
-template<typename T>
-accumulator_type<T>* accumulator() {
-    return new accumulator_type<T>();
-}
-
-}
-
 int
 main(int argc, char *argv[])
 {
@@ -535,7 +458,6 @@ getSupportedOptions(gnash::Player& p)
     desc.add(dumpOpts);
 #endif
 
-
     return desc;
 }
 
diff --git a/libbase/accumulator.h b/libbase/accumulator.h
new file mode 100644
index 0000000..84ccee3
--- /dev/null
+++ b/libbase/accumulator.h
@@ -0,0 +1,107 @@
+// accumulator.h: accumulating value for boost program_options.
+// 
+//   Copyright (C) 2010, 2011 Free Software Foundation, Inc
+//   Copyright (C) 2010, 2011 benjaminwolsey.de
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef PROGRAM_OPTIONS_ACCUMULATOR_HPP
+#define PROGRAM_OPTIONS_ACCUMULATOR_HPP
+
+#include <boost/program_options/value_semantic.hpp>
+#include <boost/any.hpp>
+#include <boost/function.hpp>
+#include <vector>
+#include <string>
+
+/// An accumulating option value to handle multiple incrementing options.
+template<typename T>
+class accumulator_type : public boost::program_options::value_semantic
+{
+public:
+
+    accumulator_type() : _interval(1), _default(0) {}
+
+    /// Set the notifier function.
+    accumulator_type* notifier(boost::function1<void, const T&> f) {
+        _notifier = f;
+        return this;
+    }
+
+    /// Set the default value for this option.
+    accumulator_type* default_value(const T& t) {
+        _default = t;
+        return this;
+    }
+
+    /// Set the implicit value for this option.
+    //
+    /// Unlike for program_options::value, this specifies a value
+    /// to be applied on each occurence of the option.
+    accumulator_type* implicit_value(const T& t) {
+        _interval = t;
+        return this;
+    }
+
+    virtual std::string name() const { return std::string(); }
+
+    /// There are no tokens for an accumulator_type
+    virtual unsigned min_tokens() const { return 0; }
+    virtual unsigned max_tokens() const { return 0; }
+
+    /// Accumulating from different sources is silly.
+    virtual bool is_composing() const { return false; }
+
+    /// Requiring one or more appearances is unlikely.
+    virtual bool is_required() const { return false; }
+    
+    /// Every appearance of the option simply increments the value
+    //
+    /// There should never be any tokens.
+    virtual void parse(boost::any& value_store, 
+                       const std::vector<std::string>& new_tokens,
+                       bool /*utf8*/) const
+    {
+        assert(new_tokens.empty());
+        if (value_store.empty()) value_store = T();
+        boost::any_cast<T&>(value_store) += _interval;
+    }
+
+    /// If the option doesn't appear, this is the default value.
+    virtual bool apply_default(boost::any& value_store) const {
+        value_store = _default;
+        return true;
+    }
+ 
+    /// Notify the user function with the value of the value store.            
                  
+    virtual void notify(const boost::any& value_store) const {
+        if (_notifier) _notifier(boost::any_cast<T>(value_store));
+    }
+    
+    virtual ~accumulator_type() {}
+
+private:
+    boost::function1<void, const T&> _notifier;
+    T _interval;
+    T _default;
+};
+
+template<typename T>
+accumulator_type<T>* accumulator() {
+    return new accumulator_type<T>();
+}
+
+#endif

-----------------------------------------------------------------------

Summary of changes:
 gui/gnash.cpp         |   80 +------------------------------------
 libbase/Makefile.am   |    1 +
 libbase/accumulator.h |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+), 79 deletions(-)
 create mode 100644 libbase/accumulator.h


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]