diff options
| author | Alan Conway <aconway@apache.org> | 2008-07-17 00:03:50 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-07-17 00:03:50 +0000 |
| commit | e65b0086a2924ff04640b1350393a816249d01b3 (patch) | |
| tree | b372c5386cc44e3ad16c4ae585088ed038a629e4 /cpp/src/qpid/Plugin.h | |
| parent | e596837411d54a16dd3cb1e5de717664496c2bd0 (diff) | |
| download | qpid-python-e65b0086a2924ff04640b1350393a816249d01b3.tar.gz | |
Cluster: shadow connections, fix lifecycle & valgrind issues.
- tests/ForkedBroker: improved broker forking, exec full qpidd.
- Plugin::addFinalizer - more flexible way to shutdown plugins.
- Reworked cluster extension points using boost::function.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@677471 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/Plugin.h')
| -rw-r--r-- | cpp/src/qpid/Plugin.h | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/cpp/src/qpid/Plugin.h b/cpp/src/qpid/Plugin.h index a53d4e5d18..3c7c8031bb 100644 --- a/cpp/src/qpid/Plugin.h +++ b/cpp/src/qpid/Plugin.h @@ -21,11 +21,9 @@ * */ -#include "qpid/shared_ptr.h" #include <boost/noncopyable.hpp> -#include <vector> #include <boost/function.hpp> - +#include <vector> /**@file Generic plug-in framework. */ @@ -35,30 +33,36 @@ class Options; /** * Plug-in base class. */ -class Plugin : boost::noncopyable -{ +class Plugin : private boost::noncopyable { public: + typedef std::vector<Plugin*> Plugins; + /** - * Base interface for targets that receive plug-ins. - * Plug-ins can register clean-up functions to execute when - * the target is destroyed. + * Base interface for targets that can receive plug-ins. + * Also allows plug-ins to attach a a function to be called + * when the target is 'finalized'. */ - struct Target { + class Target : private boost::noncopyable + { public: + /** Calls finalize() if not already called. */ virtual ~Target(); - void addCleanup(const boost::function<void()>& cleanupFunction); + + /** Run all the finalizers */ + void finalize(); + + /** Add a function to run when finalize() is called */ + void addFinalizer(const boost::function<void()>&); private: - std::vector<boost::function<void()> > cleanup; + std::vector<boost::function<void()> > finalizers; }; - typedef std::vector<Plugin*> Plugins; - /** - * Construct registers the plug-in to appear in getPlugins(). + * Constructor registers the plug-in to appear in getPlugins(). * * A concrete Plugin is instantiated as a global or static - * member variable in a library so it is registered during static + * member variable in a library so it is registered during * initialization when the library is loaded. */ Plugin(); @@ -103,7 +107,7 @@ class Plugin : boost::noncopyable static void earlyInitAll(Target&); /** Call initialize() on all registered plugins */ - static void initAll(Target&); + static void initializeAll(Target&); /** For each registered plugin, add plugin.getOptions() to opts. */ static void addOptions(Options& opts); |
