diff options
30 files changed, 249 insertions, 212 deletions
diff --git a/project2/cgi/cgiCommon.cpp b/project2/cgi/cgiCommon.cpp index 92725c1..58b7e71 100644 --- a/project2/cgi/cgiCommon.cpp +++ b/project2/cgi/cgiCommon.cpp @@ -45,7 +45,7 @@ cgiServe(cgicc::CgiInput * i, CgiEnvironment * env, std::ostream & IO, const Cgi  		env->init();  		CgiApplicationEngine app(env, IO); -		LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onBefore, _1)); +		Plugable::onAllComponents(boost::bind(&ComponentLoader::onBefore, _1));  		Logger()->messagef(LOG_DEBUG, "%s: Processing request", __FUNCTION__);  		app.process();  		Logger()->messagef(LOG_DEBUG, "%s: Completed request", __FUNCTION__); diff --git a/project2/cgi/p2webCgi.cpp b/project2/cgi/p2webCgi.cpp index 80b5a98..1b2aa99 100644 --- a/project2/cgi/p2webCgi.cpp +++ b/project2/cgi/p2webCgi.cpp @@ -15,12 +15,12 @@ class GetEnv : public CgiEnvInput {  int  main(void)  { -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));  	CgiEnvironment env;  	GetEnv ge;  	cgiServe(NULL, &env, std::cout, &ge); -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1)); -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1)); -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));  } diff --git a/project2/cgi/p2webFCgi.cpp b/project2/cgi/p2webFCgi.cpp index e0782e0..7eb631f 100644 --- a/project2/cgi/p2webFCgi.cpp +++ b/project2/cgi/p2webFCgi.cpp @@ -11,7 +11,7 @@ void  p2webPeriodic()  {  	time(&lastPeriodic); -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1));  }  static @@ -21,7 +21,7 @@ p2webGoingIdle(int)  	if (time(NULL) > lastPeriodic + periodicDelay) {  		p2webPeriodic();  	} -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));  }  int @@ -41,13 +41,13 @@ main(void)  		}  		alarm(60);  		CgiEnvironment env; -		LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1)); +		Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));  		while (FCGX_Accept_r(&request) == 0) {  			alarm(0);  			cgicc::FCgiIO IO(request);  			cgiServe(&IO, &env, IO, &IO);  			FCGX_Finish_r(&request); -			LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1)); +			Plugable::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1));  			if (time(NULL) > lastPeriodic + periodicDelay) {  				p2webPeriodic();  			} diff --git a/project2/cgi/testCgi.cpp b/project2/cgi/testCgi.cpp index cff947d..cd42873 100644 --- a/project2/cgi/testCgi.cpp +++ b/project2/cgi/testCgi.cpp @@ -13,7 +13,7 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput {  		class TestConfigConsumer : public ConfigConsumer {  			public:  				void operator()(const Glib::ustring & n, const Glib::ustring & p, const Glib::ustring & v) const { -					LoaderBase::onAll<Options>(boost::bind(&Options::consume, _1, n, p, v)); +					Plugable::onAll<Options>(boost::bind(&Options::consume, _1, n, p, v));  				}  				const Options::Option * get(const Glib::ustring &) const {  					return NULL; diff --git a/project2/common/aggregate.h b/project2/common/aggregate.h index 18ad6a5..0641c6e 100644 --- a/project2/common/aggregate.h +++ b/project2/common/aggregate.h @@ -2,6 +2,7 @@  #define AGGREGATE_H  #include "scripts.h" +#include "variables.h"  #include <boost/function.hpp>  class Aggregate : public SourceObject { diff --git a/project2/common/componentLoader.cpp b/project2/common/componentLoader.cpp new file mode 100644 index 0000000..56eb833 --- /dev/null +++ b/project2/common/componentLoader.cpp @@ -0,0 +1,37 @@ +#include "componentLoader.h" + +ComponentLoader::~ComponentLoader() +{ +} + +void +ComponentLoader::onBegin() +{ +} + +void +ComponentLoader::onBefore() +{ +} + +void +ComponentLoader::onIdle() +{ +} + +void +ComponentLoader::onIteration() +{ +} + +void +ComponentLoader::onPeriodic() +{ +} + +void +ComponentLoader::onConfigLoad() +{ +} + + diff --git a/project2/common/componentLoader.h b/project2/common/componentLoader.h new file mode 100644 index 0000000..5d14efe --- /dev/null +++ b/project2/common/componentLoader.h @@ -0,0 +1,18 @@ +#ifndef COMPONENTLOADER_H +#define COMPONENTLOADER_H + +/// Helper for loading and maintaining Project2 components +class ComponentLoader { +	public: +		virtual ~ComponentLoader() = 0; +		virtual void onBegin();		// App engine start up (before settings are processed) +		virtual void onBefore();		// Before the app engine processes a request (after settings are processed) +		virtual void onIdle();		// When the app engine goes idle +		virtual void onIteration();	// When the app engine has completed an iteration +		virtual void onPeriodic();	// When the app engine feels like it +		virtual void onConfigLoad(); // When the environment reloads the configuration +		virtual bool cacheable() const { return true; } // The component can be cached for next run +}; + +#endif + diff --git a/project2/common/environment.cpp b/project2/common/environment.cpp index 7d24c5c..71327f8 100644 --- a/project2/common/environment.cpp +++ b/project2/common/environment.cpp @@ -40,7 +40,7 @@ Environment::Environment()  {  	currentEnv = this;  	typedef std::map<std::string, boost::shared_ptr<OptionsSourceLoader> > ConfigParsersMap; -	BOOST_FOREACH(const ConfigParsersMap::value_type & cp, *LoaderBase::objLoaders<OptionsSourceLoader>()) { +	BOOST_FOREACH(const ConfigParsersMap::value_type & cp, *Plugable::objLoaders<OptionsSourceLoader>()) {  		configs.push_back(cp.second->create());  	}  } @@ -50,11 +50,11 @@ typedef std::vector<const Options *> AllOptions;  class DefaultConfigConsumer : public ConfigConsumer {  	public:  		void operator()(const Glib::ustring & n, const Glib::ustring & p, const Glib::ustring & v) const { -			LoaderBase::onAll<Options>(boost::bind(&Options::consume, _1, n, p, v)); +			Plugable::onAll<Options>(boost::bind(&Options::consume, _1, n, p, v));  		}  		const Options::Option * get(const Glib::ustring & n) const {  			const Options::Option * rtn = NULL; -			LoaderBase::onAll<Options>([n,&rtn](const Options * os) { +			Plugable::onAll<Options>([n,&rtn](const Options * os) {  				const Options::Option * o = os->find(n);  				if (o) {  					rtn = o; @@ -70,12 +70,12 @@ Environment::init()  	if (std::find_if(configs.begin(), configs.end(), boost::bind(&OptionsSource::needReload, _1)) != configs.end()) {  		DefaultConfigConsumer dcc; -		LoaderBase::onAll<Options>(boost::bind(&Options::reset, _1)); +		Plugable::onAll<Options>(boost::bind(&Options::reset, _1));  		BOOST_FOREACH(const ConfigsMap::value_type & c, configs) {  			c->loadInto(dcc);  		} -		LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onConfigLoad, _1)); +		Plugable::onAllComponents(boost::bind(&ComponentLoader::onConfigLoad, _1));  		Logger()->clear();  		if (clLevel >= 0) { @@ -111,7 +111,7 @@ Environment::resolveScript(const std::string & group, const std::string & name,  			return i->second;  		}  		else { -			BOOST_FOREACH(const ReaderLoaders::value_type & rl, *LoaderBase::objLoaders<ScriptReaderLoader>()) { +			BOOST_FOREACH(const ReaderLoaders::value_type & rl, *Plugable::objLoaders<ScriptReaderLoader>()) {  				ScriptReaderPtr rs = rl.second->resolveScript(group, e.string());  				if (rs) {  					return (scriptCache[sk] = rs); diff --git a/project2/common/genLoader.h b/project2/common/genLoader.h new file mode 100644 index 0000000..e8fb683 --- /dev/null +++ b/project2/common/genLoader.h @@ -0,0 +1,30 @@ +#ifndef GENLOADER_H +#define GENLOADER_H + +#include "componentLoader.h" +#include "plugable.h" + +template <class Impl, typename... Params> +class GenLoader : public ComponentLoader { +	public: +		template <class T> +		class For : public GenLoader<Impl, Params...> { +			public: +				inline Impl * create(const Params & ... p) const +				{ +					return new T(p...); +				} +		}; +		virtual Impl * create(const Params & ...) const = 0; +		inline static Impl * createNew(const std::string & n, const Params & ... p) +		{ +			return Plugable::getLoader<GenLoader<Impl, Params...>, NotSupported>(n)->create(p...); +		} +		inline static boost::shared_ptr<GenLoader<Impl, Params...>> getFor(const std::string & n) +		{ +			return Plugable::getLoader<GenLoader<Impl, Params...>, NotSupported>(n); +		} +}; + +#endif + diff --git a/project2/common/library.cpp b/project2/common/library.cpp index 911d428..2794d3b 100644 --- a/project2/common/library.cpp +++ b/project2/common/library.cpp @@ -4,6 +4,7 @@  #include "exceptions.h"  #include "scripts.h"  #include "library.h" +#include "variables.h"  SimpleMessageException(LoadLibraryFailed);  SimpleMessageException(UnloadLibraryFailed); diff --git a/project2/common/logger.h b/project2/common/logger.h index 5a4809d..5f2ff2a 100644 --- a/project2/common/logger.h +++ b/project2/common/logger.h @@ -8,7 +8,7 @@  #include <boost/intrusive_ptr.hpp>  #include <boost/format.hpp>  #include "intrusivePtrBase.h" -#include "scriptLoader.h" +#include "genLoader.h"  /// Base class for classes providing a logging facility  class LogDriverBase : public virtual IntrusivePtrBase { diff --git a/project2/common/options.h b/project2/common/options.h index 34a22f6..e92e69b 100644 --- a/project2/common/options.h +++ b/project2/common/options.h @@ -104,13 +104,13 @@ class Options {  	static void init_options_##Type() { \  		Options * o = new Options(Label); \  		Type::InitOptions(*o); \ -		LoaderBase::newLoader<Options, Options>(#Type, o); } \ +		Plugable::newLoader<Options, Options>(#Type, o); } \  		void Type::InitOptions(Options & o) { o  #define END_OPTIONS(Type) \  		;} \  	static void kill_options_##Type() __attribute__ ((destructor(200))); \ -	static void kill_options_##Type() { LoaderBase::removeLoader<Options, Options>(#Type); } +	static void kill_options_##Type() { Plugable::removeLoader<Options, Options>(#Type); }  #define INITOPTIONS \  		static void InitOptions(Options &) diff --git a/project2/common/pch.hpp b/project2/common/pch.hpp index da12580..3319b62 100644 --- a/project2/common/pch.hpp +++ b/project2/common/pch.hpp @@ -25,6 +25,7 @@  #include <vector>  #include "scriptStorage.h"  #include "scriptLoader.h" +//#include "plugable.h"  #include "variables.h"  #include "variableType.h"  #include "sourceObject.h" diff --git a/project2/common/plugable.h b/project2/common/plugable.h new file mode 100644 index 0000000..74a2019 --- /dev/null +++ b/project2/common/plugable.h @@ -0,0 +1,110 @@ +#ifndef PLUGABLE_H +#define PLUGABLE_H + +#include <set> +#include <map> +#include <boost/function.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/foreach.hpp> +#include "exceptions.h" + +class Plugable { +	public: +		template <class CT> +			class ComponentType { +				public: +					static std::set<boost::shared_ptr<CT>> * & components() +					{ +						static std::set<boost::shared_ptr<CT>> * _comp = NULL; +						if (!_comp) { +							_comp = new std::set<boost::shared_ptr<CT>>(); +						} +						return _comp; +					} +			}; + +		static inline void onAllComponents(const boost::function<void(ComponentLoader *)> & func) +		{ +			onAll<ComponentLoader>(func); +		} + +		template <class CT> +			static void onAll(const boost::function<void(CT *)> & func) { +				BOOST_FOREACH(const auto & l, *ComponentType<CT>::components()) { +					try { +						func(l.get()); +					} +					catch (...) { +					} +				} +			} + +		template <class T> +			static std::map<std::string, boost::shared_ptr<T> > * & objLoaders()  +			{ +				static std::map<std::string, boost::shared_ptr<T> > * _objLoaders = NULL; +				if (!_objLoaders) { +					_objLoaders = new std::map<std::string, boost::shared_ptr<T> >(); +				} +				return _objLoaders; +			} + +		template <class T, class BT> +			static void newLoader(const std::string & n, T * l) +			{ +				boost::shared_ptr<T> p = boost::shared_ptr<T>(l); +				objLoaders<T>()->insert(std::pair<std::string, boost::shared_ptr<T> >(n, p)); +				ComponentType<BT>::components()->insert(boost::shared_ptr<T>(p)); +			} + +		template <class T, class BT> +			static void removeLoader(const std::string & n) +			{ +				std::map<std::string, boost::shared_ptr<T> > * & o = objLoaders<T>(); +				std::set<boost::shared_ptr<BT> > * & c = ComponentType<BT>::components(); +				typename std::map<std::string, boost::shared_ptr<T> >::iterator i = o->find(n); +				c->erase(i->second); +				o->erase(i); +				if (o->empty()) { +					delete o; +					o = NULL; +				} +				if (c->empty()) { +					delete c; +					c = NULL; +				} +			} + +		template <class L, class E> +			static boost::shared_ptr<L> getLoader(const std::string & n)  +			{ +				typename std::map<std::string, boost::shared_ptr<L> >::const_iterator i = objLoaders<L>()->find(n); +				if (i != objLoaders<L>()->end()) { +					return i->second; +				} +				else { +					throw E(n); +				} +			} +}; + +#define TOKENPASTE(x, y) x ## y +#define TOKENPASTE2(x, y) TOKENPASTE(x, y) +#define DECLARE_CUSTOM_COMPONENT_LOADER(N, I, T, B) \ +namespace TOKENPASTE2(I, __LINE__) { \ +	static void init_loader_##I() __attribute__ ((constructor(201))); \ +	static void init_loader_##I() { Plugable::newLoader<B, ComponentLoader>(N, new T()); } \ +	static void kill_loader_##I() __attribute__ ((destructor(201))); \ +	static void kill_loader_##I() { Plugable::removeLoader<B, ComponentLoader>(N); } \ +} +#define DECLARE_CUSTOM_LOADER(N, T) \ +	DECLARE_CUSTOM_COMPONENT_LOADER(N, T, T, ElementLoader) +#define DECLARE_COMPONENT_LOADER(N, T, B) \ +	DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B::For<T>, B) +#define DECLARE_LOADER(N, T) \ +	DECLARE_COMPONENT_LOADER(N, T, ElementLoader) +#define DECLARE_GENERIC_LOADER(N, B, T) \ +	DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B::For<T>, B); + +#endif + diff --git a/project2/common/scriptLoader.cpp b/project2/common/scriptLoader.cpp index f622856..66cf2aa 100644 --- a/project2/common/scriptLoader.cpp +++ b/project2/common/scriptLoader.cpp @@ -138,43 +138,3 @@ LoaderBase::collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePt  	}  } -void -LoaderBase::onAllComponents(const boost::function1<void, ComponentLoader *> & func) -{ -	onAll<ComponentLoader>(func); -} - -ComponentLoader::~ComponentLoader() -{ -} - -void -ComponentLoader::onBegin() -{ -} - -void -ComponentLoader::onBefore() -{ -} - -void -ComponentLoader::onIdle() -{ -} - -void -ComponentLoader::onIteration() -{ -} - -void -ComponentLoader::onPeriodic() -{ -} - -void -ComponentLoader::onConfigLoad() -{ -} - diff --git a/project2/common/scriptLoader.h b/project2/common/scriptLoader.h index 6e0bfe5..181292c 100644 --- a/project2/common/scriptLoader.h +++ b/project2/common/scriptLoader.h @@ -4,13 +4,10 @@  #include <set>  #include <string>  #include <boost/intrusive_ptr.hpp> -#include <boost/function.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/foreach.hpp>  #include "intrusivePtrBase.h"  #include "sourceObject.h" +#include "genLoader.h"  #include "scripts_fwd.h" -#include "exceptions.h"  #include <glibmm/ustring.h>  #include <map>  #include <vector> @@ -30,85 +27,12 @@ class LoaderBase {  		LoaderBase();  		virtual ~LoaderBase(); -		void collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr script); +		void collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr script);  		void addLoadTarget(ScriptNodePtr src, boost::intrusive_ptr<Storer> target);  		void addLoadTargetSub(ScriptNodePtr src, const Glib::ustring & name, bool required, boost::intrusive_ptr<Storer> target);  		void discardLoadTargets(); -		static void onAllComponents(const boost::function1<void, ComponentLoader *> &); -		template <class CT> -		static void onAll(const boost::function<void(CT *)> & func) { -			BOOST_FOREACH(const auto & l, *ComponentType<CT>::components()) { -				try { -					func(l.get()); -				} -				catch (...) { -				} -			} -		} - -		template <class CT> -			class ComponentType { -				public: -					static std::set<boost::shared_ptr<CT>> * & components() -					{ -						static std::set<boost::shared_ptr<CT>> * _comp = NULL; -						if (!_comp) { -							_comp = new std::set<boost::shared_ptr<CT>>(); -						} -						return _comp; -					} -			}; - -		template <class T> -			static std::map<std::string, boost::shared_ptr<T> > * & objLoaders()  -			{ -				static std::map<std::string, boost::shared_ptr<T> > * _objLoaders = NULL; -				if (!_objLoaders) { -					_objLoaders = new std::map<std::string, boost::shared_ptr<T> >(); -				} -				return _objLoaders; -			} - -		template <class T, class BT> -			static void newLoader(const std::string & n, T * l) -			{ -				boost::shared_ptr<T> p = boost::shared_ptr<T>(l); -				objLoaders<T>()->insert(std::pair<std::string, boost::shared_ptr<T> >(n, p)); -				ComponentType<BT>::components()->insert(boost::shared_ptr<T>(p)); -			} - -		template <class T, class BT> -			static void removeLoader(const std::string & n) -			{ -				std::map<std::string, boost::shared_ptr<T> > * & o = objLoaders<T>(); -				std::set<boost::shared_ptr<BT> > * & c = ComponentType<BT>::components(); -				typename std::map<std::string, boost::shared_ptr<T> >::iterator i = o->find(n); -				c->erase(i->second); -				o->erase(i); -				if (o->empty()) { -					delete o; -					o = NULL; -				} -				if (c->empty()) { -					delete c; -					c = NULL; -				} -			} - -		template <class L, class E> -			static boost::shared_ptr<L> getLoader(const std::string & n)  -			{ -				typename std::map<std::string, boost::shared_ptr<L> >::const_iterator i = objLoaders<L>()->find(n); -				if (i != objLoaders<L>()->end()) { -					return i->second; -				} -				else { -					throw E(n); -				} -			} -  	private:  		void collectAll(ScriptNodePtr script, bool childrenOnly, const StorerPtrs & sts) const;  		static ScriptNodePtr getSub(ScriptNodePtr root, const Glib::ustring & name, bool required); @@ -123,59 +47,6 @@ class LoaderBase {  		const Glib::ustring ns;  }; -#define TOKENPASTE(x, y) x ## y -#define TOKENPASTE2(x, y) TOKENPASTE(x, y) -#define DECLARE_CUSTOM_COMPONENT_LOADER(N, I, T, B) \ -namespace TOKENPASTE2(I, __LINE__) { \ -	static void init_loader_##I() __attribute__ ((constructor(201))); \ -	static void init_loader_##I() { LoaderBase::newLoader<B, ComponentLoader>(N, new T()); } \ -	static void kill_loader_##I() __attribute__ ((destructor(201))); \ -	static void kill_loader_##I() { LoaderBase::removeLoader<B, ComponentLoader>(N); } \ -} -#define DECLARE_CUSTOM_LOADER(N, T) \ -	DECLARE_CUSTOM_COMPONENT_LOADER(N, T, T, ElementLoader) -#define DECLARE_COMPONENT_LOADER(N, T, B) \ -	DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B::For<T>, B) -#define DECLARE_LOADER(N, T) \ -	DECLARE_COMPONENT_LOADER(N, T, ElementLoader) -#define DECLARE_GENERIC_LOADER(N, B, T) \ -	DECLARE_CUSTOM_COMPONENT_LOADER(N, T, B::For<T>, B); - -/// Helper for loading and maintaining Project2 components -class ComponentLoader { -	public: -		virtual ~ComponentLoader() = 0; -		virtual void onBegin();		// App engine start up (before settings are processed) -		virtual void onBefore();		// Before the app engine processes a request (after settings are processed) -		virtual void onIdle();		// When the app engine goes idle -		virtual void onIteration();	// When the app engine has completed an iteration -		virtual void onPeriodic();	// When the app engine feels like it -		virtual void onConfigLoad(); // When the environment reloads the configuration -		virtual bool cacheable() const { return true; } // The component can be cached for next run -}; - -template <class Impl, typename... Params> -class GenLoader : public ComponentLoader { -	public: -		template <class T> -		class For : public GenLoader<Impl, Params...> { -			public: -				inline Impl * create(const Params & ... p) const -				{ -					return new T(p...); -				} -		}; -		virtual Impl * create(const Params & ...) const = 0; -		inline static Impl * createNew(const std::string & n, const Params & ... p) -		{ -			return LoaderBase::getLoader<GenLoader<Impl, Params...>, NotSupported>(n)->create(p...); -		} -		inline static boost::shared_ptr<GenLoader<Impl, Params...>> getFor(const std::string & n) -		{ -			return LoaderBase::getLoader<GenLoader<Impl, Params...>, NotSupported>(n); -		} -}; -  /// Helper for loading and maintaining Project2 script components  typedef GenLoader<SourceObject, ScriptNodePtr> ElementLoader; diff --git a/project2/common/scriptStorage.h b/project2/common/scriptStorage.h index 2859a28..c8b441d 100644 --- a/project2/common/scriptStorage.h +++ b/project2/common/scriptStorage.h @@ -50,10 +50,10 @@ class StorerBase : public Storer {  		{  		}  		boost::intrusive_ptr<IntrusivePtrBase> create(ScriptNodePtr p) const { -			return creator(LoaderBase::getLoader<L, NotSupported>(p->get_name()).get(), p); +			return creator(Plugable::getLoader<L, NotSupported>(p->get_name()).get(), p);  		}  		bool cacheable(ScriptNodePtr p) const { -			return LoaderBase::getLoader<L, NotSupported>(p->get_name())->cacheable(); +			return Plugable::getLoader<L, NotSupported>(p->get_name())->cacheable();  		}  		bool save(boost::intrusive_ptr<IntrusivePtrBase> o, ScriptNodePtr name) {  			boost::intrusive_ptr<X> O = boost::dynamic_pointer_cast<X>(o); diff --git a/project2/common/scripts.h b/project2/common/scripts.h index ce2cf0e..f571d0a 100644 --- a/project2/common/scripts.h +++ b/project2/common/scripts.h @@ -8,20 +8,22 @@  #include "scriptLoader.h"  #include "scripts_fwd.h"  #include "exceptions.h" -#include "variables.h" +#include "variableType.h"  #include <vector>  SimpleMessageException(ValueNotFound);  SimpleMessage2Exception(ScriptNotFound);  SimpleMessage2Exception(DependencyNotFound); +class VariableImpl; +  class ScriptNode : public IntrusivePtrBase {  	public:  		ScriptNode(ScriptReaderPtr);  		typedef std::vector<ScriptNodePtr> ScriptNodes; -		typedef boost::function1<void, const VariableType &> LiteralCallback; -		typedef boost::function1<void, ScriptNodePtr> NodeCallback; +		typedef boost::function<void(const VariableType &)> LiteralCallback; +		typedef boost::function<void(ScriptNodePtr)> NodeCallback;  		virtual bool componentNamespace() const = 0;  		virtual std::string get_name() const = 0; diff --git a/project2/common/sourceObject.h b/project2/common/sourceObject.h index 8529100..935cead 100644 --- a/project2/common/sourceObject.h +++ b/project2/common/sourceObject.h @@ -2,6 +2,7 @@  #define SOURCEOBJECT_H  #include <boost/intrusive_ptr.hpp> +#include <boost/function.hpp>  #include <string>  #include <map>  #include "intrusivePtrBase.h" diff --git a/project2/common/transform.cpp b/project2/common/transform.cpp index 46ca42e..7e8504c 100644 --- a/project2/common/transform.cpp +++ b/project2/common/transform.cpp @@ -13,7 +13,7 @@ class TransformTargetStorer : public Storer {  		}  		boost::intrusive_ptr<IntrusivePtrBase> create(ScriptNodePtr p) const  		{ -			return LoaderBase::getLoader<TransformTargetLoader, NotSupported>(p->get_name())->create(p, Scripted); +			return Plugable::getLoader<TransformTargetLoader, NotSupported>(p->get_name())->create(p, Scripted);  		}  		bool save(boost::intrusive_ptr<IntrusivePtrBase> o, ScriptNodePtr s)  		{ @@ -46,7 +46,7 @@ typedef std::map<std::string, boost::shared_ptr<TransformLoader> > TransformLoad  void  TransformSource::addTarget(TransformChainLinkPtr tcl, ScriptNodePtr e)  { -	BOOST_FOREACH(const TransformLoaderMap::value_type & tl, *LoaderBase::objLoaders<TransformLoader>()) { +	BOOST_FOREACH(const TransformLoaderMap::value_type & tl, *Plugable::objLoaders<TransformLoader>()) {  		TransformPtr t = tl.second->create();  		if (t->canTransform(this, tcl.get())) {  			if (e) { diff --git a/project2/common/variables.h b/project2/common/variables.h index dbb4c34..948f2d2 100644 --- a/project2/common/variables.h +++ b/project2/common/variables.h @@ -5,7 +5,8 @@  #include <boost/optional.hpp>  #include <stdint.h>  #include "intrusivePtrBase.h" -#include "scriptLoader.h" +#include "genLoader.h" +#include "scripts.h"  #include "variableType.h"  #include <boost/shared_ptr.hpp> diff --git a/project2/compression/decompressStream.cpp b/project2/compression/decompressStream.cpp index eb32833..92ba035 100644 --- a/project2/compression/decompressStream.cpp +++ b/project2/compression/decompressStream.cpp @@ -1,8 +1,8 @@  #include "stream.h" -#include "scriptLoader.h" +#include "componentLoader.h"  #include "decompressor.h"  #include "scripts.h" -#include "scopeObject.h" +#include "variables.h"  #include "scriptStorage.h"  class DecompressStream : public Stream { diff --git a/project2/console/consoleEnvironment.cpp b/project2/console/consoleEnvironment.cpp index 2cb64bd..ca93d49 100644 --- a/project2/console/consoleEnvironment.cpp +++ b/project2/console/consoleEnvironment.cpp @@ -25,7 +25,7 @@ class ShowHelpTrigger : public Options::Target {  		}  		void consume(const Glib::ustring &, const VariableType &) const {  			fprintf(stdout, "Help\n"); -			LoaderBase::onAll<Options>(boost::bind(&ShowHelpTrigger::outputOptions, this, _1)); +			Plugable::onAll<Options>(boost::bind(&ShowHelpTrigger::outputOptions, this, _1));  			exit(1);  		}  	private: diff --git a/project2/console/p2consoleMain.cpp b/project2/console/p2consoleMain.cpp index a7dee1a..aef61fd 100644 --- a/project2/console/p2consoleMain.cpp +++ b/project2/console/p2consoleMain.cpp @@ -10,10 +10,10 @@ int  main(int argc, char ** argv)  {  	ConsoleEnvironment env(argc, argv); -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));  	env.init();  	BOOST_FOREACH(const ConsoleEnvironment::ToDo & todo, env.todoList()) { -		LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onBefore, _1)); +		Plugable::onAllComponents(boost::bind(&ComponentLoader::onBefore, _1));  		Logger()->messagebf(LOG_DEBUG, "%s: Beginning script '%s/%s'", __FUNCTION__, todo.get<0>(), todo.get<1>());  		boost::intrusive_ptr<ConsoleApplicationEngine> app(new ConsoleApplicationEngine(&env, env.resolveScript(todo.get<0>(), todo.get<1>(), false))); @@ -21,9 +21,9 @@ main(int argc, char ** argv)  		app->process();  		Logger()->messagef(LOG_DEBUG, "%s: Complete", __FUNCTION__); -		LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1)); +		Plugable::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1));  	} -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1)); -	LoaderBase::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1)); +	Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));  } diff --git a/project2/files/fsRows.cpp b/project2/files/fsRows.cpp index 9f8b11a..87e8c97 100644 --- a/project2/files/fsRows.cpp +++ b/project2/files/fsRows.cpp @@ -80,7 +80,7 @@ FsRows::execute(const Glib::ustring &, const RowProcessor * rp) const  		for (SpecSpec::const_iterator sf = s.begin(); sf != s.end(); ) {  			const Glib::ustring & name = (*sf++);  			if (name[0] == '-') { -				ss.specs.insert(LoaderBase::getLoader<SpecBaseLoader, NotSupported>(name.substr(1))->createWith(*sf++)); +				ss.specs.insert(Plugable::getLoader<SpecBaseLoader, NotSupported>(name.substr(1))->createWith(*sf++));  			}  			else {  				throw NotSupported(name); diff --git a/project2/files/writeStream.cpp b/project2/files/writeStream.cpp index 921804f..6e49e10 100644 --- a/project2/files/writeStream.cpp +++ b/project2/files/writeStream.cpp @@ -1,6 +1,7 @@  #include "scriptLoader.h"  #include "task.h"  #include "stream.h" +#include "variables.h"  #include <fstream>  SimpleMessageException(OpenTargetFile); diff --git a/project2/sql/rdbmsDataSource.cpp b/project2/sql/rdbmsDataSource.cpp index f13fbc6..19420db 100644 --- a/project2/sql/rdbmsDataSource.cpp +++ b/project2/sql/rdbmsDataSource.cpp @@ -195,7 +195,7 @@ RdbmsDataSource::RdbmsConnection::isExpired() const  RdbmsDataSource::ConnectionInfo::ConnectionInfo(ScriptNodePtr node) :  	dsn(node->value("dsn").as<std::string>()), -	typeId(LoaderBase::getLoader<ConnectionLoader, UnknownConnectionProvider>(node->value("provider"))) +	typeId(Plugable::getLoader<ConnectionLoader, UnknownConnectionProvider>(node->value("provider")))  {  } diff --git a/project2/xml/sessionXml.h b/project2/xml/sessionXml.h index e79e507..4288d9e 100644 --- a/project2/xml/sessionXml.h +++ b/project2/xml/sessionXml.h @@ -2,6 +2,7 @@  #define SESSIONXML_H  #include "sessionContainer.h" +#include "options.h"  #include <boost/filesystem/path.hpp>  class SessionContainerXml : public SessionContainer { diff --git a/project2/xml/xmlPresenter.h b/project2/xml/xmlPresenter.h index fd586a5..0180342 100644 --- a/project2/xml/xmlPresenter.h +++ b/project2/xml/xmlPresenter.h @@ -3,6 +3,8 @@  #include "presenter.h"  #include "transform.h" +#include "options.h" +#include "variables.h"  #include <libxml/tree.h>  namespace xmlpp { diff --git a/project2/xml/xmlScriptParser.cpp b/project2/xml/xmlScriptParser.cpp index 35fc509..7563d20 100644 --- a/project2/xml/xmlScriptParser.cpp +++ b/project2/xml/xmlScriptParser.cpp @@ -189,7 +189,7 @@ XmlScriptNode::variable(const Glib::ustring & n) const  	if (cs.size() == 1) {  		if (const xmlpp::Element * c = dynamic_cast<const xmlpp::Element *>(cs.front())) {  			if (const xmlpp::Attribute * source = c->get_attribute("source")) { -				return LoaderBase::getLoader<VariableLoader, UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(c, script)); +				return Plugable::getLoader<VariableLoader, UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(c, script));  			}  			else {  				return new VariableLiteral(new XmlScriptNode(c, script)); @@ -203,10 +203,10 @@ VariableImpl *  XmlScriptNode::variable(const boost::optional<Glib::ustring> & defaultSource) const  {  	if (const xmlpp::Attribute * source = element->get_attribute("source")) { -		return LoaderBase::getLoader<VariableLoader, UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(element, script)); +		return Plugable::getLoader<VariableLoader, UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(element, script));  	}  	else if (defaultSource) { -		return LoaderBase::getLoader<VariableLoader, UnknownVariableSource>(defaultSource.get())->create(new XmlScriptNode(element, script)); +		return Plugable::getLoader<VariableLoader, UnknownVariableSource>(defaultSource.get())->create(new XmlScriptNode(element, script));  	}  	else {  		return new VariableLiteral(new XmlScriptNode(element, script)); @@ -225,7 +225,7 @@ XmlScriptNode::applyValue(const Glib::ustring & n, VariableType & val) const  		if (const xmlpp::Element * c = dynamic_cast<const xmlpp::Element *>(cs.front())) {  			boost::intrusive_ptr<VariableImpl> v;  			if (const xmlpp::Attribute * source = c->get_attribute("source")) { -				v = LoaderBase::getLoader<VariableLoader, UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(c, script)); +				v = Plugable::getLoader<VariableLoader, UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(c, script));  			}  			else {  				v = new VariableLiteral(new XmlScriptNode(c, script));  | 
