From 5f333817c2542544aa7609badef8d65f2ab73940 Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 21 Jun 2013 00:07:15 +0000 Subject: Split the plugable stuff into its own files/classes --- project2/cgi/cgiCommon.cpp | 2 +- project2/cgi/p2webCgi.cpp | 8 +- project2/cgi/p2webFCgi.cpp | 8 +- project2/cgi/testCgi.cpp | 2 +- project2/common/aggregate.h | 1 + project2/common/componentLoader.cpp | 37 +++++++++ project2/common/componentLoader.h | 18 ++++ project2/common/environment.cpp | 12 +-- project2/common/genLoader.h | 30 +++++++ project2/common/library.cpp | 1 + project2/common/logger.h | 2 +- project2/common/options.h | 4 +- project2/common/pch.hpp | 1 + project2/common/plugable.h | 110 ++++++++++++++++++++++++ project2/common/scriptLoader.cpp | 40 --------- project2/common/scriptLoader.h | 133 +----------------------------- project2/common/scriptStorage.h | 4 +- project2/common/scripts.h | 8 +- project2/common/sourceObject.h | 1 + project2/common/transform.cpp | 4 +- project2/common/variables.h | 3 +- project2/compression/decompressStream.cpp | 4 +- project2/console/consoleEnvironment.cpp | 2 +- project2/console/p2consoleMain.cpp | 10 +-- project2/files/fsRows.cpp | 2 +- project2/files/writeStream.cpp | 1 + project2/sql/rdbmsDataSource.cpp | 2 +- project2/xml/sessionXml.h | 1 + project2/xml/xmlPresenter.h | 2 + project2/xml/xmlScriptParser.cpp | 8 +- 30 files changed, 249 insertions(+), 212 deletions(-) create mode 100644 project2/common/componentLoader.cpp create mode 100644 project2/common/componentLoader.h create mode 100644 project2/common/genLoader.h create mode 100644 project2/common/plugable.h 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(boost::bind(&Options::consume, _1, n, p, v)); + Plugable::onAll(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 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 > ConfigParsersMap; - BOOST_FOREACH(const ConfigParsersMap::value_type & cp, *LoaderBase::objLoaders()) { + BOOST_FOREACH(const ConfigParsersMap::value_type & cp, *Plugable::objLoaders()) { configs.push_back(cp.second->create()); } } @@ -50,11 +50,11 @@ typedef std::vector AllOptions; class DefaultConfigConsumer : public ConfigConsumer { public: void operator()(const Glib::ustring & n, const Glib::ustring & p, const Glib::ustring & v) const { - LoaderBase::onAll(boost::bind(&Options::consume, _1, n, p, v)); + Plugable::onAll(boost::bind(&Options::consume, _1, n, p, v)); } const Options::Option * get(const Glib::ustring & n) const { const Options::Option * rtn = NULL; - LoaderBase::onAll([n,&rtn](const Options * os) { + Plugable::onAll([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(boost::bind(&Options::reset, _1)); + Plugable::onAll(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()) { + BOOST_FOREACH(const ReaderLoaders::value_type & rl, *Plugable::objLoaders()) { 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 GenLoader : public ComponentLoader { + public: + template + class For : public GenLoader { + 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, NotSupported>(n)->create(p...); + } + inline static boost::shared_ptr> getFor(const std::string & n) + { + return Plugable::getLoader, 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 #include #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(#Type, o); } \ + Plugable::newLoader(#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(#Type); } + static void kill_options_##Type() { Plugable::removeLoader(#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 #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 +#include +#include +#include +#include +#include "exceptions.h" + +class Plugable { + public: + template + class ComponentType { + public: + static std::set> * & components() + { + static std::set> * _comp = NULL; + if (!_comp) { + _comp = new std::set>(); + } + return _comp; + } + }; + + static inline void onAllComponents(const boost::function & func) + { + onAll(func); + } + + template + static void onAll(const boost::function & func) { + BOOST_FOREACH(const auto & l, *ComponentType::components()) { + try { + func(l.get()); + } + catch (...) { + } + } + } + + template + static std::map > * & objLoaders() + { + static std::map > * _objLoaders = NULL; + if (!_objLoaders) { + _objLoaders = new std::map >(); + } + return _objLoaders; + } + + template + static void newLoader(const std::string & n, T * l) + { + boost::shared_ptr p = boost::shared_ptr(l); + objLoaders()->insert(std::pair >(n, p)); + ComponentType::components()->insert(boost::shared_ptr(p)); + } + + template + static void removeLoader(const std::string & n) + { + std::map > * & o = objLoaders(); + std::set > * & c = ComponentType::components(); + typename std::map >::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 + static boost::shared_ptr getLoader(const std::string & n) + { + typename std::map >::const_iterator i = objLoaders()->find(n); + if (i != objLoaders()->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(N, new T()); } \ + static void kill_loader_##I() __attribute__ ((destructor(201))); \ + static void kill_loader_##I() { Plugable::removeLoader(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, 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, 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 & func) -{ - onAll(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 #include #include -#include -#include -#include #include "intrusivePtrBase.h" #include "sourceObject.h" +#include "genLoader.h" #include "scripts_fwd.h" -#include "exceptions.h" #include #include #include @@ -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 target); void addLoadTargetSub(ScriptNodePtr src, const Glib::ustring & name, bool required, boost::intrusive_ptr target); void discardLoadTargets(); - static void onAllComponents(const boost::function1 &); - template - static void onAll(const boost::function & func) { - BOOST_FOREACH(const auto & l, *ComponentType::components()) { - try { - func(l.get()); - } - catch (...) { - } - } - } - - template - class ComponentType { - public: - static std::set> * & components() - { - static std::set> * _comp = NULL; - if (!_comp) { - _comp = new std::set>(); - } - return _comp; - } - }; - - template - static std::map > * & objLoaders() - { - static std::map > * _objLoaders = NULL; - if (!_objLoaders) { - _objLoaders = new std::map >(); - } - return _objLoaders; - } - - template - static void newLoader(const std::string & n, T * l) - { - boost::shared_ptr p = boost::shared_ptr(l); - objLoaders()->insert(std::pair >(n, p)); - ComponentType::components()->insert(boost::shared_ptr(p)); - } - - template - static void removeLoader(const std::string & n) - { - std::map > * & o = objLoaders(); - std::set > * & c = ComponentType::components(); - typename std::map >::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 - static boost::shared_ptr getLoader(const std::string & n) - { - typename std::map >::const_iterator i = objLoaders()->find(n); - if (i != objLoaders()->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(N, new T()); } \ - static void kill_loader_##I() __attribute__ ((destructor(201))); \ - static void kill_loader_##I() { LoaderBase::removeLoader(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, 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, 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 GenLoader : public ComponentLoader { - public: - template - class For : public GenLoader { - 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, NotSupported>(n)->create(p...); - } - inline static boost::shared_ptr> getFor(const std::string & n) - { - return LoaderBase::getLoader, NotSupported>(n); - } -}; - /// Helper for loading and maintaining Project2 script components typedef GenLoader 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 create(ScriptNodePtr p) const { - return creator(LoaderBase::getLoader(p->get_name()).get(), p); + return creator(Plugable::getLoader(p->get_name()).get(), p); } bool cacheable(ScriptNodePtr p) const { - return LoaderBase::getLoader(p->get_name())->cacheable(); + return Plugable::getLoader(p->get_name())->cacheable(); } bool save(boost::intrusive_ptr o, ScriptNodePtr name) { boost::intrusive_ptr O = boost::dynamic_pointer_cast(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 SimpleMessageException(ValueNotFound); SimpleMessage2Exception(ScriptNotFound); SimpleMessage2Exception(DependencyNotFound); +class VariableImpl; + class ScriptNode : public IntrusivePtrBase { public: ScriptNode(ScriptReaderPtr); typedef std::vector ScriptNodes; - typedef boost::function1 LiteralCallback; - typedef boost::function1 NodeCallback; + typedef boost::function LiteralCallback; + typedef boost::function 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 +#include #include #include #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 create(ScriptNodePtr p) const { - return LoaderBase::getLoader(p->get_name())->create(p, Scripted); + return Plugable::getLoader(p->get_name())->create(p, Scripted); } bool save(boost::intrusive_ptr o, ScriptNodePtr s) { @@ -46,7 +46,7 @@ typedef std::map > TransformLoad void TransformSource::addTarget(TransformChainLinkPtr tcl, ScriptNodePtr e) { - BOOST_FOREACH(const TransformLoaderMap::value_type & tl, *LoaderBase::objLoaders()) { + BOOST_FOREACH(const TransformLoaderMap::value_type & tl, *Plugable::objLoaders()) { 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 #include #include "intrusivePtrBase.h" -#include "scriptLoader.h" +#include "genLoader.h" +#include "scripts.h" #include "variableType.h" #include 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(boost::bind(&ShowHelpTrigger::outputOptions, this, _1)); + Plugable::onAll(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 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(name.substr(1))->createWith(*sf++)); + ss.specs.insert(Plugable::getLoader(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 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()), - typeId(LoaderBase::getLoader(node->value("provider"))) + typeId(Plugable::getLoader(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 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 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(cs.front())) { if (const xmlpp::Attribute * source = c->get_attribute("source")) { - return LoaderBase::getLoader(source->get_value())->create(new XmlScriptNode(c, script)); + return Plugable::getLoader(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 & defaultSource) const { if (const xmlpp::Attribute * source = element->get_attribute("source")) { - return LoaderBase::getLoader(source->get_value())->create(new XmlScriptNode(element, script)); + return Plugable::getLoader(source->get_value())->create(new XmlScriptNode(element, script)); } else if (defaultSource) { - return LoaderBase::getLoader(defaultSource.get())->create(new XmlScriptNode(element, script)); + return Plugable::getLoader(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(cs.front())) { boost::intrusive_ptr v; if (const xmlpp::Attribute * source = c->get_attribute("source")) { - v = LoaderBase::getLoader(source->get_value())->create(new XmlScriptNode(c, script)); + v = Plugable::getLoader(source->get_value())->create(new XmlScriptNode(c, script)); } else { v = new VariableLiteral(new XmlScriptNode(c, script)); -- cgit v1.2.3