From c57cbe5b0b07653eb472925a644e3ce4f4ac14f0 Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 15 Dec 2011 14:34:07 +0000 Subject: Remove straggling references to XML and configuration from recent changes --- project2/cgi/cgiAppEngine.cpp | 10 +- project2/cgi/cgiAppEngine.h | 5 - project2/cgi/cgiCommon.cpp | 1 - project2/cgi/cgiOutputOptions.h | 4 - project2/cgi/cgiStageDefaultError.cpp | 4 +- project2/cgi/cgiStageDefaultNotFound.cpp | 2 +- project2/cgi/cgiStageRequest.cpp | 2 +- project2/cgi/p2webCgi.cpp | 2 +- project2/cgi/p2webFCgi.cpp | 2 +- project2/cgi/pch.hpp | 2 +- project2/common/Jamfile.jam | 3 +- project2/common/appEngine.cpp | 2 +- project2/common/checkHost.h | 2 +- project2/common/commonObjects.cpp | 2 +- project2/common/commonObjects.h | 2 +- project2/common/environment.cpp | 8 +- project2/common/environment.h | 4 +- project2/common/fileStrmVarWriter.cpp | 2 +- project2/common/functions/dates.cpp | 4 +- project2/common/functions/strings.cpp | 4 +- project2/common/if.cpp | 2 +- project2/common/iterate.cpp | 2 +- project2/common/iterate.h | 2 +- project2/common/library.cpp | 2 +- project2/common/library.h | 2 +- project2/common/noOutputExecute.h | 2 +- project2/common/optionsSource.h | 2 +- project2/common/paramChecker.cpp | 2 +- project2/common/pch.hpp | 4 +- project2/common/presenter.h | 2 +- project2/common/rowProcessor.h | 2 +- project2/common/rowView.cpp | 2 +- project2/common/scriptLoader.cpp | 155 ++++++++++++++++++++++++++++ project2/common/scriptLoader.h | 141 +++++++++++++++++++++++++ project2/common/scriptStorage.h | 147 ++++++++++++++++++++++++++ project2/common/scripts.h | 2 +- project2/common/sessionClearTask.cpp | 2 +- project2/common/sessionClearTask.h | 2 +- project2/common/sessionSetTask.cpp | 2 +- project2/common/sessionSetTask.h | 2 +- project2/common/structExceptHandling.cpp | 4 +- project2/common/taskHost.cpp | 2 +- project2/common/taskHost.h | 2 +- project2/common/transform.h | 2 +- project2/common/validDateCheck.cpp | 2 +- project2/common/variables-modconfig.cpp | 4 +- project2/common/variables-modlocalparam.cpp | 4 +- project2/common/variables-modlookup.cpp | 4 +- project2/common/variables-modparam.cpp | 4 +- project2/common/variables-modsession.cpp | 4 +- project2/common/variables-moduri.cpp | 4 +- project2/common/variables.cpp | 2 +- project2/common/variables.h | 2 +- project2/common/view.h | 2 +- project2/common/viewHost.h | 2 +- project2/common/xmlObjectLoader.cpp | 155 ---------------------------- project2/common/xmlObjectLoader.h | 141 ------------------------- project2/common/xmlStorage.h | 147 -------------------------- project2/console/consoleAppEngine.cpp | 8 +- project2/console/consoleAppEngine.h | 2 - project2/console/consoleEnvironment.cpp | 2 +- project2/console/p2consoleMain.cpp | 3 +- project2/console/pch.hpp | 2 +- project2/files/fileRows.cpp | 2 +- project2/files/fsRows.cpp | 2 +- project2/json/couchSession.cpp | 2 +- project2/mail/sendmailTask.cpp | 2 +- project2/mail/sendmailTask.h | 1 - project2/processes/procRows.cpp | 2 +- project2/regex/regexCheck.cpp | 2 +- project2/regex/regexRows.cpp | 2 +- project2/sql/connectionLoader.h | 2 +- project2/sql/pch.hpp | 2 +- project2/sql/rdbmsDataSource.h | 2 +- project2/sql/sqlCache.cpp | 2 +- project2/sql/sqlCheck.cpp | 2 +- project2/sql/sqlMergeTask.cpp | 2 +- project2/sql/sqlRows.cpp | 2 +- project2/sql/sqlTask.cpp | 2 +- project2/url/urlRows.cpp | 2 +- project2/xml/rawView.cpp | 2 +- project2/xml/xmlCache.cpp | 2 +- project2/xml/xmlDocumentCache.cpp | 2 +- project2/xml/xmlDocumentPrefetch.cpp | 2 +- project2/xml/xmlPresenter.cpp | 6 +- project2/xml/xmlRows.cpp | 2 +- project2/xml/xmlScriptParser.cpp | 2 +- project2/xml/xmlScriptParser.h | 2 +- project2/xml/xpathRows.cpp | 2 +- 89 files changed, 542 insertions(+), 563 deletions(-) create mode 100644 project2/common/scriptLoader.cpp create mode 100644 project2/common/scriptLoader.h create mode 100644 project2/common/scriptStorage.h delete mode 100644 project2/common/xmlObjectLoader.cpp delete mode 100644 project2/common/xmlObjectLoader.h delete mode 100644 project2/common/xmlStorage.h diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp index 4d91069..f94597c 100644 --- a/project2/cgi/cgiAppEngine.cpp +++ b/project2/cgi/cgiAppEngine.cpp @@ -119,7 +119,7 @@ CgiApplicationEngine::addEnvData(const MultiRowSetPresenter * p, OutputOptionsPt { if (!o || o->Environment()) { // Environment set up by web server - p->addNewRowSet("environment", env()->xmlPrefix); + p->addNewRowSet("environment", env()->scriptNamespacePrefix); // Server stuff addEnvToPresenter(p, "servername", &cgicc::CgiEnvironment::getServerName); addEnvToPresenter(p, "serversoftware", &cgicc::CgiEnvironment::getServerSoftware); @@ -134,7 +134,7 @@ CgiApplicationEngine::addEnvData(const MultiRowSetPresenter * p, OutputOptionsPt if (!o || o->URL()) { // URL elements - p->addNewRowSet("uriElems", env()->xmlPrefix); + p->addNewRowSet("uriElems", env()->scriptNamespacePrefix); p->addAttribute("full", _env->getRedirectURL()); BOOST_FOREACH(std::string s, _env->elems) { p->addNewRow("uriElem"); @@ -146,7 +146,7 @@ CgiApplicationEngine::addEnvData(const MultiRowSetPresenter * p, OutputOptionsPt if (!o || o->Parameters()) { // Parameters - p->addNewRowSet("params", env()->xmlPrefix); + p->addNewRowSet("params", env()->scriptNamespacePrefix); BOOST_FOREACH(cgicc::FormEntry fe, _env->cgi->getElements()) { p->addNewRow("param"); p->addAttribute("name", fe.getName()); @@ -174,7 +174,7 @@ CgiApplicationEngine::addAppData(const MultiRowSetPresenter * p, OutputOptionsPt } if (!o || o->Session()) { // Sessions variables - p->addNewRowSet("session", env()->xmlPrefix); + p->addNewRowSet("session", env()->scriptNamespacePrefix); p->addAttribute("id", cursession->ID.str()); cursession->ForeachValue(boost::bind(&CgiApplicationEngine::addVarToPresenter, this, p, _1, _2)); p->finishRowSet(); @@ -182,7 +182,7 @@ CgiApplicationEngine::addAppData(const MultiRowSetPresenter * p, OutputOptionsPt if (!o || o->Timing()) { // Timing info - p->addNewRowSet("timing", env()->xmlPrefix); + p->addNewRowSet("timing", env()->scriptNamespacePrefix); p->addAttribute("start", startTime); if (!endTime.is_not_a_date_time()) { p->addAttribute("end", endTime); diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h index f4b3896..d4295de 100644 --- a/project2/cgi/cgiAppEngine.h +++ b/project2/cgi/cgiAppEngine.h @@ -21,13 +21,9 @@ namespace cgicc { class HTTPHeader; class CgiEnvironment; } -namespace xmlpp { - class Document; -} class CgiApplicationEngine : public ApplicationEngine, public TransformChainLink { public: - typedef boost::shared_ptr XmlDocPtr; typedef boost::shared_ptr HttpHeaderPtr; CgiApplicationEngine(const CgiEnvironment *, std::ostream &); @@ -43,7 +39,6 @@ class CgiApplicationEngine : public ApplicationEngine, public TransformChainLink private: mutable boost::posix_time::ptime startTime; mutable boost::posix_time::ptime endTime; - void loadEngineSection(const xmlpp::Element *) const; SessionContainerPtr sessionsContainer; // Helpers void addVarToPresenter(const MultiRowSetPresenter * p, const Glib::ustring & name, const VariableType &) const; diff --git a/project2/cgi/cgiCommon.cpp b/project2/cgi/cgiCommon.cpp index 3664e9f..7559ea7 100644 --- a/project2/cgi/cgiCommon.cpp +++ b/project2/cgi/cgiCommon.cpp @@ -1,7 +1,6 @@ #include #include "cgiCommon.h" #include "logger.h" -#include #include #include #include diff --git a/project2/cgi/cgiOutputOptions.h b/project2/cgi/cgiOutputOptions.h index 07b7598..4a4f1c8 100644 --- a/project2/cgi/cgiOutputOptions.h +++ b/project2/cgi/cgiOutputOptions.h @@ -5,10 +5,6 @@ #include "options.h" #include "variables.h" -namespace xmlpp { - class Element; -} - class OutputOptions : public IntrusivePtrBase { public: OutputOptions(ScriptNodePtr); diff --git a/project2/cgi/cgiStageDefaultError.cpp b/project2/cgi/cgiStageDefaultError.cpp index 82d7b2e..ad27d2d 100644 --- a/project2/cgi/cgiStageDefaultError.cpp +++ b/project2/cgi/cgiStageDefaultError.cpp @@ -29,8 +29,8 @@ CgiApplicationEngine::DefaultErrorStage::getHeader() const CgiApplicationEngine::NextStage CgiApplicationEngine::DefaultErrorStage::run() { - pres->addNamedValue("error-type", e->xmlPrefix, buf); - pres->addNamedValue("error-what", e->xmlPrefix, what.c_str()); + pres->addNamedValue("error-type", e->scriptNamespacePrefix, buf); + pres->addNamedValue("error-what", e->scriptNamespacePrefix, what.c_str()); return NextStage(NULL, this, pres.get(), pres.get()); } diff --git a/project2/cgi/cgiStageDefaultNotFound.cpp b/project2/cgi/cgiStageDefaultNotFound.cpp index d05c92b..be32658 100644 --- a/project2/cgi/cgiStageDefaultNotFound.cpp +++ b/project2/cgi/cgiStageDefaultNotFound.cpp @@ -23,7 +23,7 @@ CgiApplicationEngine::DefaultNotFoundStage::getHeader() const CgiApplicationEngine::NextStage CgiApplicationEngine::DefaultNotFoundStage::run() { - pres->addNamedValue("missing-resource", e->xmlPrefix, nf.what()); + pres->addNamedValue("missing-resource", e->scriptNamespacePrefix, nf.what()); return NextStage(NULL, this, pres.get(), pres.get()); } diff --git a/project2/cgi/cgiStageRequest.cpp b/project2/cgi/cgiStageRequest.cpp index 99ca956..ac8516b 100644 --- a/project2/cgi/cgiStageRequest.cpp +++ b/project2/cgi/cgiStageRequest.cpp @@ -2,7 +2,7 @@ #include "cgiAppEngine.h" #include "cgiEnvironment.h" #include "cgiHttpHeader.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include CgiApplicationEngine::RequestStage::RequestStage(const CgiEnvironment * e, ScriptReaderPtr s) : diff --git a/project2/cgi/p2webCgi.cpp b/project2/cgi/p2webCgi.cpp index be48f4f..0248df6 100644 --- a/project2/cgi/p2webCgi.cpp +++ b/project2/cgi/p2webCgi.cpp @@ -1,5 +1,5 @@ #include "cgiCommon.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include int diff --git a/project2/cgi/p2webFCgi.cpp b/project2/cgi/p2webFCgi.cpp index 72dfa44..3b833ed 100644 --- a/project2/cgi/p2webFCgi.cpp +++ b/project2/cgi/p2webFCgi.cpp @@ -1,6 +1,6 @@ #include "cgiCommon.h" #include "FCgiIO.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include time_t lastPeriodic = 0; diff --git a/project2/cgi/pch.hpp b/project2/cgi/pch.hpp index ff0b175..df744a4 100644 --- a/project2/cgi/pch.hpp +++ b/project2/cgi/pch.hpp @@ -10,7 +10,7 @@ #include "exceptions.h" #include "iterate.h" #include "logger.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include "options.h" diff --git a/project2/common/Jamfile.jam b/project2/common/Jamfile.jam index 5c6cfc7..7e00700 100644 --- a/project2/common/Jamfile.jam +++ b/project2/common/Jamfile.jam @@ -13,8 +13,7 @@ cpp-pch pch : pch.hpp : ; lib p2common : pch - [ glob *.cpp ] - [ glob functions/*.cpp ] + [ glob-tree *.cpp ] ../../libmisc/buffer.cpp ../../libmisc/misc.cpp : diff --git a/project2/common/appEngine.cpp b/project2/common/appEngine.cpp index db44a94..b5db2cf 100644 --- a/project2/common/appEngine.cpp +++ b/project2/common/appEngine.cpp @@ -33,7 +33,7 @@ void ApplicationEngine::addCoreAppData(const MultiRowSetPresenter * p) const { // Message log - p->addNewRowSet("messages", env()->xmlPrefix); + p->addNewRowSet("messages", env()->scriptNamespacePrefix); BOOST_FOREACH(const Messages::value_type & m, appMessages) { p->addNewRow("message"); p->addAttribute("group", m->group); diff --git a/project2/common/checkHost.h b/project2/common/checkHost.h index 9a87aea..cc32ad4 100644 --- a/project2/common/checkHost.h +++ b/project2/common/checkHost.h @@ -2,7 +2,7 @@ #define CHECKHOST_H #include "paramChecker.h" -#include "xmlStorage.h" +#include "scriptStorage.h" #include #include #include "commonObjects.h" diff --git a/project2/common/commonObjects.cpp b/project2/common/commonObjects.cpp index 5bfe6bc..041b4ef 100644 --- a/project2/common/commonObjects.cpp +++ b/project2/common/commonObjects.cpp @@ -2,7 +2,7 @@ #include "commonObjects.h" #include "safeMapFind.h" #include "appEngine.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" CommonObjects::CommonObjects() { diff --git a/project2/common/commonObjects.h b/project2/common/commonObjects.h index 2e00442..6c587c4 100644 --- a/project2/common/commonObjects.h +++ b/project2/common/commonObjects.h @@ -3,7 +3,7 @@ #include "dataSource.h" #include "rowSet.h" -#include "xmlStorage.h" +#include "scriptStorage.h" class CommonObjects : public virtual IntrusivePtrBase { public: diff --git a/project2/common/environment.cpp b/project2/common/environment.cpp index e99be54..891f1d9 100644 --- a/project2/common/environment.cpp +++ b/project2/common/environment.cpp @@ -2,7 +2,7 @@ #include "environment.h" #include "optionsSource.h" #include "loggers.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include @@ -24,12 +24,12 @@ Environment::Environment() : "Log to console with level (default WARNING)")("c") ("common.datasourceRoot", Options::value(&datasourceRoot, "datasources"), "The folder in which to find datasource definitions") - ("common.namespace", Options::value(&xmlNamespace, "http://project2.randomdan.homeip.net"), + ("common.namespace", Options::value(&scriptNamespace, "http://project2.randomdan.homeip.net"), "The namespace to use for Project2 components and responses") - ("common.namespacePrefix", Options::value(&xmlPrefix, "project2"), + ("common.namespacePrefix", Options::value(&scriptNamespacePrefix, "project2"), "The namespace prefix to use for the Project2 namespace") ("common.sessionTimeOut", Options::value(&sessionTimeOut, 3600), - "The time after which idle sessions are forgetten") + "The time after which idle sessions are forgotten") ; } diff --git a/project2/common/environment.h b/project2/common/environment.h index c2b9474..8c6ae61 100644 --- a/project2/common/environment.h +++ b/project2/common/environment.h @@ -40,8 +40,8 @@ class Environment { public: std::string datasourceRoot; - Glib::ustring xmlNamespace; - Glib::ustring xmlPrefix; + Glib::ustring scriptNamespace; + Glib::ustring scriptNamespacePrefix; time_t sessionTimeOut; }; diff --git a/project2/common/fileStrmVarWriter.cpp b/project2/common/fileStrmVarWriter.cpp index 0028af8..47d03e8 100644 --- a/project2/common/fileStrmVarWriter.cpp +++ b/project2/common/fileStrmVarWriter.cpp @@ -1,7 +1,7 @@ #include #include "fileStrmVarWriter.h" #include "rowSet.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include diff --git a/project2/common/functions/dates.cpp b/project2/common/functions/dates.cpp index 8028789..c1992f7 100644 --- a/project2/common/functions/dates.cpp +++ b/project2/common/functions/dates.cpp @@ -1,7 +1,7 @@ #include #include "../variables.h" -#include "../xmlObjectLoader.h" -#include "../xmlStorage.h" +#include "../scriptLoader.h" +#include "../scriptStorage.h" #include "../logger.h" #include #include diff --git a/project2/common/functions/strings.cpp b/project2/common/functions/strings.cpp index d2967d2..507aafc 100644 --- a/project2/common/functions/strings.cpp +++ b/project2/common/functions/strings.cpp @@ -1,7 +1,7 @@ #include #include "../variables.h" -#include "../xmlObjectLoader.h" -#include "../xmlStorage.h" +#include "../scriptLoader.h" +#include "../scriptStorage.h" /// Variable implementation to access platform configuration values class Trim : public VariableImplDyn { diff --git a/project2/common/if.cpp b/project2/common/if.cpp index 0f982ec..624feef 100644 --- a/project2/common/if.cpp +++ b/project2/common/if.cpp @@ -1,7 +1,7 @@ #include #include "if.h" #include "logger.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include diff --git a/project2/common/iterate.cpp b/project2/common/iterate.cpp index 9c7592e..037261d 100644 --- a/project2/common/iterate.cpp +++ b/project2/common/iterate.cpp @@ -3,7 +3,7 @@ #include "logger.h" #include #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "scopeObject.h" DECLARE_LOADER("iterate", Iterate); diff --git a/project2/common/iterate.h b/project2/common/iterate.h index aa0b0e8..540cec6 100644 --- a/project2/common/iterate.h +++ b/project2/common/iterate.h @@ -3,7 +3,7 @@ #include "rowProcessor.h" #include "iHaveSubTasks.h" -#include "xmlStorage.h" +#include "scriptStorage.h" class Iterate; typedef boost::intrusive_ptr IteratePtr; diff --git a/project2/common/library.cpp b/project2/common/library.cpp index 0c4fa7b..f7cc51c 100644 --- a/project2/common/library.cpp +++ b/project2/common/library.cpp @@ -1,6 +1,6 @@ #include #include -#include "xmlStorage.h" +#include "scriptStorage.h" #include "exceptions.h" #include "scripts.h" #include "library.h" diff --git a/project2/common/library.h b/project2/common/library.h index 892c075..c6d9278 100644 --- a/project2/common/library.h +++ b/project2/common/library.h @@ -1,7 +1,7 @@ #ifndef LIBRARY_LOADER_H #define LIBRARY_LOADER_H -#include "xmlObjectLoader.h" +#include "scriptLoader.h" class Library : public SourceObject { public: diff --git a/project2/common/noOutputExecute.h b/project2/common/noOutputExecute.h index fffea9c..67f6b00 100644 --- a/project2/common/noOutputExecute.h +++ b/project2/common/noOutputExecute.h @@ -2,7 +2,7 @@ #define NOOUTPUTEXECUTE_H #include "sourceObject.h" -#include "xmlStorage.h" +#include "scriptStorage.h" class NoOutputExecute; typedef boost::intrusive_ptr NoOutputExecutePtr; diff --git a/project2/common/optionsSource.h b/project2/common/optionsSource.h index 73335d8..59d404f 100644 --- a/project2/common/optionsSource.h +++ b/project2/common/optionsSource.h @@ -4,7 +4,7 @@ #include #include #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" typedef boost::function3 ConfigConsumer; diff --git a/project2/common/paramChecker.cpp b/project2/common/paramChecker.cpp index fe49fa3..3d6b046 100644 --- a/project2/common/paramChecker.cpp +++ b/project2/common/paramChecker.cpp @@ -1,6 +1,6 @@ #include #include "paramChecker.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" ParamChecker::ParamChecker(ScriptNodePtr p) : SourceObject(p), diff --git a/project2/common/pch.hpp b/project2/common/pch.hpp index 54637e0..85a7932 100644 --- a/project2/common/pch.hpp +++ b/project2/common/pch.hpp @@ -22,8 +22,8 @@ #include #include #include -#include "xmlStorage.h" -#include "xmlObjectLoader.h" +#include "scriptStorage.h" +#include "scriptLoader.h" #include "variables.h" #include "sourceObject.h" #include "scripts.h" diff --git a/project2/common/presenter.h b/project2/common/presenter.h index c0cc700..de233a3 100644 --- a/project2/common/presenter.h +++ b/project2/common/presenter.h @@ -7,7 +7,7 @@ #include #include "view.h" #include "paramChecker.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" class NameValuePairPresenter : public virtual IntrusivePtrBase { public: diff --git a/project2/common/rowProcessor.h b/project2/common/rowProcessor.h index 18beac7..cee9e41 100644 --- a/project2/common/rowProcessor.h +++ b/project2/common/rowProcessor.h @@ -6,7 +6,7 @@ #include "iHaveParameters.h" #include "rowSet.h" #include "cache.h" -#include "xmlStorage.h" +#include "scriptStorage.h" class Presenter; diff --git a/project2/common/rowView.cpp b/project2/common/rowView.cpp index 35b410d..0f25a30 100644 --- a/project2/common/rowView.cpp +++ b/project2/common/rowView.cpp @@ -2,7 +2,7 @@ #include "rowView.h" #include "presenter.h" #include "scopeObject.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "scopeObject.h" #include #include diff --git a/project2/common/scriptLoader.cpp b/project2/common/scriptLoader.cpp new file mode 100644 index 0000000..42f826e --- /dev/null +++ b/project2/common/scriptLoader.cpp @@ -0,0 +1,155 @@ +#include +#include "scriptLoader.h" +#include "scriptStorage.h" +#include "logger.h" +#include "library.h" +#include "appEngine.h" +#include +#include +#include +#include + +unsigned int LoaderBase::depth = 0; +std::set LoaderBase::loadedObjects; + +class DepthCounter { + public: + DepthCounter(unsigned int & c) : counter(c) { + counter += 1; + } + ~DepthCounter() { + counter -= 1; + } + private: + unsigned int & counter; +}; + +typedef std::map > ElementLoaderMap; +typedef std::set > ComponentLoaderSet; + +LoaderBase::LoaderBase() : + recursive(true) +{ +} + +LoaderBase::~LoaderBase() +{ +} + +void +LoaderBase::addLoadTarget(ScriptNodePtr src, boost::intrusive_ptr target) { + targets[src].push_back(target); +} + + std::set > * & +LoaderBase::componentLoaders() +{ + static std::set > * _compLoaders = NULL; + if (!_compLoaders) { + _compLoaders = new std::set >(); + } + return _compLoaders; +} + +void +LoaderBase::collectAll(ScriptNodePtr node, bool childrenOnly, const StorerPtrs & sts) const +{ + DepthCounter dc(depth); + unsigned int created = 0; + if (!childrenOnly && node->componentNamespace()) { + Glib::ustring name = node->get_name(); + unsigned int stored = 0; + created += 1; + boost::intrusive_ptr o; + BOOST_FOREACH(const StorerPtr & s, sts) { + try { + o = s->create(node); + break; + } + catch (const NotSupported &) { + } + } + if (!o) { + throw NotSupported(name); + } + BOOST_FOREACH(const StorerPtr & s, sts) { + if (s->save(o, node)) { + stored += 1; + break; + } + } + if (stored < 1) { + throw NotSupported(name); + } + } + if (created == 0 && (recursive || childrenOnly)) { + BOOST_FOREACH(ScriptNodePtr child, node->children()) { + collectAll(child, false, sts); + } + } +} + +void +LoaderBase::collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr node) +{ + (void)co; + addLoadTarget(node, Storer::into(&libraries)); + if (depth != 0 && co) { + throw std::logic_error("Cannot set CommonObjects in subloader"); + } + Targets::iterator i; + while ((i = targets.begin()) != targets.end()) { + collectAll(i->first, childrenOnly, i->second); + targets.erase(i); + } + if (co) { + BOOST_FOREACH(SourceObjectPtr o, loadedObjects) { + o->loadComplete(co); + } + loadedObjects.clear(); + } +} + +void +LoaderBase::onAllComponents(const boost::function1 & func) +{ + BOOST_FOREACH(ComponentLoaderSet::value_type l, *componentLoaders()) { + try { + func(l.get()); + } + catch (...) { + } + } +} + +void +ComponentLoader::onBegin() +{ +} + +void +ComponentLoader::onBefore() +{ +} + +void +ComponentLoader::onIdle() +{ +} + +void +ComponentLoader::onIteration() +{ +} + +void +ComponentLoader::onPeriodic() +{ +} + +const Options * +ComponentLoader::options() const +{ + return NULL; +} + diff --git a/project2/common/scriptLoader.h b/project2/common/scriptLoader.h new file mode 100644 index 0000000..d916821 --- /dev/null +++ b/project2/common/scriptLoader.h @@ -0,0 +1,141 @@ +#ifndef SCRIPTLOADER_H +#define SCRIPTLOADER_H + +#include +#include +#include +#include +#include +#include "intrusivePtrBase.h" +#include "sourceObject.h" +#include "exceptions.h" +#include +#include +#include + +enum UnsupportedHandling { ErrorOnUnsupported, WarnOnUnsupported, IgnoreUnsupported }; +class ElementLoader; +class ComponentLoader; +class CommonObjects; +class Storer; +class ScriptReader; + +class LoaderBase { + public: + typedef boost::intrusive_ptr StorerPtr; + typedef std::vector StorerPtrs; + typedef std::map Targets; + + LoaderBase(); + virtual ~LoaderBase(); + void collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr script); + + void addLoadTarget(ScriptNodePtr src, boost::intrusive_ptr target); + + static void onAllComponents(const boost::function1 &); + + static std::set > * & componentLoaders(); + + 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)); + componentLoaders()->insert(boost::shared_ptr(p)); + } + + template + static void removeLoader(const std::string & n) + { + std::map > * & o = objLoaders(); + std::set > * & c = componentLoaders(); + 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; + Targets targets; + static unsigned int depth; + template friend class ElementLoaderImpl; + static std::set loadedObjects; + + const bool recursive; + + public: + const Glib::ustring ns; +}; + +#define DECLARE_CUSTOM_COMPONENT_LOADER(N, I, T, B) \ + 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##Impl, B) +#define DECLARE_LOADER(N, T) \ + DECLARE_COMPONENT_LOADER(N, T, ElementLoader) + +/// Helper for loading and maintaining Project2 components +class Options; +class ComponentLoader { + public: + 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 const Options * options() const; // Options to be populated from the common config file/env/etc +}; +/// Helper for loading and maintaining Project2 script components +class ElementLoader : public ComponentLoader { + public: + virtual SourceObjectPtr createFrom(ScriptNodePtr) const = 0; +}; + +/// Helper for loading and maintaining Project2 script components (typed implementation) +template +class ElementLoaderImpl : public ElementLoader { + public: + SourceObjectPtr createFrom(ScriptNodePtr sn) const + { + SourceObjectPtr sop = new X(sn); + LoaderBase::loadedObjects.insert(sop); + return sop; + } +}; +#endif + diff --git a/project2/common/scriptStorage.h b/project2/common/scriptStorage.h new file mode 100644 index 0000000..d5daf95 --- /dev/null +++ b/project2/common/scriptStorage.h @@ -0,0 +1,147 @@ +#ifndef SCRIPTSTORAGE_H +#define SCRIPTSTORAGE_H + +#include "sourceObject.h" +#include "scriptLoader.h" +#include "exceptions.h" +#include "scripts.h" +#include +#include +#include +#include + +SimpleMessageException(StoreFailed); + +#define SINGLE(X) \ + boost::intrusive_ptr +#define STORAGEOF(X) \ + std::map > +#define ANONORDEREDSTORAGEOF(X) \ + std::list > +#define ANONSTORAGEOF(X) \ + std::set > + +class Storer; +typedef boost::intrusive_ptr StorerPtr; +class Storer : public virtual IntrusivePtrBase { + public: + template + static StorerPtr into(SINGLE(X) * obj); + template + static StorerPtr into(STORAGEOF(X) * map); + template + static StorerPtr into(ANONSTORAGEOF(X) * set); + template + static StorerPtr into(ANONORDEREDSTORAGEOF(X) * list); + + virtual boost::intrusive_ptr create(ScriptNodePtr) const = 0; + virtual bool save(boost::intrusive_ptr, ScriptNodePtr) = 0; +}; + +template +class StorerBase : public Storer { + public: + typedef M * Map; + boost::intrusive_ptr create(ScriptNodePtr p) const { + return LoaderBase::getLoader(p->get_name())->createFrom(p); + } + bool save(boost::intrusive_ptr o, ScriptNodePtr p) { + boost::intrusive_ptr O = boost::dynamic_pointer_cast(o); + if (O) { + if (!insert(p, O)) { + throw StoreFailed(p->get_name()); + } + } + return O; + } + virtual bool insert(ScriptNodePtr, boost::intrusive_ptr) = 0; +}; + +template +class StorerImpl : public StorerBase { + public: + StorerImpl(M * m); + bool insert(ScriptNodePtr, boost::intrusive_ptr O); +}; +template +class StorerImpl : public StorerBase { + public: + typedef SINGLE(X) Obj; + StorerImpl(SINGLE(X) * o) : obj(o) + { + } + bool insert(ScriptNodePtr, boost::intrusive_ptr O) + { + *obj = O; + return true; + } + Obj * obj; +}; +template +class StorerImpl : public StorerBase { + public: + typedef STORAGEOF(X) Map; + StorerImpl(STORAGEOF(X) * m) : map(m) + { + } + bool insert(ScriptNodePtr, boost::intrusive_ptr O) + { + return map->insert(typename Map::value_type(O->name, O)).second; + } + Map * map; +}; +template +class StorerImpl : public StorerBase { + public: + typedef ANONSTORAGEOF(X) Map; + StorerImpl(ANONSTORAGEOF(X) * m) : map(m) + { + } + bool insert(ScriptNodePtr, boost::intrusive_ptr O) + { + map->insert(O); + return true; + } + Map * map; +}; +template +class StorerImpl : public StorerBase { + public: + typedef ANONORDEREDSTORAGEOF(X) Map; + StorerImpl(ANONORDEREDSTORAGEOF(X) * m) : map(m) + { + } + bool insert(ScriptNodePtr, boost::intrusive_ptr O) + { + map->push_back(O); + return true; + } + Map * map; +}; + +template +StorerPtr +Storer::into(SINGLE(X) * obj) { + return new StorerImpl(obj); +} + +template +StorerPtr +Storer::into(STORAGEOF(X) * map) { + return new StorerImpl(map); +} + +template +StorerPtr +Storer::into(ANONSTORAGEOF(X) * set) { + return new StorerImpl(set); +} + +template +StorerPtr +Storer::into(ANONORDEREDSTORAGEOF(X) * list) { + return new StorerImpl(list); +} + +#endif + diff --git a/project2/common/scripts.h b/project2/common/scripts.h index 2db4bad..becfda2 100644 --- a/project2/common/scripts.h +++ b/project2/common/scripts.h @@ -5,7 +5,7 @@ #include #include #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "exceptions.h" #include "variables.h" #include diff --git a/project2/common/sessionClearTask.cpp b/project2/common/sessionClearTask.cpp index 9fba697..b3b1000 100644 --- a/project2/common/sessionClearTask.cpp +++ b/project2/common/sessionClearTask.cpp @@ -1,6 +1,6 @@ #include #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "sessionClearTask.h" #include "appEngine.h" #include "session.h" diff --git a/project2/common/sessionClearTask.h b/project2/common/sessionClearTask.h index 224c951..c7def60 100644 --- a/project2/common/sessionClearTask.h +++ b/project2/common/sessionClearTask.h @@ -4,7 +4,7 @@ #include #include #include "sourceObject.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "task.h" class CommonObjects; diff --git a/project2/common/sessionSetTask.cpp b/project2/common/sessionSetTask.cpp index 8cf0788..aca5b26 100644 --- a/project2/common/sessionSetTask.cpp +++ b/project2/common/sessionSetTask.cpp @@ -1,6 +1,6 @@ #include #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "sessionSetTask.h" #include "appEngine.h" #include "session.h" diff --git a/project2/common/sessionSetTask.h b/project2/common/sessionSetTask.h index c9b22e5..8e88837 100644 --- a/project2/common/sessionSetTask.h +++ b/project2/common/sessionSetTask.h @@ -4,7 +4,7 @@ #include #include #include "sourceObject.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "task.h" #include "variables.h" diff --git a/project2/common/structExceptHandling.cpp b/project2/common/structExceptHandling.cpp index bfd2f2b..3820ce8 100644 --- a/project2/common/structExceptHandling.cpp +++ b/project2/common/structExceptHandling.cpp @@ -1,7 +1,7 @@ #include #include "structExceptHandling.h" -#include "xmlObjectLoader.h" -#include "xmlStorage.h" +#include "scriptLoader.h" +#include "scriptStorage.h" #include "scripts.h" #include diff --git a/project2/common/taskHost.cpp b/project2/common/taskHost.cpp index 9ee0304..1b4e929 100644 --- a/project2/common/taskHost.cpp +++ b/project2/common/taskHost.cpp @@ -3,7 +3,7 @@ #include "noOutputExecute.h" #include "dataSource.h" #include "scopeObject.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "commonObjects.h" #include diff --git a/project2/common/taskHost.h b/project2/common/taskHost.h index 9f9a1c5..e4cc443 100644 --- a/project2/common/taskHost.h +++ b/project2/common/taskHost.h @@ -1,7 +1,7 @@ #ifndef TASKHOST_H #define TASKHOST_H -#include "xmlStorage.h" +#include "scriptStorage.h" #include "checkHost.h" #include "iHaveSubTasks.h" #include "commonObjects.h" diff --git a/project2/common/transform.h b/project2/common/transform.h index 06db2c7..42f4d4d 100644 --- a/project2/common/transform.h +++ b/project2/common/transform.h @@ -3,7 +3,7 @@ #include #include "intrusivePtrBase.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include class TransformChainLink : public virtual IntrusivePtrBase { diff --git a/project2/common/validDateCheck.cpp b/project2/common/validDateCheck.cpp index 987fa87..d83fa1f 100644 --- a/project2/common/validDateCheck.cpp +++ b/project2/common/validDateCheck.cpp @@ -1,6 +1,6 @@ #include #include "logger.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "commonObjects.h" #include "paramChecker.h" #include "variables.h" diff --git a/project2/common/variables-modconfig.cpp b/project2/common/variables-modconfig.cpp index 5a031be..0dd7feb 100644 --- a/project2/common/variables-modconfig.cpp +++ b/project2/common/variables-modconfig.cpp @@ -1,7 +1,7 @@ #include #include "variables.h" -#include "xmlObjectLoader.h" -#include "xmlStorage.h" +#include "scriptLoader.h" +#include "scriptStorage.h" #include #include "appEngine.h" diff --git a/project2/common/variables-modlocalparam.cpp b/project2/common/variables-modlocalparam.cpp index f6fd31c..38cfbba 100644 --- a/project2/common/variables-modlocalparam.cpp +++ b/project2/common/variables-modlocalparam.cpp @@ -1,8 +1,8 @@ #include #include "variables.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "logger.h" -#include "xmlStorage.h" +#include "scriptStorage.h" #include "iHaveParameters.h" /// Variable implementation to access call parameters diff --git a/project2/common/variables-modlookup.cpp b/project2/common/variables-modlookup.cpp index c5a2a2e..677b628 100644 --- a/project2/common/variables-modlookup.cpp +++ b/project2/common/variables-modlookup.cpp @@ -5,8 +5,8 @@ #include "rowProcessor.h" #include "rowSet.h" #include -#include "xmlObjectLoader.h" -#include "xmlStorage.h" +#include "scriptLoader.h" +#include "scriptStorage.h" /// Variable implementation that looks up it's value in a map of key(s)/value pairs diff --git a/project2/common/variables-modparam.cpp b/project2/common/variables-modparam.cpp index f17cae5..3019b96 100644 --- a/project2/common/variables-modparam.cpp +++ b/project2/common/variables-modparam.cpp @@ -1,7 +1,7 @@ #include #include "variables.h" -#include "xmlObjectLoader.h" -#include "xmlStorage.h" +#include "scriptLoader.h" +#include "scriptStorage.h" #include "appEngine.h" /// Variable implementation to access call parameters diff --git a/project2/common/variables-modsession.cpp b/project2/common/variables-modsession.cpp index 68d0e56..551f448 100644 --- a/project2/common/variables-modsession.cpp +++ b/project2/common/variables-modsession.cpp @@ -1,7 +1,7 @@ #include #include "variables.h" -#include "xmlObjectLoader.h" -#include "xmlStorage.h" +#include "scriptLoader.h" +#include "scriptStorage.h" #include "appEngine.h" /// Variable implementation to access session contents diff --git a/project2/common/variables-moduri.cpp b/project2/common/variables-moduri.cpp index 8096203..041141f 100644 --- a/project2/common/variables-moduri.cpp +++ b/project2/common/variables-moduri.cpp @@ -1,7 +1,7 @@ #include #include "variables.h" -#include "xmlObjectLoader.h" -#include "xmlStorage.h" +#include "scriptLoader.h" +#include "scriptStorage.h" #include "appEngine.h" /// Variable implementation to access URI path fragments diff --git a/project2/common/variables.cpp b/project2/common/variables.cpp index 8df00e2..4dc4538 100644 --- a/project2/common/variables.cpp +++ b/project2/common/variables.cpp @@ -2,7 +2,7 @@ #include "variables.h" #include "variables-modfixed.h" #include "iHaveParameters.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "exceptions.h" #include "appEngine.h" #include "session.h" diff --git a/project2/common/variables.h b/project2/common/variables.h index 05b7855..a52e2b1 100644 --- a/project2/common/variables.h +++ b/project2/common/variables.h @@ -7,7 +7,7 @@ #include #include #include "intrusivePtrBase.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include diff --git a/project2/common/view.h b/project2/common/view.h index 23c292f..5d13280 100644 --- a/project2/common/view.h +++ b/project2/common/view.h @@ -2,7 +2,7 @@ #define VIEW_H #include "sourceObject.h" -#include "xmlStorage.h" +#include "scriptStorage.h" class MultiRowSetPresenter; diff --git a/project2/common/viewHost.h b/project2/common/viewHost.h index 589e2b1..39849ec 100644 --- a/project2/common/viewHost.h +++ b/project2/common/viewHost.h @@ -2,7 +2,7 @@ #define VIEWHOST_H #include "paramChecker.h" -#include "xmlStorage.h" +#include "scriptStorage.h" #include "presenter.h" #include "checkHost.h" #include diff --git a/project2/common/xmlObjectLoader.cpp b/project2/common/xmlObjectLoader.cpp deleted file mode 100644 index f25ba6b..0000000 --- a/project2/common/xmlObjectLoader.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include -#include "xmlObjectLoader.h" -#include "xmlStorage.h" -#include "logger.h" -#include "library.h" -#include "appEngine.h" -#include -#include -#include -#include - -unsigned int LoaderBase::depth = 0; -std::set LoaderBase::loadedObjects; - -class DepthCounter { - public: - DepthCounter(unsigned int & c) : counter(c) { - counter += 1; - } - ~DepthCounter() { - counter -= 1; - } - private: - unsigned int & counter; -}; - -typedef std::map > ElementLoaderMap; -typedef std::set > ComponentLoaderSet; - -LoaderBase::LoaderBase() : - recursive(true) -{ -} - -LoaderBase::~LoaderBase() -{ -} - -void -LoaderBase::addLoadTarget(ScriptNodePtr src, boost::intrusive_ptr target) { - targets[src].push_back(target); -} - - std::set > * & -LoaderBase::componentLoaders() -{ - static std::set > * _compLoaders = NULL; - if (!_compLoaders) { - _compLoaders = new std::set >(); - } - return _compLoaders; -} - -void -LoaderBase::collectAll(ScriptNodePtr node, bool childrenOnly, const StorerPtrs & sts) const -{ - DepthCounter dc(depth); - unsigned int created = 0; - if (!childrenOnly && node->componentNamespace()) { - Glib::ustring name = node->get_name(); - unsigned int stored = 0; - created += 1; - boost::intrusive_ptr o; - BOOST_FOREACH(const StorerPtr & s, sts) { - try { - o = s->create(node); - break; - } - catch (const NotSupported &) { - } - } - if (!o) { - throw NotSupported(name); - } - BOOST_FOREACH(const StorerPtr & s, sts) { - if (s->save(o, node)) { - stored += 1; - break; - } - } - if (stored < 1) { - throw NotSupported(name); - } - } - if (created == 0 && (recursive || childrenOnly)) { - BOOST_FOREACH(ScriptNodePtr child, node->children()) { - collectAll(child, false, sts); - } - } -} - -void -LoaderBase::collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr node) -{ - (void)co; - addLoadTarget(node, Storer::into(&libraries)); - if (depth != 0 && co) { - throw std::logic_error("Cannot set CommonObjects in subloader"); - } - Targets::iterator i; - while ((i = targets.begin()) != targets.end()) { - collectAll(i->first, childrenOnly, i->second); - targets.erase(i); - } - if (co) { - BOOST_FOREACH(SourceObjectPtr o, loadedObjects) { - o->loadComplete(co); - } - loadedObjects.clear(); - } -} - -void -LoaderBase::onAllComponents(const boost::function1 & func) -{ - BOOST_FOREACH(ComponentLoaderSet::value_type l, *componentLoaders()) { - try { - func(l.get()); - } - catch (...) { - } - } -} - -void -ComponentLoader::onBegin() -{ -} - -void -ComponentLoader::onBefore() -{ -} - -void -ComponentLoader::onIdle() -{ -} - -void -ComponentLoader::onIteration() -{ -} - -void -ComponentLoader::onPeriodic() -{ -} - -const Options * -ComponentLoader::options() const -{ - return NULL; -} - diff --git a/project2/common/xmlObjectLoader.h b/project2/common/xmlObjectLoader.h deleted file mode 100644 index 3dd12a4..0000000 --- a/project2/common/xmlObjectLoader.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef XMLOBJECTLOADER_H -#define XMLOBJECTLOADER_H - -#include -#include -#include -#include -#include -#include "intrusivePtrBase.h" -#include "sourceObject.h" -#include "exceptions.h" -#include -#include -#include - -enum UnsupportedHandling { ErrorOnUnsupported, WarnOnUnsupported, IgnoreUnsupported }; -class ElementLoader; -class ComponentLoader; -class CommonObjects; -class Storer; -class ScriptReader; - -class LoaderBase { - public: - typedef boost::intrusive_ptr StorerPtr; - typedef std::vector StorerPtrs; - typedef std::map Targets; - - LoaderBase(); - virtual ~LoaderBase(); - void collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr script); - - void addLoadTarget(ScriptNodePtr src, boost::intrusive_ptr target); - - static void onAllComponents(const boost::function1 &); - - static std::set > * & componentLoaders(); - - 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)); - componentLoaders()->insert(boost::shared_ptr(p)); - } - - template - static void removeLoader(const std::string & n) - { - std::map > * & o = objLoaders(); - std::set > * & c = componentLoaders(); - 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; - Targets targets; - static unsigned int depth; - template friend class ElementLoaderImpl; - static std::set loadedObjects; - - const bool recursive; - - public: - const Glib::ustring ns; -}; - -#define DECLARE_CUSTOM_COMPONENT_LOADER(N, I, T, B) \ - 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##Impl, B) -#define DECLARE_LOADER(N, T) \ - DECLARE_COMPONENT_LOADER(N, T, ElementLoader) - -/// Helper for loading and maintaining Project2 components -class Options; -class ComponentLoader { - public: - 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 const Options * options() const; // Options to be populated from the common config file/env/etc -}; -/// Helper for loading and maintaining Project2 script components -class ElementLoader : public ComponentLoader { - public: - virtual SourceObjectPtr createFrom(ScriptNodePtr) const = 0; -}; - -/// Helper for loading and maintaining Project2 script components (typed implementation) -template -class ElementLoaderImpl : public ElementLoader { - public: - SourceObjectPtr createFrom(ScriptNodePtr sn) const - { - SourceObjectPtr sop = new X(sn); - LoaderBase::loadedObjects.insert(sop); - return sop; - } -}; -#endif - diff --git a/project2/common/xmlStorage.h b/project2/common/xmlStorage.h deleted file mode 100644 index 267343f..0000000 --- a/project2/common/xmlStorage.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef XMLSTORAGE_H -#define XMLSTORAGE_H - -#include "sourceObject.h" -#include "xmlObjectLoader.h" -#include "exceptions.h" -#include "scripts.h" -#include -#include -#include -#include - -SimpleMessageException(StoreFailed); - -#define SINGLE(X) \ - boost::intrusive_ptr -#define STORAGEOF(X) \ - std::map > -#define ANONORDEREDSTORAGEOF(X) \ - std::list > -#define ANONSTORAGEOF(X) \ - std::set > - -class Storer; -typedef boost::intrusive_ptr StorerPtr; -class Storer : public virtual IntrusivePtrBase { - public: - template - static StorerPtr into(SINGLE(X) * obj); - template - static StorerPtr into(STORAGEOF(X) * map); - template - static StorerPtr into(ANONSTORAGEOF(X) * set); - template - static StorerPtr into(ANONORDEREDSTORAGEOF(X) * list); - - virtual boost::intrusive_ptr create(ScriptNodePtr) const = 0; - virtual bool save(boost::intrusive_ptr, ScriptNodePtr) = 0; -}; - -template -class StorerBase : public Storer { - public: - typedef M * Map; - boost::intrusive_ptr create(ScriptNodePtr p) const { - return LoaderBase::getLoader(p->get_name())->createFrom(p); - } - bool save(boost::intrusive_ptr o, ScriptNodePtr p) { - boost::intrusive_ptr O = boost::dynamic_pointer_cast(o); - if (O) { - if (!insert(p, O)) { - throw StoreFailed(p->get_name()); - } - } - return O; - } - virtual bool insert(ScriptNodePtr, boost::intrusive_ptr) = 0; -}; - -template -class StorerImpl : public StorerBase { - public: - StorerImpl(M * m); - bool insert(ScriptNodePtr, boost::intrusive_ptr O); -}; -template -class StorerImpl : public StorerBase { - public: - typedef SINGLE(X) Obj; - StorerImpl(SINGLE(X) * o) : obj(o) - { - } - bool insert(ScriptNodePtr, boost::intrusive_ptr O) - { - *obj = O; - return true; - } - Obj * obj; -}; -template -class StorerImpl : public StorerBase { - public: - typedef STORAGEOF(X) Map; - StorerImpl(STORAGEOF(X) * m) : map(m) - { - } - bool insert(ScriptNodePtr, boost::intrusive_ptr O) - { - return map->insert(typename Map::value_type(O->name, O)).second; - } - Map * map; -}; -template -class StorerImpl : public StorerBase { - public: - typedef ANONSTORAGEOF(X) Map; - StorerImpl(ANONSTORAGEOF(X) * m) : map(m) - { - } - bool insert(ScriptNodePtr, boost::intrusive_ptr O) - { - map->insert(O); - return true; - } - Map * map; -}; -template -class StorerImpl : public StorerBase { - public: - typedef ANONORDEREDSTORAGEOF(X) Map; - StorerImpl(ANONORDEREDSTORAGEOF(X) * m) : map(m) - { - } - bool insert(ScriptNodePtr, boost::intrusive_ptr O) - { - map->push_back(O); - return true; - } - Map * map; -}; - -template -StorerPtr -Storer::into(SINGLE(X) * obj) { - return new StorerImpl(obj); -} - -template -StorerPtr -Storer::into(STORAGEOF(X) * map) { - return new StorerImpl(map); -} - -template -StorerPtr -Storer::into(ANONSTORAGEOF(X) * set) { - return new StorerImpl(set); -} - -template -StorerPtr -Storer::into(ANONORDEREDSTORAGEOF(X) * list) { - return new StorerImpl(list); -} - -#endif - diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp index 7229c36..cb8109f 100644 --- a/project2/console/consoleAppEngine.cpp +++ b/project2/console/consoleAppEngine.cpp @@ -5,7 +5,7 @@ #include "consoleEnvironment.h" #include "safeMapFind.h" #include "iterate.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include @@ -76,9 +76,3 @@ ConsoleApplicationEngine::addAppData(const MultiRowSetPresenter *) const { } -void -ConsoleApplicationEngine::loadEngineSection(const xmlpp::Element * e) const -{ - conplat.insert(ConsolePlatforms::value_type(e->get_attribute_value("setting"), e->get_attribute_value("platform"))); -} - diff --git a/project2/console/consoleAppEngine.h b/project2/console/consoleAppEngine.h index d53574f..9a9ce26 100644 --- a/project2/console/consoleAppEngine.h +++ b/project2/console/consoleAppEngine.h @@ -10,7 +10,6 @@ #include "taskHost.h" #include "viewHost.h" #include -#include class ConsoleEnvironment; @@ -31,7 +30,6 @@ class ConsoleApplicationEngine : public ApplicationEngine, TaskHost, ViewHost { private: typedef std::map ConsolePlatforms; mutable ConsolePlatforms conplat; - void loadEngineSection(const xmlpp::Element *) const; private: SessionPtr runtime; diff --git a/project2/console/consoleEnvironment.cpp b/project2/console/consoleEnvironment.cpp index 6c407b3..a378fc9 100644 --- a/project2/console/consoleEnvironment.cpp +++ b/project2/console/consoleEnvironment.cpp @@ -6,7 +6,7 @@ #include #include "logger.h" #include "exceptions.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include diff --git a/project2/console/p2consoleMain.cpp b/project2/console/p2consoleMain.cpp index c560bfd..19b3f9d 100644 --- a/project2/console/p2consoleMain.cpp +++ b/project2/console/p2consoleMain.cpp @@ -1,8 +1,7 @@ #include -#include #include "consoleEnvironment.h" #include "consoleAppEngine.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "logger.h" #include #include diff --git a/project2/console/pch.hpp b/project2/console/pch.hpp index 6e6ee96..30db218 100644 --- a/project2/console/pch.hpp +++ b/project2/console/pch.hpp @@ -8,7 +8,7 @@ #include "exceptions.h" #include "iterate.h" #include "logger.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include "options.h" diff --git a/project2/files/fileRows.cpp b/project2/files/fileRows.cpp index 4afbbb3..3a8800b 100644 --- a/project2/files/fileRows.cpp +++ b/project2/files/fileRows.cpp @@ -2,7 +2,7 @@ #include "logger.h" #include "scopeObject.h" #include "rowProcessor.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "exceptions.h" #include diff --git a/project2/files/fsRows.cpp b/project2/files/fsRows.cpp index 41ec4b6..1c72473 100644 --- a/project2/files/fsRows.cpp +++ b/project2/files/fsRows.cpp @@ -1,6 +1,6 @@ #include "fsRows.h" #include "logger.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "rowProcessor.h" #include "exceptions.h" #include diff --git a/project2/json/couchSession.cpp b/project2/json/couchSession.cpp index 8a4436b..a328ad5 100644 --- a/project2/json/couchSession.cpp +++ b/project2/json/couchSession.cpp @@ -4,7 +4,7 @@ #include "exceptions.h" #include "../libmisc/buffer.h" #include "../libmisc/curlsup.h" -#include +#include #include #include #include diff --git a/project2/mail/sendmailTask.cpp b/project2/mail/sendmailTask.cpp index e8b354f..447b8f9 100644 --- a/project2/mail/sendmailTask.cpp +++ b/project2/mail/sendmailTask.cpp @@ -2,7 +2,7 @@ #include "logger.h" #include #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "viewHost.h" #include "environment.h" #include diff --git a/project2/mail/sendmailTask.h b/project2/mail/sendmailTask.h index 6e2a10b..9cf4922 100644 --- a/project2/mail/sendmailTask.h +++ b/project2/mail/sendmailTask.h @@ -1,7 +1,6 @@ #ifndef SENDMAILTASK_H #define SENDMAILTASK_H -#include #include #include #include "task.h" diff --git a/project2/processes/procRows.cpp b/project2/processes/procRows.cpp index 2e1f643..eb41b1d 100644 --- a/project2/processes/procRows.cpp +++ b/project2/processes/procRows.cpp @@ -1,5 +1,5 @@ #include "procRows.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "scripts.h" #include #include diff --git a/project2/regex/regexCheck.cpp b/project2/regex/regexCheck.cpp index e58e8f1..e7975bc 100644 --- a/project2/regex/regexCheck.cpp +++ b/project2/regex/regexCheck.cpp @@ -1,5 +1,5 @@ #include "regexCheck.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "commonObjects.h" #include diff --git a/project2/regex/regexRows.cpp b/project2/regex/regexRows.cpp index 1238eb5..e1b18f9 100644 --- a/project2/regex/regexRows.cpp +++ b/project2/regex/regexRows.cpp @@ -1,5 +1,5 @@ #include "regexRows.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "rowProcessor.h" #include #include diff --git a/project2/sql/connectionLoader.h b/project2/sql/connectionLoader.h index eabf28b..3dc5f93 100644 --- a/project2/sql/connectionLoader.h +++ b/project2/sql/connectionLoader.h @@ -1,7 +1,7 @@ #ifndef CONNECTIONLOADER_H #define CONNECTIONLOADER_H -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "../libdbpp/connection.h" /// Base class to implement DB connection type modules diff --git a/project2/sql/pch.hpp b/project2/sql/pch.hpp index 01c68d4..f1ff842 100644 --- a/project2/sql/pch.hpp +++ b/project2/sql/pch.hpp @@ -20,7 +20,7 @@ #include "sqlVariableBinder.h" #include "sqlWriter.h" #include "variables.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "scripts.h" #include #include diff --git a/project2/sql/rdbmsDataSource.h b/project2/sql/rdbmsDataSource.h index bc72b05..b991cc4 100644 --- a/project2/sql/rdbmsDataSource.h +++ b/project2/sql/rdbmsDataSource.h @@ -7,7 +7,7 @@ #include "dataSource.h" #include "../libdbpp/connection.h" #include "../libdbpp/error.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" class ConnectionLoader; diff --git a/project2/sql/sqlCache.cpp b/project2/sql/sqlCache.cpp index 7ed4ae1..e94e345 100644 --- a/project2/sql/sqlCache.cpp +++ b/project2/sql/sqlCache.cpp @@ -9,7 +9,7 @@ #include "commonObjects.h" #include "rdbmsDataSource.h" #include "logger.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "iHaveParameters.h" #include "rowSet.h" #include diff --git a/project2/sql/sqlCheck.cpp b/project2/sql/sqlCheck.cpp index 879cbca..b1d369c 100644 --- a/project2/sql/sqlCheck.cpp +++ b/project2/sql/sqlCheck.cpp @@ -1,6 +1,6 @@ #include #include "sqlCheck.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "selectcommand.h" #include "column.h" #include "rdbmsDataSource.h" diff --git a/project2/sql/sqlMergeTask.cpp b/project2/sql/sqlMergeTask.cpp index 972b299..0182f1e 100644 --- a/project2/sql/sqlMergeTask.cpp +++ b/project2/sql/sqlMergeTask.cpp @@ -5,7 +5,7 @@ #include "rdbmsDataSource.h" #include "exceptions.h" #include "sqlVariableBinder.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include diff --git a/project2/sql/sqlRows.cpp b/project2/sql/sqlRows.cpp index dbcc7be..83763dd 100644 --- a/project2/sql/sqlRows.cpp +++ b/project2/sql/sqlRows.cpp @@ -6,7 +6,7 @@ #include "rdbmsDataSource.h" #include "column.h" #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "commonObjects.h" #include #include diff --git a/project2/sql/sqlTask.cpp b/project2/sql/sqlTask.cpp index 6ff05af..6855cc0 100644 --- a/project2/sql/sqlTask.cpp +++ b/project2/sql/sqlTask.cpp @@ -1,7 +1,7 @@ #include #include "sqlTask.h" #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "modifycommand.h" #include "rdbmsDataSource.h" #include "commonObjects.h" diff --git a/project2/url/urlRows.cpp b/project2/url/urlRows.cpp index a634126..84253c2 100644 --- a/project2/url/urlRows.cpp +++ b/project2/url/urlRows.cpp @@ -1,6 +1,6 @@ #include "urlRows.h" #include "rowProcessor.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "exceptions.h" #include "../libmisc/curlsup.h" #include diff --git a/project2/xml/rawView.cpp b/project2/xml/rawView.cpp index 8feceb3..cd65cfa 100644 --- a/project2/xml/rawView.cpp +++ b/project2/xml/rawView.cpp @@ -3,7 +3,7 @@ #include "rawView.h" #include "xml.h" #include "presenter.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "environment.h" #include "appEngine.h" #include "xmlScriptParser.h" diff --git a/project2/xml/xmlCache.cpp b/project2/xml/xmlCache.cpp index 96cf914..5233928 100644 --- a/project2/xml/xmlCache.cpp +++ b/project2/xml/xmlCache.cpp @@ -1,7 +1,7 @@ #include #include "cache.h" #include "logger.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "iHaveParameters.h" #include "xmlRawRows.h" #include "xmlPresenter.h" diff --git a/project2/xml/xmlDocumentCache.cpp b/project2/xml/xmlDocumentCache.cpp index 696b2e5..a26b526 100644 --- a/project2/xml/xmlDocumentCache.cpp +++ b/project2/xml/xmlDocumentCache.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include "xmlDocumentCache.h" #include #include diff --git a/project2/xml/xmlDocumentPrefetch.cpp b/project2/xml/xmlDocumentPrefetch.cpp index 2be3eea..64b236e 100644 --- a/project2/xml/xmlDocumentPrefetch.cpp +++ b/project2/xml/xmlDocumentPrefetch.cpp @@ -1,6 +1,6 @@ #include #include "xmlDocumentPrefetch.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" DECLARE_LOADER("xmldocumentprefetch", XmlDocumentPrefetch); diff --git a/project2/xml/xmlPresenter.cpp b/project2/xml/xmlPresenter.cpp index 86ec831..9d9f0fd 100644 --- a/project2/xml/xmlPresenter.cpp +++ b/project2/xml/xmlPresenter.cpp @@ -1,6 +1,6 @@ #include #include "xmlPresenter.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "variables.h" #include "appEngine.h" #include @@ -31,8 +31,8 @@ void XmlPresenter::createDoc(const Glib::ustring & responseRootNodeName, const Glib::ustring & responseStyle) const { nodeStack.push_back(responseDoc->create_root_node(responseRootNodeName)); - declareNamespace(Environment::getCurrent()->xmlPrefix, - Environment::getCurrent()->xmlNamespace); + declareNamespace(Environment::getCurrent()->scriptNamespacePrefix, + Environment::getCurrent()->scriptNamespace); // XSLT Style char * buf; if (!responseStyle.empty() && asprintf(&buf, "type=\"text/xsl\" href=\"%s\"", diff --git a/project2/xml/xmlRows.cpp b/project2/xml/xmlRows.cpp index 9ec7be0..01e626f 100644 --- a/project2/xml/xmlRows.cpp +++ b/project2/xml/xmlRows.cpp @@ -5,7 +5,7 @@ #include "exceptions.h" #include #include -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include diff --git a/project2/xml/xmlScriptParser.cpp b/project2/xml/xmlScriptParser.cpp index 4963b8f..fc62a6b 100644 --- a/project2/xml/xmlScriptParser.cpp +++ b/project2/xml/xmlScriptParser.cpp @@ -64,7 +64,7 @@ XmlScriptNode::xmlElement() const bool XmlScriptNode::componentNamespace() const { - return element->get_namespace_uri () == Environment::getCurrent()->xmlNamespace; + return element->get_namespace_uri () == Environment::getCurrent()->scriptNamespace; } std::string diff --git a/project2/xml/xmlScriptParser.h b/project2/xml/xmlScriptParser.h index ad0b1bf..452f0ef 100644 --- a/project2/xml/xmlScriptParser.h +++ b/project2/xml/xmlScriptParser.h @@ -3,7 +3,7 @@ #include #include "exceptions.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include "scripts.h" #include #include diff --git a/project2/xml/xpathRows.cpp b/project2/xml/xpathRows.cpp index bc9481a..c4fde3b 100644 --- a/project2/xml/xpathRows.cpp +++ b/project2/xml/xpathRows.cpp @@ -5,7 +5,7 @@ #include "logger.h" #include "xml.h" #include "exceptions.h" -#include "xmlObjectLoader.h" +#include "scriptLoader.h" #include #include #include -- cgit v1.2.3