summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-10-02 21:25:12 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-10-02 21:25:12 +0100
commitc9382a9c89ce03f1fcde3fadd294a3938b894e47 (patch)
tree7e5de1834f121b44f2485132741a6b3fe8431129
parentCompat fix (diff)
parentBig tidy up of loggers and logger factories (diff)
downloadproject2-c9382a9c89ce03f1fcde3fadd294a3938b894e47.tar.bz2
project2-c9382a9c89ce03f1fcde3fadd294a3938b894e47.tar.xz
project2-c9382a9c89ce03f1fcde3fadd294a3938b894e47.zip
Merge branch 'project2-adhoc-plugins'
-rw-r--r--project2/basics/aggregates/avg.cpp2
-rw-r--r--project2/basics/aggregates/count.cpp3
-rw-r--r--project2/basics/aggregates/countDistinct.cpp2
-rw-r--r--project2/basics/aggregates/distinct.cpp3
-rw-r--r--project2/basics/aggregates/join.cpp2
-rw-r--r--project2/basics/aggregates/max.cpp3
-rw-r--r--project2/basics/aggregates/min.cpp2
-rw-r--r--project2/basics/aggregates/sum.cpp2
-rw-r--r--project2/basics/caches/memoryCache.cpp10
-rw-r--r--project2/basics/functions/dates.cpp8
-rw-r--r--project2/basics/functions/strings.cpp2
-rw-r--r--project2/basics/if.cpp10
-rw-r--r--project2/basics/loggers/consoleLog.cpp6
-rw-r--r--project2/basics/loggers/syslogLog.cpp6
-rw-r--r--project2/basics/options/preload.cpp6
-rw-r--r--project2/basics/options/showHelp.cpp6
-rw-r--r--project2/basics/options/showHelp.h4
-rw-r--r--project2/basics/tasks/iterate.cpp4
-rw-r--r--project2/basics/tasks/session/sessionClearTask.cpp2
-rw-r--r--project2/basics/tasks/session/sessionSetTask.cpp2
-rw-r--r--project2/basics/tasks/structExceptHandling.cpp9
-rw-r--r--project2/basics/tests/compoundTest.cpp12
-rw-r--r--project2/basics/tests/equals.cpp4
-rw-r--r--project2/basics/tests/greaterthan.cpp4
-rw-r--r--project2/basics/tests/greaterthanorequal.cpp4
-rw-r--r--project2/basics/tests/isdistinct.cpp3
-rw-r--r--project2/basics/tests/isuniq.cpp3
-rw-r--r--project2/basics/tests/lessthan.cpp4
-rw-r--r--project2/basics/tests/lessthanorequal.cpp4
-rw-r--r--project2/basics/tests/notequals.cpp4
-rw-r--r--project2/basics/tests/validDateCheck.cpp2
-rw-r--r--project2/basics/unittests/dummylib.cpp2
-rw-r--r--project2/basics/unittests/testLibraries.cpp7
-rw-r--r--project2/basics/views/autotree.cpp2
-rw-r--r--project2/basics/views/flatView.cpp4
-rw-r--r--project2/basics/views/flatView.h1
-rw-r--r--project2/basics/views/rowView.cpp8
-rw-r--r--project2/basics/views/singleton.cpp4
-rw-r--r--project2/basics/views/viewGroup.cpp4
-rw-r--r--project2/cgi/cgiAppEngine.cpp8
-rw-r--r--project2/cgi/cgiAppEngine.h2
-rw-r--r--project2/cgi/cgiContentNegotiate.cpp14
-rw-r--r--project2/cgi/cgiOutputOptions.cpp15
-rw-r--r--project2/cgi/cgiOutputOptions.h12
-rw-r--r--project2/cgi/cgiProgRouter.cpp30
-rw-r--r--project2/cgi/cgiRequestContext.cpp2
-rw-r--r--project2/cgi/cgiRequestID.cpp3
-rw-r--r--project2/cgi/cgiRouter.cpp4
-rw-r--r--project2/cgi/cgiRouter.h3
-rw-r--r--project2/cgi/cgiSimpleRouter.cpp2
-rw-r--r--project2/cgi/cgiStageDefaultError.cpp2
-rw-r--r--project2/cgi/cgiStageFail.cpp3
-rw-r--r--project2/cgi/cgiStagePresent.cpp10
-rw-r--r--project2/cgi/cgiStageRedirect.cpp4
-rw-r--r--project2/cgi/cgiUriParam.cpp2
-rw-r--r--project2/cgi/p2webCgi.cpp8
-rw-r--r--project2/cgi/p2webFCgi.cpp8
-rw-r--r--project2/cgi/pch.hpp6
-rw-r--r--project2/cgi/testCgi.cpp22
-rw-r--r--project2/common/Jamfile.jam2
-rw-r--r--project2/common/aggregate.cpp4
-rw-r--r--project2/common/aggregate.h2
-rw-r--r--project2/common/check.cpp7
-rw-r--r--project2/common/check.h1
-rw-r--r--project2/common/checkHost.cpp2
-rw-r--r--project2/common/commonObjects.cpp4
-rw-r--r--project2/common/componentLoader.cpp37
-rw-r--r--project2/common/dataSource.cpp3
-rw-r--r--project2/common/dataSource.h1
-rw-r--r--project2/common/genLoader.h38
-rw-r--r--project2/common/iHaveSubTasks.cpp2
-rw-r--r--project2/common/iHaveSubTasks.h7
-rw-r--r--project2/common/instanceStore.h52
-rw-r--r--project2/common/instanceStore.impl.h97
-rw-r--r--project2/common/library.cpp5
-rw-r--r--project2/common/lifeCycle.cpp50
-rw-r--r--project2/common/lifeCycle.h (renamed from project2/common/componentLoader.h)22
-rw-r--r--project2/common/logger.cpp20
-rw-r--r--project2/common/logger.h54
-rw-r--r--project2/common/loggerFactory.cpp14
-rw-r--r--project2/common/loggerFactory.h38
-rw-r--r--project2/common/loggerFactory.impl.h43
-rw-r--r--project2/common/noOutputExecute.cpp17
-rw-r--r--project2/common/noOutputExecute.h23
-rw-r--r--project2/common/options.cpp4
-rw-r--r--project2/common/options.h14
-rw-r--r--project2/common/optionsSource.cpp45
-rw-r--r--project2/common/optionsSource.h8
-rw-r--r--project2/common/pch.hpp16
-rw-r--r--project2/common/plugable.cpp8
-rw-r--r--project2/common/plugable.h82
-rw-r--r--project2/common/presenter.cpp4
-rw-r--r--project2/common/presenter.h2
-rw-r--r--project2/common/presenterCache.cpp3
-rw-r--r--project2/common/presenterCache.h1
-rw-r--r--project2/common/rowProcessor.cpp4
-rw-r--r--project2/common/rowSet.cpp3
-rw-r--r--project2/common/rowSet.h1
-rw-r--r--project2/common/rowSetCache.cpp3
-rw-r--r--project2/common/rowSetCache.h1
-rw-r--r--project2/common/scriptLoader.cpp12
-rw-r--r--project2/common/scriptLoader.h8
-rw-r--r--project2/common/scriptStorage.h11
-rw-r--r--project2/common/scripts.cpp8
-rw-r--r--project2/common/scripts.h8
-rw-r--r--project2/common/sessionContainer.cpp4
-rw-r--r--project2/common/sessionContainer.h3
-rw-r--r--project2/common/sourceObject.cpp4
-rw-r--r--project2/common/stream.cpp3
-rw-r--r--project2/common/stream.h1
-rw-r--r--project2/common/task.cpp11
-rw-r--r--project2/common/task.h6
-rw-r--r--project2/common/taskHost.cpp4
-rw-r--r--project2/common/taskHost.h3
-rw-r--r--project2/common/test.cpp3
-rw-r--r--project2/common/test.h1
-rw-r--r--project2/common/transform.cpp14
-rw-r--r--project2/common/transform.h9
-rw-r--r--project2/common/unittests/testConfig.cpp2
-rw-r--r--project2/common/variableType.cpp1
-rw-r--r--project2/common/variables.cpp6
-rw-r--r--project2/common/variables.h6
-rw-r--r--project2/common/variables/config.cpp12
-rw-r--r--project2/common/variables/literal.cpp5
-rw-r--r--project2/common/variables/localparam.cpp2
-rw-r--r--project2/common/variables/lookup.cpp4
-rw-r--r--project2/common/variables/param.cpp2
-rw-r--r--project2/common/variables/session.cpp2
-rw-r--r--project2/common/view.cpp3
-rw-r--r--project2/common/view.h1
-rw-r--r--project2/common/viewHost.cpp2
-rw-r--r--project2/common/viewHost.h1
-rw-r--r--project2/compression/decompressStream.cpp9
-rw-r--r--project2/compression/decompressor.cpp7
-rw-r--r--project2/compression/decompressor.h8
-rw-r--r--project2/compression/gzip.cpp2
-rw-r--r--project2/compression/nocomp.cpp3
-rw-r--r--project2/console/consoleAppEngine.cpp4
-rw-r--r--project2/console/p2consoleMain.cpp9
-rw-r--r--project2/console/pch.hpp7
-rw-r--r--project2/daemon/lib/daemon.cpp4
-rw-r--r--project2/daemon/lib/daemon.h4
-rw-r--r--project2/daemon/p2daemonAppEngine.cpp8
-rw-r--r--project2/daemon/p2daemonMain.cpp8
-rw-r--r--project2/files/fileLog.cpp6
-rw-r--r--project2/files/fileStream.cpp6
-rw-r--r--project2/files/fsFilterMaxDepth.cpp3
-rw-r--r--project2/files/fsFilterName.cpp3
-rw-r--r--project2/files/fsFilterType.cpp4
-rw-r--r--project2/files/fsRows.cpp11
-rw-r--r--project2/files/fsRows.h19
-rw-r--r--project2/files/functions/pwd.cpp2
-rw-r--r--project2/files/optionsSource.cpp14
-rw-r--r--project2/files/pch.hpp20
-rw-r--r--project2/files/presenterCache.cpp11
-rw-r--r--project2/files/writeStream.cpp5
-rw-r--r--project2/ice/iceDaemon.cpp12
-rw-r--r--project2/ice/iceDataSource.cpp4
-rw-r--r--project2/ice/iceModule.cpp4
-rw-r--r--project2/ice/iceModule.h3
-rw-r--r--project2/ice/iceRows.h3
-rw-r--r--project2/ice/iceTask.h5
-rw-r--r--project2/ice/pch.hpp8
-rw-r--r--project2/ice/slice2Common.cpp6
-rw-r--r--project2/ice/slice2Common.h2
-rw-r--r--project2/ice/slice2Daemon.cpp2
-rw-r--r--project2/ice/slice2Rows.cpp2
-rw-r--r--project2/ice/slice2Task.cpp2
-rw-r--r--project2/ice/unittests/testClient.cpp28
-rw-r--r--project2/ice/unittests/testClientCompile.cpp20
-rw-r--r--project2/ice/unittests/testDaemon.cpp12
-rw-r--r--project2/ice/unittests/testDaemonCompile.cpp4
-rw-r--r--project2/json/pch.hpp4
-rw-r--r--project2/json/presenter-p.cpp3
-rw-r--r--project2/json/presenter.cpp3
-rw-r--r--project2/mail/sendmailTask.cpp2
-rw-r--r--project2/mail/sendmailTask.h1
-rw-r--r--project2/processes/processStream.cpp3
-rw-r--r--project2/regex/regexRows.cpp2
-rw-r--r--project2/regex/regexTest.cpp2
-rw-r--r--project2/sql/pch.hpp28
-rw-r--r--project2/sql/rdbmsDataSource.cpp6
-rw-r--r--project2/sql/rdbmsDataSource.h2
-rw-r--r--project2/sql/sqlBulkLoad.cpp5
-rw-r--r--project2/sql/sqlCache.cpp6
-rw-r--r--project2/sql/sqlMergeTask.cpp12
-rw-r--r--project2/sql/sqlRows.cpp2
-rw-r--r--project2/sql/sqlTask.cpp10
-rw-r--r--project2/sql/sqlTask.h7
-rw-r--r--project2/sql/sqlTest.cpp2
-rw-r--r--project2/streams/streamNvpRows.cpp4
-rw-r--r--project2/streams/streamPresenter.cpp5
-rw-r--r--project2/streams/streamRows.cpp4
-rw-r--r--project2/streams/viewStream.cpp6
-rw-r--r--project2/url/downloadToFile.cpp2
-rw-r--r--project2/url/urlStream.cpp2
-rw-r--r--project2/ut/butf_logger.cpp6
-rw-r--r--project2/ut/testScriptHost.cpp2
-rw-r--r--project2/xml/mutators/copy.cpp2
-rw-r--r--project2/xml/mutators/copyToAttr.cpp3
-rw-r--r--project2/xml/mutators/create.cpp3
-rw-r--r--project2/xml/mutators/delete.cpp3
-rw-r--r--project2/xml/mutators/rename.cpp4
-rw-r--r--project2/xml/pch.hpp10
-rw-r--r--project2/xml/rawView.cpp4
-rw-r--r--project2/xml/sessionXml.cpp4
-rw-r--r--project2/xml/sessionXml.h2
-rw-r--r--project2/xml/transformHtml.cpp29
-rw-r--r--project2/xml/transformText.cpp4
-rw-r--r--project2/xml/xmlCache.cpp6
-rw-r--r--project2/xml/xmlDocumentCache.cpp4
-rw-r--r--project2/xml/xmlDocumentPrefetch.cpp3
-rw-r--r--project2/xml/xmlPresenter.cpp8
-rw-r--r--project2/xml/xmlPresenter.h2
-rw-r--r--project2/xml/xmlRawRows.cpp2
-rw-r--r--project2/xml/xmlRows.cpp2
-rw-r--r--project2/xml/xmlScriptParser.cpp15
-rw-r--r--project2/xml/xpathRows.cpp2
218 files changed, 745 insertions, 1028 deletions
diff --git a/project2/basics/aggregates/avg.cpp b/project2/basics/aggregates/avg.cpp
index 900bc5f..0547120 100644
--- a/project2/basics/aggregates/avg.cpp
+++ b/project2/basics/aggregates/avg.cpp
@@ -26,5 +26,5 @@ class Average : public ValueAggregate {
mutable std::list<double> vals;
};
-DECLARE_LOADER("average", Average);
+NAMEDFACTORY("average", Average, ValueAggregateFactory);
diff --git a/project2/basics/aggregates/count.cpp b/project2/basics/aggregates/count.cpp
index be22783..3d47b34 100644
--- a/project2/basics/aggregates/count.cpp
+++ b/project2/basics/aggregates/count.cpp
@@ -25,6 +25,5 @@ class Count : public ValueAggregate {
mutable int c;
};
-DECLARE_LOADER("count", Count);
-
+NAMEDFACTORY("count", Count, ValueAggregateFactory);
diff --git a/project2/basics/aggregates/countDistinct.cpp b/project2/basics/aggregates/countDistinct.cpp
index 205b932..9acba4c 100644
--- a/project2/basics/aggregates/countDistinct.cpp
+++ b/project2/basics/aggregates/countDistinct.cpp
@@ -22,5 +22,5 @@ class CountDistinct : public ValueAggregate {
mutable std::set<VariableType> result;
};
-DECLARE_LOADER("countdistinct", CountDistinct);
+NAMEDFACTORY("countdistinct", CountDistinct, ValueAggregateFactory);
diff --git a/project2/basics/aggregates/distinct.cpp b/project2/basics/aggregates/distinct.cpp
index 33d71b0..c7f5fe0 100644
--- a/project2/basics/aggregates/distinct.cpp
+++ b/project2/basics/aggregates/distinct.cpp
@@ -24,4 +24,5 @@ class Distinct : public SetAggregate {
mutable std::set<VariableType> result;
};
-DECLARE_LOADER("distinct", Distinct);
+NAMEDFACTORY("distinct", Distinct, SetAggregateFactory);
+
diff --git a/project2/basics/aggregates/join.cpp b/project2/basics/aggregates/join.cpp
index 405c093..695626f 100644
--- a/project2/basics/aggregates/join.cpp
+++ b/project2/basics/aggregates/join.cpp
@@ -31,5 +31,5 @@ class Join : public ValueAggregate {
Variable sep;
};
-DECLARE_LOADER("join", Join);
+NAMEDFACTORY("join", Join, ValueAggregateFactory);
diff --git a/project2/basics/aggregates/max.cpp b/project2/basics/aggregates/max.cpp
index 6304647..a193ed4 100644
--- a/project2/basics/aggregates/max.cpp
+++ b/project2/basics/aggregates/max.cpp
@@ -22,6 +22,5 @@ class Max : public ValueAggregate {
mutable VariableType result;
};
-DECLARE_LOADER("max", Max);
-
+NAMEDFACTORY("max", Max, ValueAggregateFactory);
diff --git a/project2/basics/aggregates/min.cpp b/project2/basics/aggregates/min.cpp
index 75b0b87..f5e442c 100644
--- a/project2/basics/aggregates/min.cpp
+++ b/project2/basics/aggregates/min.cpp
@@ -28,5 +28,5 @@ class Min : public ValueAggregate {
mutable bool first;
};
-DECLARE_LOADER("min", Min);
+NAMEDFACTORY("min", Min, ValueAggregateFactory);
diff --git a/project2/basics/aggregates/sum.cpp b/project2/basics/aggregates/sum.cpp
index 68a9cd4..bdbf229 100644
--- a/project2/basics/aggregates/sum.cpp
+++ b/project2/basics/aggregates/sum.cpp
@@ -23,5 +23,5 @@ class Sum : public ValueAggregate {
mutable double sum;
};
-DECLARE_LOADER("sum", Sum);
+NAMEDFACTORY("sum", Sum, ValueAggregateFactory);
diff --git a/project2/basics/caches/memoryCache.cpp b/project2/basics/caches/memoryCache.cpp
index 2bec824..8aaa019 100644
--- a/project2/basics/caches/memoryCache.cpp
+++ b/project2/basics/caches/memoryCache.cpp
@@ -138,14 +138,14 @@ class MemoryCache : public RowSetCache {
CachedRowSetPtr cur;
- friend class CustomMemoryCacheLoader;
+ friend class CustomMemoryCacheFactory;
static time_t CacheLife;
static CacheStore Store;
};
time_t MemoryCache::CacheLife;
MemoryCache::CacheStore MemoryCache::Store;
-class CustomMemoryCacheLoader : public ElementLoader::For<MemoryCache> {
+class CustomMemoryCacheFactory : public RowSetCacheFactory::For<MemoryCache>, public LifeCycle {
public:
void onPeriodic() override {
typedef MemoryCache::CacheStore::index<MemoryCache::IndexByTime>::type::iterator iter;
@@ -156,10 +156,10 @@ class CustomMemoryCacheLoader : public ElementLoader::For<MemoryCache> {
INITOPTIONS;
};
-DECLARE_CUSTOM_LOADER("memorycache", CustomMemoryCacheLoader);
+NAMEDPLUGIN("memorycache", CustomMemoryCacheFactory, RowSetCacheFactory);
-DECLARE_OPTIONS(CustomMemoryCacheLoader, "Memory Cache options")
+DECLARE_OPTIONS(CustomMemoryCacheFactory, "Memory Cache options")
("cache.memory.life", Options::value(&MemoryCache::CacheLife, 3600),
"The age of cache entries after which they are removed (seconds)")
-END_OPTIONS(CustomMemoryCacheLoader);
+END_OPTIONS(CustomMemoryCacheFactory);
diff --git a/project2/basics/functions/dates.cpp b/project2/basics/functions/dates.cpp
index b19b921..91a7077 100644
--- a/project2/basics/functions/dates.cpp
+++ b/project2/basics/functions/dates.cpp
@@ -35,7 +35,7 @@ class ParseDate : public VariableImpl {
Variable string;
Variable format;
};
-DECLARE_COMPONENT_LOADER("parsedate", ParseDate, VariableLoader);
+NAMEDFACTORY("parsedate", ParseDate, VariableFactory);
class FormatDate : public VariableImpl {
public:
@@ -57,7 +57,7 @@ class FormatDate : public VariableImpl {
Variable date;
Variable format;
};
-DECLARE_COMPONENT_LOADER("formatdate", FormatDate, VariableLoader);
+NAMEDFACTORY("formatdate", FormatDate, VariableFactory);
class AdjustDate : public VariableImpl {
public:
@@ -74,7 +74,7 @@ class AdjustDate : public VariableImpl {
Variable date;
Variable offset;
};
-DECLARE_COMPONENT_LOADER("adjustdate", AdjustDate, VariableLoader);
+NAMEDFACTORY("adjustdate", AdjustDate, VariableFactory);
class CurrentDate : public VariableImpl {
public:
@@ -86,5 +86,5 @@ class CurrentDate : public VariableImpl {
return boost::posix_time::microsec_clock::universal_time();
}
};
-DECLARE_COMPONENT_LOADER("currentdate", CurrentDate, VariableLoader);
+NAMEDFACTORY("currentdate", CurrentDate, VariableFactory);
diff --git a/project2/basics/functions/strings.cpp b/project2/basics/functions/strings.cpp
index 735a781..640cfb3 100644
--- a/project2/basics/functions/strings.cpp
+++ b/project2/basics/functions/strings.cpp
@@ -23,6 +23,6 @@ class Trim : public VariableImpl {
private:
Variable string;
};
-DECLARE_COMPONENT_LOADER("trim", Trim, VariableLoader);
+NAMEDFACTORY("trim", Trim, VariableFactory);
diff --git a/project2/basics/if.cpp b/project2/basics/if.cpp
index bdd9835..d860b55 100644
--- a/project2/basics/if.cpp
+++ b/project2/basics/if.cpp
@@ -4,8 +4,10 @@
#include "scriptLoader.h"
#include <boost/bind.hpp>
#include <algorithm>
+#include <task.h>
-DECLARE_LOADER("if", If);
+NAMEDFACTORY("if", If, ViewFactory);
+NAMEDFACTORY("if", If, TaskFactory);
StaticMessageException(NoTestsToPerform, "No tests to perform");
If::If(ScriptNodePtr e) :
@@ -13,9 +15,9 @@ If::If(ScriptNodePtr e) :
IHaveSubTasks(e),
View(e)
{
- e->script->loader.addLoadTarget(e, Storer::into<ElementLoader>(&normal));
- e->script->loader.addLoadTarget(e, Storer::into<ElementLoader>(&subViews));
- e->script->loader.addLoadTarget(e, Storer::into<ElementLoader>(&test));
+ e->script->loader.addLoadTarget(e, Storer::into<TaskFactory>(&normal));
+ e->script->loader.addLoadTarget(e, Storer::into<ViewFactory>(&subViews));
+ e->script->loader.addLoadTarget(e, Storer::into<TestFactory>(&test));
}
bool
diff --git a/project2/basics/loggers/consoleLog.cpp b/project2/basics/loggers/consoleLog.cpp
index de45245..a88e6b2 100644
--- a/project2/basics/loggers/consoleLog.cpp
+++ b/project2/basics/loggers/consoleLog.cpp
@@ -1,5 +1,5 @@
-#include "logger.h"
-#include "options.h"
+#include <loggerFactory.impl.h>
+#include <options.h>
/// Logger that writes to the console
class ConsoleLogDriver : public LogDriverBase {
@@ -25,5 +25,5 @@ END_OPTIONS(ConsoleLogDriver);
int ConsoleLogDriver::level;
-DECLARE_LOGGER_LOADER("console", ConsoleLogDriver);
+DECLARE_LOGGER("console", ConsoleLogDriver);
diff --git a/project2/basics/loggers/syslogLog.cpp b/project2/basics/loggers/syslogLog.cpp
index 8e58326..cb026c6 100644
--- a/project2/basics/loggers/syslogLog.cpp
+++ b/project2/basics/loggers/syslogLog.cpp
@@ -1,5 +1,5 @@
-#include "logger.h"
-#include "options.h"
+#include <loggerFactory.impl.h>
+#include <options.h>
/// Logger that writes to syslog
class SyslogLogDriver : public LogDriverBase {
@@ -35,5 +35,5 @@ END_OPTIONS(SyslogLogDriver);
int SyslogLogDriver::level;
std::string SyslogLogDriver::ident;
-DECLARE_LOGGER_LOADER("syslog", SyslogLogDriver);
+DECLARE_LOGGER("syslog", SyslogLogDriver);
diff --git a/project2/basics/options/preload.cpp b/project2/basics/options/preload.cpp
index 5cf42e8..4781abb 100644
--- a/project2/basics/options/preload.cpp
+++ b/project2/basics/options/preload.cpp
@@ -19,7 +19,7 @@ class Preload {
static void LoadLibrary(const VariableType & librarypath)
{
- const auto beforeOpts = InstanceSet<Options>::GetAll();
+ const auto beforeOpts = AdHoc::PluginManager::getDefault()->getAll<Options>();
void * handle = dlopen(librarypath, RTLD_GLOBAL | RTLD_NOW);
if (handle) {
@@ -32,10 +32,10 @@ class Preload {
}
libs[librarypath.as<std::string>()] = boost::shared_ptr<void>(handle, &dlclose);
- const auto afterOpts = InstanceSet<Options>::GetAll();
+ const auto afterOpts = AdHoc::PluginManager::getDefault()->getAll<Options>();
for (const auto & opt : afterOpts) {
if (std::find(beforeOpts.begin(), beforeOpts.end(), opt) == beforeOpts.end()) {
- opt->reset();
+ opt->implementation()->reset();
}
}
}
diff --git a/project2/basics/options/showHelp.cpp b/project2/basics/options/showHelp.cpp
index 86dbc6f..395baed 100644
--- a/project2/basics/options/showHelp.cpp
+++ b/project2/basics/options/showHelp.cpp
@@ -8,7 +8,9 @@ void ShowHelpComponent::onConfigLoad()
if (!showHelp)
return;
fprintf(stdout, "Help\n");
- InstanceSet<Options>::OnAll(boost::bind(&ShowHelpComponent::outputOptions, this, _1));
+ for (auto opts : AdHoc::PluginManager::getDefault()->getAll<Options>()) {
+ outputOptions(opts->implementation());
+ }
exit(1);
}
@@ -27,5 +29,5 @@ ShowHelpComponent::Option()
}
bool ShowHelpComponent::showHelp;
-DECLARE_COMPONENT("ShowHelpComponent", ShowHelpComponent);
+NAMEDPLUGIN("ShowHelpComponent", ShowHelpComponent, LifeCycle);
diff --git a/project2/basics/options/showHelp.h b/project2/basics/options/showHelp.h
index 75fb4cb..c42a736 100644
--- a/project2/basics/options/showHelp.h
+++ b/project2/basics/options/showHelp.h
@@ -1,10 +1,10 @@
#ifndef SHOWHELP_H
#define SHOWHELP_H
-#include <componentLoader.h>
#include <options.h>
+#include <lifeCycle.h>
-class ShowHelpComponent : public ComponentLoader {
+class ShowHelpComponent : public LifeCycle {
public:
void onConfigLoad() override;
static Options::TargetPtr Option();
diff --git a/project2/basics/tasks/iterate.cpp b/project2/basics/tasks/iterate.cpp
index d2a767a..16224f6 100644
--- a/project2/basics/tasks/iterate.cpp
+++ b/project2/basics/tasks/iterate.cpp
@@ -4,14 +4,14 @@
#include <boost/bind.hpp>
#include "scriptLoader.h"
-DECLARE_LOADER("iterate", Iterate);
+NAMEDFACTORY("iterate", Iterate, TaskFactory);
Iterate::Iterate(ScriptNodePtr p) :
SourceObject(p),
IHaveSubTasks(p),
RowProcessor(p)
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&normal));
+ p->script->loader.addLoadTarget(p, Storer::into<TaskFactory>(&normal));
}
Iterate::~Iterate()
diff --git a/project2/basics/tasks/session/sessionClearTask.cpp b/project2/basics/tasks/session/sessionClearTask.cpp
index 8a21791..2b016be 100644
--- a/project2/basics/tasks/session/sessionClearTask.cpp
+++ b/project2/basics/tasks/session/sessionClearTask.cpp
@@ -4,7 +4,7 @@
#include "session.h"
#include "execContext.h"
-DECLARE_LOADER("sessionclear", SessionClearTask);
+NAMEDFACTORY("sessionclear", SessionClearTask, TaskFactory);
SessionClearTask::SessionClearTask(ScriptNodePtr p) :
SourceObject(p),
diff --git a/project2/basics/tasks/session/sessionSetTask.cpp b/project2/basics/tasks/session/sessionSetTask.cpp
index 120dd06..f009e46 100644
--- a/project2/basics/tasks/session/sessionSetTask.cpp
+++ b/project2/basics/tasks/session/sessionSetTask.cpp
@@ -4,7 +4,7 @@
#include "session.h"
#include "execContext.h"
-DECLARE_LOADER("sessionset", SessionSetTask);
+NAMEDFACTORY("sessionset", SessionSetTask, TaskFactory);
SessionSetTask::SessionSetTask(ScriptNodePtr p) :
SourceObject(p),
diff --git a/project2/basics/tasks/structExceptHandling.cpp b/project2/basics/tasks/structExceptHandling.cpp
index b79dae6..4e46466 100644
--- a/project2/basics/tasks/structExceptHandling.cpp
+++ b/project2/basics/tasks/structExceptHandling.cpp
@@ -3,16 +3,17 @@
#include "scriptLoader.h"
#include "scriptStorage.h"
#include "scripts.h"
+#include <task.h>
-DECLARE_LOADER("handler", StructuredExceptionHandler);
+NAMEDFACTORY("handler", StructuredExceptionHandler, TaskFactory);
StructuredExceptionHandler::StructuredExceptionHandler(ScriptNodePtr e) :
SourceObject(e),
IHaveSubTasks(e)
{
- e->script->loader.addLoadTargetSub(e, "try", true, Storer::into<ElementLoader>(&normal));
- e->script->loader.addLoadTargetSub(e, "catch", false, Storer::into<ElementLoader>(&catches));
- e->script->loader.addLoadTargetSub(e, "finally", false, Storer::into<ElementLoader>(&finallies));
+ e->script->loader.addLoadTargetSub(e, "try", true, Storer::into<TaskFactory>(&normal));
+ e->script->loader.addLoadTargetSub(e, "catch", false, Storer::into<TaskFactory>(&catches));
+ e->script->loader.addLoadTargetSub(e, "finally", false, Storer::into<TaskFactory>(&finallies));
}
void
diff --git a/project2/basics/tests/compoundTest.cpp b/project2/basics/tests/compoundTest.cpp
index 3799d06..88cff62 100644
--- a/project2/basics/tests/compoundTest.cpp
+++ b/project2/basics/tests/compoundTest.cpp
@@ -10,7 +10,7 @@ CompoundTest::CompoundTest(ScriptNodePtr s) :
SourceObject(s),
Test(s)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&tests));
+ s->script->loader.addLoadTarget(s, Storer::into<TestFactory>(&tests));
}
class All : public CompoundTest {
@@ -26,7 +26,7 @@ class All : public CompoundTest {
return (std::find_if(tests.begin(), tests.end(), !boost::bind(&Test::passes, _1, ec)) == tests.end());
}
};
-DECLARE_LOADER("all", All);
+NAMEDFACTORY("all", All, TestFactory);
class Any : public CompoundTest {
public:
@@ -41,7 +41,7 @@ class Any : public CompoundTest {
return (std::find_if(tests.begin(), tests.end(), boost::bind(&Test::passes, _1, ec)) != tests.end());
}
};
-DECLARE_LOADER("any", Any);
+NAMEDFACTORY("any", Any, TestFactory);
class None : public CompoundTest {
public:
@@ -56,7 +56,7 @@ class None : public CompoundTest {
return (std::find_if(tests.begin(), tests.end(), boost::bind(&Test::passes, _1, ec)) == tests.end());
}
};
-DECLARE_LOADER("none", None);
+NAMEDFACTORY("none", None, TestFactory);
class Not : public Test {
public:
@@ -64,7 +64,7 @@ class Not : public Test {
SourceObject(s),
Test(s)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&test));
+ s->script->loader.addLoadTarget(s, Storer::into<TestFactory>(&test));
}
bool passes(ExecContext * ec) const {
if (!test) {
@@ -75,4 +75,4 @@ class Not : public Test {
private:
TestPtr test;
};
-DECLARE_LOADER("not", Not);
+NAMEDFACTORY("not", Not, TestFactory);
diff --git a/project2/basics/tests/equals.cpp b/project2/basics/tests/equals.cpp
index 425d317..3f32053 100644
--- a/project2/basics/tests/equals.cpp
+++ b/project2/basics/tests/equals.cpp
@@ -16,9 +16,9 @@ class Equals : public Test {
bool passes(ExecContext * ec) const {
return (a(ec) == b(ec));
}
-
+
private:
Variable a, b;
};
-DECLARE_LOADER("equals", Equals);
+NAMEDFACTORY("equals", Equals, TestFactory);
diff --git a/project2/basics/tests/greaterthan.cpp b/project2/basics/tests/greaterthan.cpp
index b43cef1..01e5812 100644
--- a/project2/basics/tests/greaterthan.cpp
+++ b/project2/basics/tests/greaterthan.cpp
@@ -16,9 +16,9 @@ class GreaterThan : public Test {
bool passes(ExecContext * ec) const {
return (a(ec) > b(ec));
}
-
+
private:
Variable a, b;
};
-DECLARE_LOADER("greaterthan", GreaterThan);
+NAMEDFACTORY("greaterthan", GreaterThan, TestFactory);
diff --git a/project2/basics/tests/greaterthanorequal.cpp b/project2/basics/tests/greaterthanorequal.cpp
index 67328b2..f5f0124 100644
--- a/project2/basics/tests/greaterthanorequal.cpp
+++ b/project2/basics/tests/greaterthanorequal.cpp
@@ -16,9 +16,9 @@ class GreaterThanOrEqual : public Test {
bool passes(ExecContext * ec) const {
return (a(ec) >= b(ec));
}
-
+
private:
Variable a, b;
};
-DECLARE_LOADER("greaterthanorequal", GreaterThanOrEqual);
+NAMEDFACTORY("greaterthanorequal", GreaterThanOrEqual, TestFactory);
diff --git a/project2/basics/tests/isdistinct.cpp b/project2/basics/tests/isdistinct.cpp
index 47ed647..2c95535 100644
--- a/project2/basics/tests/isdistinct.cpp
+++ b/project2/basics/tests/isdistinct.cpp
@@ -37,4 +37,5 @@ class IsDistinct : public Test, IHaveParameters {
typedef std::set<Vars> Rows;
mutable Rows previous;
};
-DECLARE_LOADER("isdistinct", IsDistinct);
+NAMEDFACTORY("isdistinct", IsDistinct, TestFactory);
+
diff --git a/project2/basics/tests/isuniq.cpp b/project2/basics/tests/isuniq.cpp
index dc71ac5..295be40 100644
--- a/project2/basics/tests/isuniq.cpp
+++ b/project2/basics/tests/isuniq.cpp
@@ -45,4 +45,5 @@ class IsUniq : public Test, IHaveParameters {
typedef std::vector<VariableType> Vars;
mutable Vars previous;
};
-DECLARE_LOADER("isuniq", IsUniq);
+NAMEDFACTORY("isuniq", IsUniq, TestFactory);
+
diff --git a/project2/basics/tests/lessthan.cpp b/project2/basics/tests/lessthan.cpp
index f040532..3f172ef 100644
--- a/project2/basics/tests/lessthan.cpp
+++ b/project2/basics/tests/lessthan.cpp
@@ -16,9 +16,9 @@ class LessThan : public Test {
bool passes(ExecContext * ec) const {
return (a(ec) < b(ec));
}
-
+
private:
Variable a, b;
};
-DECLARE_LOADER("lessthan", LessThan);
+NAMEDFACTORY("lessthan", LessThan, TestFactory);
diff --git a/project2/basics/tests/lessthanorequal.cpp b/project2/basics/tests/lessthanorequal.cpp
index 1cb0e9e..8a64e01 100644
--- a/project2/basics/tests/lessthanorequal.cpp
+++ b/project2/basics/tests/lessthanorequal.cpp
@@ -16,9 +16,9 @@ class LessThanOrEqual : public Test {
bool passes(ExecContext * ec) const {
return (a(ec) <= b(ec));
}
-
+
private:
Variable a, b;
};
-DECLARE_LOADER("lessthanorequal", LessThanOrEqual);
+NAMEDFACTORY("lessthanorequal", LessThanOrEqual, TestFactory);
diff --git a/project2/basics/tests/notequals.cpp b/project2/basics/tests/notequals.cpp
index aeb784e..bbf3186 100644
--- a/project2/basics/tests/notequals.cpp
+++ b/project2/basics/tests/notequals.cpp
@@ -16,9 +16,9 @@ class NotEquals : public Test {
bool passes(ExecContext * ec) const {
return (a(ec) != b(ec));
}
-
+
private:
Variable a, b;
};
-DECLARE_LOADER("notequals", NotEquals);
+NAMEDFACTORY("notequals", NotEquals, TestFactory);
diff --git a/project2/basics/tests/validDateCheck.cpp b/project2/basics/tests/validDateCheck.cpp
index b1ab5a3..231a478 100644
--- a/project2/basics/tests/validDateCheck.cpp
+++ b/project2/basics/tests/validDateCheck.cpp
@@ -62,5 +62,5 @@ class ValidDateTest : public Test {
int warnLev;
};
-DECLARE_LOADER("validdatetest", ValidDateTest);
+NAMEDFACTORY("validdatetest", ValidDateTest, TestFactory);
diff --git a/project2/basics/unittests/dummylib.cpp b/project2/basics/unittests/dummylib.cpp
index 2e919a0..a493f3c 100644
--- a/project2/basics/unittests/dummylib.cpp
+++ b/project2/basics/unittests/dummylib.cpp
@@ -13,5 +13,5 @@ class DummyTask : public Task {
}
};
-DECLARE_LOADER("DummyTask", DummyTask);
+NAMEDFACTORY("DummyTask", DummyTask, TaskFactory);
diff --git a/project2/basics/unittests/testLibraries.cpp b/project2/basics/unittests/testLibraries.cpp
index 9b05166..7797694 100644
--- a/project2/basics/unittests/testLibraries.cpp
+++ b/project2/basics/unittests/testLibraries.cpp
@@ -4,6 +4,7 @@
#include <testOptionsSource.h>
#include <exceptions.h>
#include <library.h>
+#include <task.h>
#include <testAppInstance.h>
#define XSTR(s) STR(s)
@@ -24,18 +25,18 @@ BOOST_AUTO_TEST_CASE( load_missing_library )
BOOST_AUTO_TEST_CASE( load_and_unload_library )
{
- BOOST_REQUIRE_THROW(ElementLoader::getFor("DummyTask"), NotSupported);
+ BOOST_REQUIRE_THROW(TaskFactory::get("DummyTask"), AdHoc::NoSuchPluginException);
BOOST_TEST_CHECKPOINT("Configure (load)");
TestOptionsSource::LoadTestOptions({
{ "library", (root / "bin" / self.parent_path().parent_path().leaf() / self.parent_path().leaf() / "libdummylib.so").string() }
});
BOOST_TEST_CHECKPOINT("Verify");
- BOOST_REQUIRE(ElementLoader::getFor("DummyTask"));
+ BOOST_REQUIRE(TaskFactory::get("DummyTask"));
BOOST_TEST_CHECKPOINT("Configure (empty)");
TestOptionsSource::LoadTestOptions({ });
- BOOST_REQUIRE_THROW(ElementLoader::getFor("DummyTask"), NotSupported);
+ BOOST_REQUIRE_THROW(TaskFactory::get("DummyTask"), AdHoc::NoSuchPluginException);
}
BOOST_AUTO_TEST_SUITE_END();
diff --git a/project2/basics/views/autotree.cpp b/project2/basics/views/autotree.cpp
index 48cb643..bfeabee 100644
--- a/project2/basics/views/autotree.cpp
+++ b/project2/basics/views/autotree.cpp
@@ -4,7 +4,7 @@
#include "scriptLoader.h"
#include <boost/bind.hpp>
-DECLARE_LOADER("autotree", AutoTree);
+NAMEDFACTORY("autotree", AutoTree, ViewFactory);
AutoTree::AutoTree(ScriptNodePtr p) :
SourceObject(p),
diff --git a/project2/basics/views/flatView.cpp b/project2/basics/views/flatView.cpp
index ad13105..1ad2c68 100644
--- a/project2/basics/views/flatView.cpp
+++ b/project2/basics/views/flatView.cpp
@@ -3,8 +3,10 @@
#include "presenter.h"
#include "scriptLoader.h"
#include <boost/bind.hpp>
+#include <factory.impl.h>
-DECLARE_LOADER("flatview", FlatView);
+NAMEDFACTORY("flatview", FlatView, FlatViewFactory);
+INSTANTIATEFACTORY(FlatView, ScriptNodePtr);
FlatView::FlatView(ScriptNodePtr p) :
SourceObject(p),
diff --git a/project2/basics/views/flatView.h b/project2/basics/views/flatView.h
index 5dc24dc..3e7f9d2 100644
--- a/project2/basics/views/flatView.h
+++ b/project2/basics/views/flatView.h
@@ -23,6 +23,7 @@ class FlatView : public SourceObject, public RowProcessor {
typedef std::map<Glib::ustring, Variable> Columns;
Columns viewColumns;
};
+typedef AdHoc::Factory<FlatView, ScriptNodePtr> FlatViewFactory;
#endif
diff --git a/project2/basics/views/rowView.cpp b/project2/basics/views/rowView.cpp
index 8ec5417..a798688 100644
--- a/project2/basics/views/rowView.cpp
+++ b/project2/basics/views/rowView.cpp
@@ -5,7 +5,7 @@
#include <scopeExit.h>
#include <boost/bind.hpp>
-DECLARE_LOADER("view", RowView);
+NAMEDFACTORY("view", RowView, ViewFactory);
RowView::RowView(ScriptNodePtr p) :
SourceObject(p),
@@ -23,9 +23,9 @@ RowView::RowView(ScriptNodePtr p) :
viewColumns->insert(Columns::value_type(node->get_name(), Variable(node)));
}
}
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&subViews));
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&valueAggregates));
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&setAggregates));
+ p->script->loader.addLoadTarget(p, Storer::into<ViewFactory>(&subViews));
+ p->script->loader.addLoadTarget(p, Storer::into<ValueAggregateFactory>(&valueAggregates));
+ p->script->loader.addLoadTarget(p, Storer::into<SetAggregateFactory>(&setAggregates));
}
RowView::~RowView()
diff --git a/project2/basics/views/singleton.cpp b/project2/basics/views/singleton.cpp
index 29b32aa..15f2908 100644
--- a/project2/basics/views/singleton.cpp
+++ b/project2/basics/views/singleton.cpp
@@ -14,7 +14,7 @@ class Singleton : public View {
for (ScriptNodePtr node : p->childrenIn("columns")) {
viewColumns.insert(Columns::value_type(node->get_name(), Variable(node)));
}
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&subViews));
+ p->script->loader.addLoadTarget(p, Storer::into<ViewFactory>(&subViews));
}
void execute(const MultiRowSetPresenter * p, ExecContext * ec) const
{
@@ -40,5 +40,5 @@ class Singleton : public View {
typedef ANONSTORAGEOF(View) SubViews;
SubViews subViews;
};
-DECLARE_LOADER("singleton", Singleton);
+NAMEDFACTORY("singleton", Singleton, ViewFactory);
diff --git a/project2/basics/views/viewGroup.cpp b/project2/basics/views/viewGroup.cpp
index 0049e9d..8237e86 100644
--- a/project2/basics/views/viewGroup.cpp
+++ b/project2/basics/views/viewGroup.cpp
@@ -7,7 +7,7 @@ class ViewGroup : public View {
SourceObject(s),
View(s)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&subViews));
+ s->script->loader.addLoadTarget(s, Storer::into<ViewFactory>(&subViews));
}
void execute(const MultiRowSetPresenter * presenter, ExecContext * ec) const
@@ -23,4 +23,4 @@ class ViewGroup : public View {
SubViews subViews;
};
-DECLARE_LOADER("viewgroup", ViewGroup);
+NAMEDFACTORY("viewgroup", ViewGroup, ViewFactory);
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index c569617..a69fa9e 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -36,7 +36,7 @@ std::string CgiApplicationEngine::onErrorPresent;
std::string CgiApplicationEngine::defaultPresenter;
SessionContainerPtr CgiApplicationEngine::sessionsContainer;
std::string CgiApplicationEngine::sessionCookie;
-boost::shared_ptr<RouterLoader> CgiApplicationEngine::router;
+const RouterFactory * CgiApplicationEngine::router;
CgiApplicationEngine::PlatformHostnameList CgiApplicationEngine::platHosts;
class PlatformHostnameTarget : public Options::Target {
@@ -86,13 +86,13 @@ DECLARE_OPTIONS(CgiApplicationEngine, "Project2 CGI options")
"The present script to use when the requested script (or child) fails")
("cgi.dumpDataDoc", Options::value(&dumpdatadoc),
"Write a copy of the data document before sending it to the web server")
-("cgi.sessionModule", Options::function([](const VariableType & m) { sessionsContainer = SessionContainerLoader::createNew(m); }, "xml"),
+("cgi.sessionModule", Options::function([](const VariableType & m) { sessionsContainer = SessionContainerFactory::createNew(m); }, "xml"),
"The module with which to implement session management")
("cgi.sessionCookie", Options::value(&sessionCookie, "sessionID"),
"The name of the cookie for storing session IDs")
("cgi.hostRegex", new PlatformHostnameTarget(),
"Regular expression used to define a hostname -> platform association")
-("cgi.router", Options::function([](const VariableType & r) { router = RouterLoader::getFor(r); }, "simple"),
+("cgi.router", Options::function([](const VariableType & r) { router = RouterFactory::get(r); }, "simple"),
"Implemenation of router model to map request paths to scripts")
END_OPTIONS(CgiApplicationEngine);
@@ -318,7 +318,7 @@ CgiApplicationEngine::process(std::ostream & IO, cgicc::CgiInput * cgii, const C
boost::function<std::string()> sn = boost::bind(&CgiEnvInput::getenv, &cgienv, "SERVER_NAME");
OptionsSource::loadSources(boost::bind(&CgiApplicationEngine::derivedPlatform, sn));
CgiRequestContext crc(cgii, cgienv);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onBefore, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onBefore, _1));
Logger()->messagebf(LOG_DEBUG, "%s: Processing request (%s)", __FUNCTION__, crc.getRedirectURL());
process(IO, &crc);
Logger()->messagef(LOG_DEBUG, "%s: Completed request", __FUNCTION__);
diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h
index d964d07..d8271b5 100644
--- a/project2/cgi/cgiAppEngine.h
+++ b/project2/cgi/cgiAppEngine.h
@@ -161,7 +161,7 @@ class CgiApplicationEngine : AppInstance {
INITOPTIONS;
static PlatformHostnameList platHosts;
- static boost::shared_ptr<RouterLoader> router;
+ static const RouterFactory * router;
static SessionContainerPtr sessionsContainer;
static std::string sessionCookie;
private:
diff --git a/project2/cgi/cgiContentNegotiate.cpp b/project2/cgi/cgiContentNegotiate.cpp
index 2494ba8..0d1bbaf 100644
--- a/project2/cgi/cgiContentNegotiate.cpp
+++ b/project2/cgi/cgiContentNegotiate.cpp
@@ -3,7 +3,7 @@
#include <boost/tokenizer.hpp>
#include <boost/bind.hpp>
-class ContentNegotiateLoader : public PresenterLoader {
+class ContentNegotiateFactory : public PresenterFactory {
public:
MultiRowSetPresenter * create(const ScriptNodePtr & s, const ObjectSource & os, ExecContext * const & ec) const
{
@@ -14,11 +14,11 @@ class ContentNegotiateLoader : public PresenterLoader {
if (mimetype == "*/*") break;
for (const auto & t : mappedTypes) {
if (t->Matches(mimetype)) {
- return PresenterLoader::getFor(t->present)->create(s, os, ec);
+ return PresenterFactory::createNew(t->present, s, os, ec);
}
}
}
- return PresenterLoader::getFor((*mappedTypes.begin())->present)->create(s, os, ec);
+ return PresenterFactory::createNew((*mappedTypes.begin())->present, s, os, ec);
}
INITOPTIONS;
@@ -44,14 +44,14 @@ class ContentNegotiateLoader : public PresenterLoader {
bool cacheable() const { return false; }
};
-ContentNegotiateLoader::MappedTypes ContentNegotiateLoader::mappedTypes;
+ContentNegotiateFactory::MappedTypes ContentNegotiateFactory::mappedTypes;
-DECLARE_CUSTOM_COMPONENT_LOADER("contentnegotiate", ContentNegotiateLoader, ContentNegotiateLoader, PresenterLoader);
+NAMEDPLUGIN("contentnegotiate", ContentNegotiateFactory, PresenterFactory);
-DECLARE_OPTIONS(ContentNegotiateLoader, "Content negotiation options")
+DECLARE_OPTIONS(ContentNegotiateFactory, "Content negotiation options")
("cgi.contentnegotiation.mappedtype", Options::functions(
[](const VariableType & v) { mappedTypes.push_back(new MappedType(v)); },
boost::bind(&MappedTypes::clear, &mappedTypes)),
"mimetype=presenter list of types to negotiate")
-END_OPTIONS(ContentNegotiateLoader)
+END_OPTIONS(ContentNegotiateFactory)
diff --git a/project2/cgi/cgiOutputOptions.cpp b/project2/cgi/cgiOutputOptions.cpp
index de3d291..07dbf79 100644
--- a/project2/cgi/cgiOutputOptions.cpp
+++ b/project2/cgi/cgiOutputOptions.cpp
@@ -1,6 +1,6 @@
#include "cgiOutputOptions.h"
#include "scripts.h"
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
bool OutputOptions::core;
bool OutputOptions::session;
@@ -21,7 +21,7 @@ OutputOptions::OutputOptions(ScriptNodePtr p) :
{
}
-DECLARE_OPTIONS(OutputOptionsLoader, "CGI default output options")
+DECLARE_OPTIONS(OutputOptions, "CGI default output options")
("cgi.output.encoding", Options::value(&OutputOptions::encoding, "utf-8"), "Default out encoding")
("cgi.output.core", Options::value(&OutputOptions::core, true), "Core messages")
("cgi.output.session", Options::value(&OutputOptions::session, true), "Session values")
@@ -29,13 +29,8 @@ DECLARE_OPTIONS(OutputOptionsLoader, "CGI default output options")
("cgi.output.environment", Options::value(&OutputOptions::environment, true), "Environment")
("cgi.output.url", Options::value(&OutputOptions::url, true), "URL breakdown")
("cgi.output.parameters", Options::value(&OutputOptions::parameters, true), "Parameters")
-END_OPTIONS(OutputOptionsLoader)
+END_OPTIONS(OutputOptions)
-OutputOptionsPtr
-OutputOptionsLoader::create(ScriptNodePtr e) const {
- return new OutputOptions(e);
-}
-
-DECLARE_CUSTOM_COMPONENT_LOADER("outputoptions", OutputOptions, OutputOptionsLoader, OutputOptionsLoader)
-INSTANTIATESTORE(std::string, OutputOptionsLoader);
+NAMEDFACTORY("outputoptions", OutputOptions, OutputOptionsFactory)
+INSTANTIATEFACTORY(OutputOptions, ScriptNodePtr);
diff --git a/project2/cgi/cgiOutputOptions.h b/project2/cgi/cgiOutputOptions.h
index be2c452..6c40388 100644
--- a/project2/cgi/cgiOutputOptions.h
+++ b/project2/cgi/cgiOutputOptions.h
@@ -17,8 +17,9 @@ class OutputOptions : public IntrusivePtrBase {
const Variable URL;
const Variable Parameters;
+ INITOPTIONS;
+
// defaults
- friend class OutputOptionsLoader;
static std::string encoding;
private:
static bool core;
@@ -29,13 +30,6 @@ class OutputOptions : public IntrusivePtrBase {
static bool parameters;
};
typedef boost::intrusive_ptr<OutputOptions> OutputOptionsPtr;
-
-class OutputOptionsLoader : public ComponentLoader {
- public:
- typedef std::string KeyType;
-
- OutputOptionsPtr create(ScriptNodePtr e) const;
- INITOPTIONS;
-};
+typedef AdHoc::Factory<OutputOptions, ScriptNodePtr> OutputOptionsFactory;
#endif
diff --git a/project2/cgi/cgiProgRouter.cpp b/project2/cgi/cgiProgRouter.cpp
index 3e84637..2b72652 100644
--- a/project2/cgi/cgiProgRouter.cpp
+++ b/project2/cgi/cgiProgRouter.cpp
@@ -9,11 +9,15 @@
#include "scriptStorage.h"
#include "rowSet.h"
#include "exceptions.h"
+#include <factory.impl.h>
typedef std::map<std::string, std::string> VarMap;
class RoutingTable {
public:
+ class Route;
+ typedef AdHoc::Factory<RoutingTable::Route, ScriptNodePtr> RouteFactory;
+
void loadRoutesFromFile(const std::string & routeFile) {
routeScriptPath = routeFile;
if (routeFile.empty()) {
@@ -38,7 +42,7 @@ class RoutingTable {
void setRouteScript()
{
routeScript = ScriptReader::resolveScript(CommonObjects::datasourceRoot, routeScriptPath, true);
- routeScript->loader.addLoadTarget(routeScript->root(), Storer::into<ElementLoader>(&routes));
+ routeScript->loader.addLoadTarget(routeScript->root(), Storer::into<RouteFactory>(&routes));
routes.clear();
routeScript->load(NULL, true);
}
@@ -79,7 +83,7 @@ class RoutingTable {
}
const std::string variable;
};
-
+
class Route : public SourceObject {
public:
Route(ScriptNodePtr s) :
@@ -123,13 +127,12 @@ class RoutingTable {
std::list<RoutePtr> routes;
};
-typedef RoutingTable::Route Route;
-DECLARE_LOADER("route", Route);
+NAMEDFACTORY("route", RoutingTable::Route, RoutingTable::RouteFactory);
class ProgRouter;
-class ProgRouterLoader : public RouterLoader::For<ProgRouter> {
+class ProgRouterFactory : public RouterFactory::For<ProgRouter>, public LifeCycle {
public:
- void onBefore()
+ void onBefore() override
{
routingTable.onBefore();
}
@@ -139,14 +142,14 @@ class ProgRouterLoader : public RouterLoader::For<ProgRouter> {
INITOPTIONS;
};
-RoutingTable ProgRouterLoader::routingTable;
+RoutingTable ProgRouterFactory::routingTable;
-DECLARE_OPTIONS(ProgRouterLoader, "CGI Programmable Router options")
+DECLARE_OPTIONS(ProgRouterFactory, "CGI Programmable Router options")
("cgi.progRouter.routes", Options::functions(
boost::bind(&RoutingTable::loadRoutesFromFile, &routingTable, _1),
boost::bind(&RoutingTable::clearRoutes, &routingTable)),
"Script file defining web service routes")
-END_OPTIONS(ProgRouterLoader);
+END_OPTIONS(ProgRouterFactory);
SimpleMessageException(UriElementNotFound);
@@ -156,7 +159,7 @@ class ProgRouter : public Router {
path(p) {
}
std::string route() const {
- return ProgRouterLoader::routingTable.present(path, vars);
+ return ProgRouterFactory::routingTable.present(path, vars);
}
bool isDefault() const {
return false;
@@ -189,7 +192,7 @@ class ProgRouter : public Router {
mutable VarMap vars;
};
-DECLARE_CUSTOM_COMPONENT_LOADER("progRouter", ProgRouter, ProgRouterLoader, RouterLoader);
+NAMEDPLUGIN("progRouter", ProgRouterFactory, RouterFactory);
class Routes : public RowSet {
public:
@@ -209,7 +212,7 @@ class Routes : public RowSet {
void execute(const Glib::ustring & filter, const RowProcessorCallback & rp, ExecContext *) const
{
RouteRowState rs;
- for (const auto & r : ProgRouterLoader::routingTable.routes) {
+ for (const auto & r : ProgRouterFactory::routingTable.routes) {
if (boost::algorithm::starts_with(r->path, filter)) {
rs.fields[0] = VariableType(r->present);
rs.fields[1] = VariableType(r->path);
@@ -219,5 +222,6 @@ class Routes : public RowSet {
}
};
-DECLARE_LOADER("routes", Routes);
+NAMEDFACTORY("routes", Routes, RowSetFactory);
+INSTANTIATEFACTORY(RoutingTable::Route, ScriptNodePtr);
diff --git a/project2/cgi/cgiRequestContext.cpp b/project2/cgi/cgiRequestContext.cpp
index 636d2f6..24de206 100644
--- a/project2/cgi/cgiRequestContext.cpp
+++ b/project2/cgi/cgiRequestContext.cpp
@@ -13,7 +13,7 @@
CgiRequestContext::CgiRequestContext(cgicc::CgiInput * i, const CgiEnvInput & e) :
cgi(i),
- router(boost::bind(&RouterLoader::create, boost::cref(CgiApplicationEngine::router), getRedirectURL())),
+ router(boost::bind(&RouterFactory::create, boost::cref(CgiApplicationEngine::router), getRedirectURL())),
cgienv(e),
session(boost::bind(&CgiRequestContext::getSessionInternal, this))
{
diff --git a/project2/cgi/cgiRequestID.cpp b/project2/cgi/cgiRequestID.cpp
index 038fff5..88c212c 100644
--- a/project2/cgi/cgiRequestID.cpp
+++ b/project2/cgi/cgiRequestID.cpp
@@ -50,6 +50,5 @@ class CgiRequestID : public VariableImplDyn {
return hashstr.str();
}
};
-DECLARE_COMPONENT_LOADER("requestid", CgiRequestID, VariableLoader);
-
+NAMEDFACTORY("requestid", CgiRequestID, VariableFactory);
diff --git a/project2/cgi/cgiRouter.cpp b/project2/cgi/cgiRouter.cpp
index dc77c40..ebf8eb0 100644
--- a/project2/cgi/cgiRouter.cpp
+++ b/project2/cgi/cgiRouter.cpp
@@ -1,5 +1,5 @@
#include "cgiRouter.h"
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
-INSTANTIATESTORE(std::string, RouterLoader);
+INSTANTIATEFACTORY(Router, const std::string &);
diff --git a/project2/cgi/cgiRouter.h b/project2/cgi/cgiRouter.h
index 9e9c621..bc4ce44 100644
--- a/project2/cgi/cgiRouter.h
+++ b/project2/cgi/cgiRouter.h
@@ -3,6 +3,7 @@
#include <variables.h>
#include <scriptLoader.h>
+#include <factory.h>
class MultiRowSetPresenter;
@@ -15,7 +16,7 @@ class Router : public IntrusivePtrBase {
virtual void present(const MultiRowSetPresenter * p) const = 0;
};
typedef boost::intrusive_ptr<Router> RouterPtr;
-typedef GenLoader<Router, std::string, const std::string &> RouterLoader;
+typedef AdHoc::Factory<Router, const std::string &> RouterFactory;
#endif
diff --git a/project2/cgi/cgiSimpleRouter.cpp b/project2/cgi/cgiSimpleRouter.cpp
index b67848e..bc8c544 100644
--- a/project2/cgi/cgiSimpleRouter.cpp
+++ b/project2/cgi/cgiSimpleRouter.cpp
@@ -54,5 +54,5 @@ class SimpleRouter : public Router {
std::vector<std::string> elems;
};
-DECLARE_GENERIC_LOADER("simple", RouterLoader, SimpleRouter);
+NAMEDFACTORY("simple", SimpleRouter, RouterFactory);
diff --git a/project2/cgi/cgiStageDefaultError.cpp b/project2/cgi/cgiStageDefaultError.cpp
index d230a21..e5d1b9f 100644
--- a/project2/cgi/cgiStageDefaultError.cpp
+++ b/project2/cgi/cgiStageDefaultError.cpp
@@ -16,7 +16,7 @@ CgiApplicationEngine::DefaultErrorStage::DefaultErrorStage(const std::exception
auto xp = dynamic_cast<TransformSource *>(pres.get());
auto cp = dynamic_cast<ContentPresenter *>(pres.get());
if (xp && cp && cp->contentType == CgiApplicationEngine::transformContentType) {
- auto h = TransformTargetLoader::getFor(CgiApplicationEngine::transformTargetType)->create(root, Default);
+ auto h = TransformTargetFactory::createNew(CgiApplicationEngine::transformTargetType, root, Default);
xp->addTarget(h, crc, root);
}
}
diff --git a/project2/cgi/cgiStageFail.cpp b/project2/cgi/cgiStageFail.cpp
index 461c8a7..e96f14f 100644
--- a/project2/cgi/cgiStageFail.cpp
+++ b/project2/cgi/cgiStageFail.cpp
@@ -46,6 +46,5 @@ namespace CgiApplicationExtras {
};
}
-typedef CgiApplicationExtras::CgiFail cgif;
-DECLARE_LOADER("cgifail", cgif);
+NAMEDFACTORY("cgifail", CgiApplicationExtras::CgiFail, ViewFactory);
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index 5e33df3..dffc98e 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -11,19 +11,19 @@ CgiApplicationEngine::PresentStage::PresentStage(ScriptReaderPtr s, CgiRequestCo
CheckHost(s->root()),
ViewHost(s->root()),
presenter([this, crc] {
- auto p = PresenterLoader::getFor(CgiApplicationEngine::defaultPresenter)->create(root, Default, crc);
+ auto p = PresenterFactory::createNew(CgiApplicationEngine::defaultPresenter, root, Default, crc);
auto xp = dynamic_cast<TransformSource *>(p);
auto cp = dynamic_cast<ContentPresenter *>(p);
if (xp && cp && cp->contentType == CgiApplicationEngine::transformContentType) {
- auto h = TransformTargetLoader::getFor(CgiApplicationEngine::transformTargetType)->create(root, Default);
+ auto h = TransformTargetFactory::createNew(CgiApplicationEngine::transformTargetType, root, Default);
xp->addTarget(h, crc, root);
}
return p;
})
{
- s->loader.addLoadTarget(s->root(), Storer::into<OutputOptionsLoader>(&outputOptions));
- s->loader.addLoadTarget(s->root(), Storer::into<PresenterLoader>(&presenter, Scripted, crc));
- s->loader.addLoadTarget(s->root(), Storer::into<ElementLoader>(&caches));
+ s->loader.addLoadTarget(s->root(), Storer::into<OutputOptionsFactory>(&outputOptions));
+ s->loader.addLoadTarget(s->root(), Storer::into<PresenterFactory>(&presenter, Scripted, crc));
+ s->loader.addLoadTarget(s->root(), Storer::into<PresenterCacheFactory>(&caches));
}
CgiApplicationEngine::NextStage
diff --git a/project2/cgi/cgiStageRedirect.cpp b/project2/cgi/cgiStageRedirect.cpp
index d6fee08..18de9f9 100644
--- a/project2/cgi/cgiStageRedirect.cpp
+++ b/project2/cgi/cgiStageRedirect.cpp
@@ -42,5 +42,5 @@ namespace CgiApplicationExtras {
};
}
-typedef CgiApplicationExtras::CgiRedirect cgird;
-DECLARE_LOADER("cgiredirect", cgird);
+NAMEDFACTORY("cgiredirect", CgiApplicationExtras::CgiRedirect, ViewFactory);
+
diff --git a/project2/cgi/cgiUriParam.cpp b/project2/cgi/cgiUriParam.cpp
index 985048d..edce6f8 100644
--- a/project2/cgi/cgiUriParam.cpp
+++ b/project2/cgi/cgiUriParam.cpp
@@ -27,5 +27,5 @@ class VariableUri : public VariableImplDyn {
private:
Variable index;
};
-DECLARE_COMPONENT_LOADER("uri", VariableUri, VariableLoader);
+NAMEDFACTORY("uri", VariableUri, VariableFactory);
diff --git a/project2/cgi/p2webCgi.cpp b/project2/cgi/p2webCgi.cpp
index a4e2328..33e1b8b 100644
--- a/project2/cgi/p2webCgi.cpp
+++ b/project2/cgi/p2webCgi.cpp
@@ -14,12 +14,12 @@ class GetEnv : public CgiEnvInput {
int
main(void)
{
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onBegin, _1));
CgiApplicationEngine app;
GetEnv ge;
app.process(std::cout, NULL, ge);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1));
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1));
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIteration, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onPeriodic, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIdle, _1));
}
diff --git a/project2/cgi/p2webFCgi.cpp b/project2/cgi/p2webFCgi.cpp
index 42a99bc..fae6cca 100644
--- a/project2/cgi/p2webFCgi.cpp
+++ b/project2/cgi/p2webFCgi.cpp
@@ -11,7 +11,7 @@ void
p2webPeriodic()
{
time(&lastPeriodic);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onPeriodic, _1));
}
static
@@ -21,7 +21,7 @@ p2webGoingIdle(int)
if (time(NULL) > lastPeriodic + periodicDelay) {
p2webPeriodic();
}
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIdle, _1));
}
int
@@ -40,7 +40,7 @@ main(void)
fprintf(stderr, "Failed to set signal handler\n");
}
alarm(60);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onBegin, _1));
CgiApplicationEngine app;
while (FCGX_Accept_r(&request) == 0) {
alarm(0);
@@ -48,7 +48,7 @@ main(void)
boost::filesystem::current_path(boost::filesystem::initial_path());
app.process(IO, &IO, IO);
FCGX_Finish_r(&request);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIteration, _1));
if (time(NULL) > lastPeriodic + periodicDelay) {
p2webPeriodic();
}
diff --git a/project2/cgi/pch.hpp b/project2/cgi/pch.hpp
index 065558b..125c912 100644
--- a/project2/cgi/pch.hpp
+++ b/project2/cgi/pch.hpp
@@ -2,11 +2,9 @@
#ifndef CGI_PCH
#define CGI_PCH
-#include "cgiRequestContext.h"
-#include "cgiHttpHeader.h"
-#include "scriptLoader.h"
+#include <boost/tuple/tuple.hpp>
+#include <boost/variant/variant_fwd.hpp>
#include <boost/bind.hpp>
-#include "options.h"
#include <cgicc/CgiEnvironment.h>
#include <cgicc/Cgicc.h>
#include <cgicc/HTTPContentHeader.h>
diff --git a/project2/cgi/testCgi.cpp b/project2/cgi/testCgi.cpp
index 4ab13d1..7f9df28 100644
--- a/project2/cgi/testCgi.cpp
+++ b/project2/cgi/testCgi.cpp
@@ -16,7 +16,9 @@ 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 Options::CurrentPlatform & cp) const {
- InstanceSet<Options>::OnAll(boost::bind(&Options::consume, _1, n, p, v, cp));
+ for (auto opts : AdHoc::PluginManager::getDefault()->getAll<Options>()) {
+ opts->implementation()->consume(n, p, v, cp);
+ }
}
const Options::Option * get(const Glib::ustring &) const {
return NULL;
@@ -27,14 +29,14 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput {
typedef std::map<std::string, StrPtr> OptStore;
TestInput(int argc, char ** argv)
{
- OptionsSources::Add("_1", new FileOptions(".testCgi.settings"));
- OptionsSources::Add("_2", new CommandLineArguments(argc, argv,
- [](const char * url) { urls.push_back(url); }));
+ AdHoc::PluginManager::getDefault()->add<OptionsSource>(new FileOptions(".testCgi.settings"), "_1", __FILE__, __LINE__);
+ AdHoc::PluginManager::getDefault()->add<OptionsSource>(
+ new CommandLineArguments(argc, argv, [](const char * url) { urls.push_back(url); }), "_2", __FILE__, __LINE__);
}
~TestInput()
{
- OptionsSources::Remove("_1");
- OptionsSources::Remove("_2");
+ AdHoc::PluginManager::getDefault()->remove<OptionsSource>("_1");
+ AdHoc::PluginManager::getDefault()->remove<OptionsSource>("_2");
}
std::string getenv(const std::string & varName) const
@@ -49,7 +51,7 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput {
}
void run()
{
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onBegin, _1));
CgiApplicationEngine app;
boost::function<std::string()> sn = boost::bind(&CgiEnvInput::getenv, this, "SERVER_NAME");
OptionsSource::loadSources(boost::bind(&CgiApplicationEngine::derivedPlatform, sn));
@@ -77,11 +79,11 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput {
optStore()["QUERY_STRING"] = StrPtr(new std::string());
}
app.process(std::cout, this, *this);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIteration, _1));
}
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onPeriodic, _1));
}
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIdle, _1));
}
INITOPTIONS;
diff --git a/project2/common/Jamfile.jam b/project2/common/Jamfile.jam
index 775d61c..5b6ad69 100644
--- a/project2/common/Jamfile.jam
+++ b/project2/common/Jamfile.jam
@@ -16,7 +16,7 @@ cpp-pch pch : pch.hpp :
lib p2common :
pch
- [ glob-tree *.cpp : unittests ]
+ [ glob-tree *.cpp : unittests library.cpp ]
:
<include>.
<library>glibmm
diff --git a/project2/common/aggregate.cpp b/project2/common/aggregate.cpp
index ee7c871..f00f7dc 100644
--- a/project2/common/aggregate.cpp
+++ b/project2/common/aggregate.cpp
@@ -1,4 +1,5 @@
#include "aggregate.h"
+#include <factory.impl.h>
Aggregate::Aggregate(ScriptNodePtr s) :
SourceObject(s),
@@ -22,3 +23,6 @@ Aggregate::pushValue(ExecContext * ec) const
pushValue(value(ec), ec);
}
+INSTANTIATEFACTORY(ValueAggregate, ScriptNodePtr);
+INSTANTIATEFACTORY(SetAggregate, ScriptNodePtr);
+
diff --git a/project2/common/aggregate.h b/project2/common/aggregate.h
index 7f33b6b..a2ad54d 100644
--- a/project2/common/aggregate.h
+++ b/project2/common/aggregate.h
@@ -24,6 +24,7 @@ class ValueAggregate : public Aggregate {
virtual VariableType resultValue() const = 0;
};
typedef boost::intrusive_ptr<const ValueAggregate> ValueAggregateCPtr;
+typedef AdHoc::Factory<ValueAggregate, ScriptNodePtr> ValueAggregateFactory;
class SetAggregate : public Aggregate {
public:
@@ -33,5 +34,6 @@ class SetAggregate : public Aggregate {
virtual void onResultValues(const UseAgg &) const = 0;
};
typedef boost::intrusive_ptr<const SetAggregate> SetAggregateCPtr;
+typedef AdHoc::Factory<SetAggregate, ScriptNodePtr> SetAggregateFactory;
#endif
diff --git a/project2/common/check.cpp b/project2/common/check.cpp
index d288e2f..703a3ea 100644
--- a/project2/common/check.cpp
+++ b/project2/common/check.cpp
@@ -2,8 +2,9 @@
#include "check.h"
#include "scriptLoader.h"
#include "scriptStorage.h"
+#include <factory.impl.h>
-DECLARE_LOADER("check", Check);
+NAMEDFACTORY("check", Check, CheckFactory);
StaticMessageException(NoTestsToPerform, "No tests to perform");
Check::Check(ScriptNodePtr p) :
@@ -12,7 +13,7 @@ Check::Check(ScriptNodePtr p) :
group(p, "group", "default"),
present(p, "present", "")
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&test));
+ p->script->loader.addLoadTarget(p, Storer::into<TestFactory>(&test));
}
Check::~Check()
@@ -28,3 +29,5 @@ Check::performCheck(ExecContext * ec) const
return test->passes(ec);
}
+INSTANTIATEFACTORY(Check, ScriptNodePtr);
+
diff --git a/project2/common/check.h b/project2/common/check.h
index dc97f8f..d108f7c 100644
--- a/project2/common/check.h
+++ b/project2/common/check.h
@@ -21,6 +21,7 @@ class Check : public SourceObject {
TestPtr test;
};
typedef boost::intrusive_ptr<const Check> CheckCPtr;
+typedef AdHoc::Factory<Check, ScriptNodePtr> CheckFactory;
#endif
diff --git a/project2/common/checkHost.cpp b/project2/common/checkHost.cpp
index a900d7a..eb2bae7 100644
--- a/project2/common/checkHost.cpp
+++ b/project2/common/checkHost.cpp
@@ -5,7 +5,7 @@
CheckHost::CheckHost(ScriptNodePtr s) :
CommonObjects(s)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&checks));
+ s->script->loader.addLoadTarget(s, Storer::into<CheckFactory>(&checks));
}
CheckHost::~CheckHost()
diff --git a/project2/common/commonObjects.cpp b/project2/common/commonObjects.cpp
index 3ffa47f..a2f7d0f 100644
--- a/project2/common/commonObjects.cpp
+++ b/project2/common/commonObjects.cpp
@@ -19,7 +19,7 @@ CommonObjects::CommonObjects(ScriptNodePtr s) :
script(s->script),
scriptLoaded(false)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&rowSets));
+ s->script->loader.addLoadTarget(s, Storer::into<RowSetFactory>(&rowSets));
}
CommonObjects::~CommonObjects()
@@ -36,7 +36,7 @@ CommonObjects::DataSources::const_iterator
CommonObjects::loadDataSource(const std::string & name) const
{
ScriptReaderPtr dbs = ScriptReader::resolveScript(datasourceRoot, name, true);
- dbs->loader.addLoadTarget(dbs->root(), Storer::into<ElementLoader>(&datasources));
+ dbs->loader.addLoadTarget(dbs->root(), Storer::into<DataSourceFactory>(&datasources));
dbs->load(NULL, false);
return AdHoc::safeMapFind<DataSourceNotFound>(datasources, name);
}
diff --git a/project2/common/componentLoader.cpp b/project2/common/componentLoader.cpp
deleted file mode 100644
index 56eb833..0000000
--- a/project2/common/componentLoader.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#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/dataSource.cpp b/project2/common/dataSource.cpp
index b5760c5..5b23c9a 100644
--- a/project2/common/dataSource.cpp
+++ b/project2/common/dataSource.cpp
@@ -1,9 +1,12 @@
#include <pch.hpp>
#include "dataSource.h"
#include "scripts.h"
+#include <factory.impl.h>
DataSource::DataSource(ScriptNodePtr p) :
SourceObject(p)
{
}
+INSTANTIATEFACTORY(DataSource, ScriptNodePtr);
+
diff --git a/project2/common/dataSource.h b/project2/common/dataSource.h
index bd7170f..c60cceb 100644
--- a/project2/common/dataSource.h
+++ b/project2/common/dataSource.h
@@ -17,6 +17,7 @@ class DataSource : public SourceObject {
virtual void commit() { };
virtual void rollback() { };
};
+typedef AdHoc::Factory<DataSource, ScriptNodePtr> DataSourceFactory;
#endif
diff --git a/project2/common/genLoader.h b/project2/common/genLoader.h
deleted file mode 100644
index 2e4300b..0000000
--- a/project2/common/genLoader.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef GENLOADER_H
-#define GENLOADER_H
-
-#include "componentLoader.h"
-#include "plugable.h"
-
-template <class Impl, class Key, typename... Params>
-class GenLoader : public ComponentLoader {
- public:
- typedef Key KeyType;
- typedef GenLoader<Impl, KeyType, Params...> Self;
-
- template <class T, class BaseLoader = Self>
- class For : public BaseLoader {
- public:
- inline Impl * create(const Params & ... p) const
- {
- return new T(p...);
- }
- };
-
- virtual Impl * create(const Params & ...) const = 0;
-
- template <class E = NotSupported>
- inline static Impl * createNew(const KeyType & n, const Params & ... p)
- {
- return InstanceMap<Self, KeyType>::template Get<E>(n)->create(p...);
- }
-
- template <class E = NotSupported>
- inline static boost::shared_ptr<Self> getFor(const KeyType & n)
- {
- return InstanceMap<Self, KeyType>::template Get<E>(n);
- }
-};
-
-#endif
-
diff --git a/project2/common/iHaveSubTasks.cpp b/project2/common/iHaveSubTasks.cpp
index 6371475..578601f 100644
--- a/project2/common/iHaveSubTasks.cpp
+++ b/project2/common/iHaveSubTasks.cpp
@@ -3,7 +3,7 @@
IHaveSubTasks::IHaveSubTasks(ScriptNodePtr e) :
SourceObject(e),
- NoOutputExecute(e)
+ Task(e)
{
}
diff --git a/project2/common/iHaveSubTasks.h b/project2/common/iHaveSubTasks.h
index 3e7d16c..1fd5041 100644
--- a/project2/common/iHaveSubTasks.h
+++ b/project2/common/iHaveSubTasks.h
@@ -1,12 +1,13 @@
#ifndef HASSUBTASKS_H
#define HASSUBTASKS_H
-#include "noOutputExecute.h"
+#include "task.h"
+#include "scriptStorage.h"
/// Base class for Project2 compoments that perform actions, but product no output
-class IHaveSubTasks : public NoOutputExecute {
+class IHaveSubTasks : public Task {
public:
- typedef ANONORDEREDSTORAGEOF(NoOutputExecute) Tasks;
+ typedef ANONORDEREDSTORAGEOF(Task) Tasks;
IHaveSubTasks(ScriptNodePtr p);
virtual ~IHaveSubTasks();
diff --git a/project2/common/instanceStore.h b/project2/common/instanceStore.h
deleted file mode 100644
index 4fd4519..0000000
--- a/project2/common/instanceStore.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef INSTANCESTORE_H
-#define INSTANCESTORE_H
-
-#include <boost/function.hpp>
-#include <set>
-#include <map>
-#include <safeMapFind.h>
-
-/// A static collection of any type, specifically with automatically cleaned up storage of a function static variable
-// which makes it safe to use in constructor functions.
-template <class Type, class StoreType>
-class InstanceStore {
- public:
- static const StoreType & GetAll();
- static void Add(const typename StoreType::value_type & p);
-
- protected:
- static void prune();
- static StoreType * & getInstances();
-};
-
-/// Keyed collection of instances
-template <class Type, class KeyType>
-class InstanceMap : public InstanceStore<Type, std::map<KeyType, boost::shared_ptr<Type>>> {
- public:
- typedef std::map<KeyType, boost::shared_ptr<Type>> Store;
- typedef InstanceStore<Type, std::map<KeyType, boost::shared_ptr<Type>>> IStore;
- typedef typename Store::value_type Value;
-
- static void Add(const KeyType & k, Type * p);
- static void Add(const KeyType & k, const boost::shared_ptr<Type> & p);
- static void Remove(const KeyType &);
-
- template <class E> static boost::shared_ptr<Type> Get(const KeyType & n)
- {
- return AdHoc::safeMapLookup<E>(InstanceStore<Type, Store>::GetAll(), n);
- }
-
- static void OnEach(const boost::function<void(const Value &)> & func);
-};
-
-/// Anonymous collection of instances
-template <class Type>
-class InstanceSet : public InstanceStore<Type, std::set<boost::shared_ptr<Type>>> {
- public:
- typedef InstanceStore<Type, std::set<boost::shared_ptr<Type>>> IStore;
- static void OnAll(const boost::function<void(Type *)> & func);
- static void Remove(const boost::shared_ptr<Type> &);
-};
-
-#endif
-
diff --git a/project2/common/instanceStore.impl.h b/project2/common/instanceStore.impl.h
deleted file mode 100644
index 2a2f497..0000000
--- a/project2/common/instanceStore.impl.h
+++ /dev/null
@@ -1,97 +0,0 @@
-#include "instanceStore.h"
-#include <boost/assert.hpp>
-
-template <class Type, class StoreType>
-const StoreType &
-InstanceStore<Type, StoreType>::GetAll()
-{
- return *getInstances();
-}
-
-template <class Type, class StoreType>
-void
-InstanceStore<Type, StoreType>::Add(const typename StoreType::value_type & p)
-{
- getInstances()->insert(p);
-}
-
-template <class Type, class StoreType>
-void
-InstanceStore<Type, StoreType>::prune()
-{
- auto & ps = getInstances();
- if (ps->empty()) {
- delete ps;
- ps = NULL;
- }
-}
-
-template <class Type, class StoreType>
-StoreType * &
-InstanceStore<Type, StoreType>::getInstances()
-{
- static StoreType * instances = NULL;
- if (!instances) {
- instances = new StoreType();
- }
- return instances;
-}
-
-template <class Type, class KeyType>
-void
-InstanceMap<Type, KeyType>::Add(const KeyType & k, Type * p)
-{
- BOOST_ASSERT(IStore::getInstances()->find(k) == IStore::getInstances()->end());
- IStore::Add(Value(k, boost::shared_ptr<Type>(p)));
-}
-
-template <class Type, class KeyType>
-void
-InstanceMap<Type, KeyType>::Add(const KeyType & k, const boost::shared_ptr<Type> & p)
-{
- BOOST_ASSERT(IStore::getInstances()->find(k) == IStore::getInstances()->end());
- IStore::Add(Value(k, p));
-}
-
-template <class Type, class KeyType>
-void
-InstanceMap<Type, KeyType>::Remove(const KeyType & k)
-{
- IStore::getInstances()->erase(k);
- IStore::prune();
-}
-
-template <class Type, class KeyType>
-void
-InstanceMap<Type, KeyType>::OnEach(const boost::function<void(const Value &)> & func)
-{
- for (const auto & l : IStore::GetAll()) {
- func(l);
- }
- IStore::prune();
-}
-
-template <class Type>
-void
-InstanceSet<Type>::OnAll(const boost::function<void(Type *)> & func)
-{
- for (const auto & l : IStore::GetAll()) {
- func(l.get());
- }
- IStore::prune();
-}
-
-template <class Type>
-void
-InstanceSet<Type>::Remove(const boost::shared_ptr<Type> & p)
-{
- IStore::getInstances()->erase(p);
- IStore::prune();
-}
-
-#define INSTANTIATESTORE(K, T) \
-template class InstanceStore<T, std::map<K, boost::shared_ptr<T>>>; \
-template class InstanceMap<T, K>; \
-template class InstanceStore<T, std::set<boost::shared_ptr<T>>>; \
-template class InstanceSet<T>
-
diff --git a/project2/common/library.cpp b/project2/common/library.cpp
index 11dadb3..136e9d4 100644
--- a/project2/common/library.cpp
+++ b/project2/common/library.cpp
@@ -23,7 +23,7 @@ Library::~Library()
}
STORAGEOF(Library) libraries;
-class LibraryLoader : public ElementLoader::For<Library> {
+class LibraryLoader : public ScriptNodeFactory::For<Library>, public LifeCycle {
public:
void onIteration() override
{
@@ -31,6 +31,5 @@ class LibraryLoader : public ElementLoader::For<Library> {
}
};
-DECLARE_CUSTOM_LOADER("library", LibraryLoader);
-
+NAMEDPLUGIN("library", LibraryLoader, ScriptNodeFactory);
diff --git a/project2/common/lifeCycle.cpp b/project2/common/lifeCycle.cpp
new file mode 100644
index 0000000..60ed172
--- /dev/null
+++ b/project2/common/lifeCycle.cpp
@@ -0,0 +1,50 @@
+#include "lifeCycle.h"
+#include <boost/function/function_fwd.hpp>
+#include <plugins.impl.h>
+
+LifeCycle::~LifeCycle()
+{
+}
+
+void
+LifeCycle::onBegin()
+{
+}
+
+void
+LifeCycle::onBefore()
+{
+}
+
+void
+LifeCycle::onIdle()
+{
+}
+
+void
+LifeCycle::onIteration()
+{
+}
+
+void
+LifeCycle::onPeriodic()
+{
+}
+
+void
+LifeCycle::onConfigLoad()
+{
+}
+
+void
+LifeCycle::onAllComponents(const boost::function<void(LifeCycle *)> & func)
+{
+ for(auto p : AdHoc::PluginManager::getDefault()->getAll()) {
+ if (auto c = dynamic_cast<LifeCycle *>(p->implementation())) {
+ func(c);
+ }
+ }
+}
+
+INSTANTIATEPLUGINOF(LifeCycle);
+
diff --git a/project2/common/componentLoader.h b/project2/common/lifeCycle.h
index 45664e3..2a6b5b2 100644
--- a/project2/common/componentLoader.h
+++ b/project2/common/lifeCycle.h
@@ -1,12 +1,14 @@
-#ifndef COMPONENTLOADER_H
-#define COMPONENTLOADER_H
+#ifndef LIFECYCLE_H
+#define LIFECYCLE_H
-#include "plugable.h"
+#include <plugins.h>
+#include <boost/function/function_fwd.hpp>
/// Helper for loading and maintaining Project2 components
-class ComponentLoader {
+class LifeCycle : public virtual AdHoc::AbstractPluginImplementation {
public:
- virtual ~ComponentLoader() = 0;
+ virtual ~LifeCycle() = 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
@@ -14,14 +16,10 @@ class ComponentLoader {
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
-};
-typedef PluginsSameBase<ComponentLoader, std::string> Components;
-#define DECLARE_COMPONENT(Id, Inst) \
- static void init_optionsSource_##Type() __attribute__ ((constructor(200))); \
- static void init_optionsSource_##Type() { Components::Add(Id, new Inst()); } \
- static void kill_optionsSource_##Type() __attribute__ ((destructor(200))); \
- static void kill_optionsSource_##Type() { Components::Remove(Id); }
+ static void onAllComponents(const boost::function<void(LifeCycle *)> & func);
+};
+typedef AdHoc::PluginOf<LifeCycle> LifeCycleComponentPlugin;
#endif
diff --git a/project2/common/logger.cpp b/project2/common/logger.cpp
index 98aaf0b..f21bd40 100644
--- a/project2/common/logger.cpp
+++ b/project2/common/logger.cpp
@@ -2,7 +2,7 @@
#define SYSLOG_NAMES 1 // Enables the definition of names in syslog.h
#include "logger.h"
-#include "instanceStore.impl.h"
+#include "loggerFactory.h"
Log Logger::log;
@@ -17,7 +17,7 @@ Log::~Log()
}
void
-Log::setLoggerAt(LogDriverLoader * ldr, int level)
+Log::setLoggerAt(LogDriverFactory * ldr, int level)
{
if (level == -1) {
logs.erase(ldr);
@@ -26,9 +26,9 @@ Log::setLoggerAt(LogDriverLoader * ldr, int level)
logs[ldr] = ldr->create();
}
lowestLevel = -1;
- for (const auto & log : InstanceSet<LogDriverLoader>::GetAll()) {
- if (log->loggerLevel() > lowestLevel) {
- lowestLevel = log->loggerLevel();
+ for (const auto & log : AdHoc::PluginManager::getDefault()->getAll<LogDriverFactory>()) {
+ if (log->implementation()->loggerLevel() > lowestLevel) {
+ lowestLevel = log->implementation()->loggerLevel();
}
}
}
@@ -94,13 +94,3 @@ Logger::operator->() const
return &log;
}
-LogDriverBase::LogDriverBase()
-{
-}
-
-LogDriverBase::~LogDriverBase()
-{
-}
-
-INSTANTIATESTORE(std::string, LogDriverLoader);
-
diff --git a/project2/common/logger.h b/project2/common/logger.h
index 0a6398e..8d8b6de 100644
--- a/project2/common/logger.h
+++ b/project2/common/logger.h
@@ -3,37 +3,24 @@
#include <map>
#include <stdarg.h>
-#include <stdlib.h>
#include <syslog.h> // Pulled in for easy client lookups of LOG_* priorties
#include <boost/intrusive_ptr.hpp>
-#include <boost/format.hpp>
+#include <boost/format/format_fwd.hpp>
#include "intrusivePtrBase.h"
-#include "genLoader.h"
#include <buffer.h>
+#include "lifeCycle.h"
-/// Base class for classes providing a logging facility
-class LogDriverBase : public virtual IntrusivePtrBase {
- public:
- LogDriverBase();
- virtual ~LogDriverBase();
-
- virtual void message(int priority, const char * msg) const = 0;
-};
-
-class LogDriverLoader : public GenLoader<LogDriverBase, std::string> {
- public:
- virtual int loggerLevel() const = 0;
-};
-
+class LogDriverBase;
+class LogDriverFactory;
class Log {
public:
typedef boost::intrusive_ptr<LogDriverBase> LogDriverBasePtr;
- typedef std::map<LogDriverLoader *, LogDriverBasePtr> LogDrivers;
+ typedef std::map<LogDriverFactory *, LogDriverBasePtr> LogDrivers;
Log();
~Log();
- void setLoggerAt(LogDriverLoader *, int level);
+ void setLoggerAt(LogDriverFactory *, int level);
void message(int priority, const char * msg) const;
void messagef(int priority, const char * msgfmt, ...) const __attribute__ ((format (printf, 3, 4)));
@@ -67,34 +54,5 @@ class Logger {
static Log log;
};
-template<typename LoggerType>
-class LogDriverLoaderImpl : public LogDriverLoader::For<LoggerType, LogDriverLoader> {
- public:
- LogDriverLoaderImpl() :
- level(LoggerType::level)
- {
- }
- virtual void onConfigLoad() override {
- Logger()->setLoggerAt(this, level);
- if (level == -1) {
- instance.reset();
- }
- }
- inline LoggerType * create() const {
- if (!instance) {
- instance = new LoggerType();
- }
- return instance.get();
- }
- int loggerLevel() const {
- return level;
- }
- const int & level;
- private:
- mutable boost::intrusive_ptr<LoggerType> instance;
-};
-#define DECLARE_LOGGER_LOADER(N, T) \
- DECLARE_CUSTOM_COMPONENT_LOADER(N, T, LogDriverLoaderImpl<T>, LogDriverLoader);
-
#endif
diff --git a/project2/common/loggerFactory.cpp b/project2/common/loggerFactory.cpp
new file mode 100644
index 0000000..b1d75d1
--- /dev/null
+++ b/project2/common/loggerFactory.cpp
@@ -0,0 +1,14 @@
+#include "loggerFactory.h"
+#include <factory.impl.h>
+
+LogDriverBase::LogDriverBase()
+{
+}
+
+LogDriverBase::~LogDriverBase()
+{
+}
+
+template class AdHoc::Factory<LogDriverBase>;
+INSTANTIATEPLUGINOF(LogDriverFactory)
+
diff --git a/project2/common/loggerFactory.h b/project2/common/loggerFactory.h
new file mode 100644
index 0000000..056f5e3
--- /dev/null
+++ b/project2/common/loggerFactory.h
@@ -0,0 +1,38 @@
+#ifndef LOGGERFACTORY_H
+#define LOGGERFACTORY_H
+
+#include <factory.h>
+#include "lifeCycle.h"
+#include "intrusivePtrBase.h"
+#include "logger.h"
+
+/// Base class for classes providing a logging facility
+class LogDriverBase : public virtual IntrusivePtrBase {
+ public:
+ LogDriverBase();
+ virtual ~LogDriverBase();
+
+ virtual void message(int priority, const char * msg) const = 0;
+};
+
+class LogDriverFactory : public AdHoc::Factory<LogDriverBase> {
+ public:
+ virtual int loggerLevel() const = 0;
+};
+
+template<typename LoggerType>
+class LogDriverFactoryImpl : public LogDriverFactory, public LifeCycle {
+ public:
+ LogDriverFactoryImpl();
+
+ virtual void onConfigLoad() override;
+ inline LoggerType * create() const override;
+ int loggerLevel() const override;
+
+ const int & level;
+ private:
+ mutable boost::intrusive_ptr<LoggerType> instance;
+};
+
+#endif
+
diff --git a/project2/common/loggerFactory.impl.h b/project2/common/loggerFactory.impl.h
new file mode 100644
index 0000000..61711fd
--- /dev/null
+++ b/project2/common/loggerFactory.impl.h
@@ -0,0 +1,43 @@
+#ifndef LOGGERFACTORY_IMPL_H
+#define LOGGERFACTORY_IMPL_H
+
+#include "loggerFactory.h"
+
+template<typename T>
+LogDriverFactoryImpl<T>::LogDriverFactoryImpl() :
+ level(T::level)
+{
+}
+
+template<typename T>
+void
+LogDriverFactoryImpl<T>::onConfigLoad()
+{
+ Logger()->setLoggerAt(this, level);
+ if (level == -1) {
+ instance.reset();
+ }
+}
+
+template<typename T>
+T *
+LogDriverFactoryImpl<T>::create() const
+{
+ if (!instance) {
+ instance = new T();
+ }
+ return instance.get();
+}
+
+template<typename T>
+int
+LogDriverFactoryImpl<T>::loggerLevel() const
+{
+ return level;
+}
+
+#define DECLARE_LOGGER(N, T) \
+ NAMEDPLUGIN(N, LogDriverFactoryImpl<T>, LogDriverFactory)
+
+#endif
+
diff --git a/project2/common/noOutputExecute.cpp b/project2/common/noOutputExecute.cpp
deleted file mode 100644
index bed7bf0..0000000
--- a/project2/common/noOutputExecute.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <pch.hpp>
-#include "noOutputExecute.h"
-
-NoOutputExecute::NoOutputExecute(ScriptNodePtr p) :
- SourceObject(p)
-{
-}
-
-NoOutputExecute::NoOutputExecute(const std::string & n) :
- SourceObject(n)
-{
-}
-
-NoOutputExecute::~NoOutputExecute()
-{
-}
-
diff --git a/project2/common/noOutputExecute.h b/project2/common/noOutputExecute.h
deleted file mode 100644
index 61d03b5..0000000
--- a/project2/common/noOutputExecute.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef NOOUTPUTEXECUTE_H
-#define NOOUTPUTEXECUTE_H
-
-#include "sourceObject.h"
-#include "scriptStorage.h"
-
-class NoOutputExecute;
-class ExecContext;
-typedef boost::intrusive_ptr<NoOutputExecute> NoOutputExecutePtr;
-
-/// Base class for Project2 compoments that perform actions, but product no output
-class NoOutputExecute : public virtual SourceObject {
- public:
- NoOutputExecute(ScriptNodePtr p);
- NoOutputExecute(const std::string & n);
-
- virtual ~NoOutputExecute();
-
- virtual void execute(ExecContext *) const = 0;
-};
-
-#endif
-
diff --git a/project2/common/options.cpp b/project2/common/options.cpp
index c1ed762..7819bd9 100644
--- a/project2/common/options.cpp
+++ b/project2/common/options.cpp
@@ -1,6 +1,6 @@
#include <pch.hpp>
#include "options.h"
-#include "instanceStore.impl.h"
+#include <plugins.impl.h>
class NamedOption : public Options::Option {
public:
@@ -169,5 +169,5 @@ Options::InstanceTarget::assign(const VariableType & value) const
assigner(value);
}
-INSTANTIATESTORE(std::string, Options);
+INSTANTIATEPLUGINOF(Options);
diff --git a/project2/common/options.h b/project2/common/options.h
index 0d90826..6e734bb 100644
--- a/project2/common/options.h
+++ b/project2/common/options.h
@@ -9,9 +9,9 @@
#include <boost/function.hpp>
#include <boost/utility/enable_if.hpp>
#include "variableType.h"
-#include "plugable.h"
+#include <plugins.h>
-class Options {
+class Options : public AdHoc::AbstractPluginImplementation {
public:
class Target;
@@ -99,22 +99,20 @@ class Options {
OptionList options;
};
-// Registration helpers
-// These work pluggable component style
-typedef PluginsSameBase<Options, std::string> OptionsSets;
-
#define DECLARE_OPTIONS(Type, Label) \
static void init_options_##Type() __attribute__ ((constructor(200))); \
static void init_options_##Type() { \
Options * o = new Options(Label); \
Type::InitOptions(*o); \
- OptionsSets::Add(#Type, o); } \
+ AdHoc::PluginManager::getDefault()->add<Options>(o, #Type, __FILE__, __LINE__); } \
void Type::InitOptions(Options & o) { o
#define END_OPTIONS(Type) \
;} \
static void kill_options_##Type() __attribute__ ((destructor(200))); \
- static void kill_options_##Type() { OptionsSets::Remove(#Type); }
+ static void kill_options_##Type() { \
+ AdHoc::PluginManager::getDefault()->remove<Options>(#Type); \
+ }
#define INITOPTIONS \
static void InitOptions(Options &)
diff --git a/project2/common/optionsSource.cpp b/project2/common/optionsSource.cpp
index 0e1d751..56e983c 100644
--- a/project2/common/optionsSource.cpp
+++ b/project2/common/optionsSource.cpp
@@ -1,21 +1,22 @@
#include "optionsSource.h"
#include "logger.h"
-#include "instanceStore.impl.h"
+#include <plugins.impl.h>
class DefaultConfigConsumer : public ConfigConsumer {
public:
void operator()(const Glib::ustring & n, const Glib::ustring & p, const Glib::ustring & v, const Options::CurrentPlatform & cp) const {
- InstanceSet<Options>::OnAll(boost::bind(&Options::consume, _1, n, p, v, cp));
+ for (auto opts : AdHoc::PluginManager::getDefault()->getAll<Options>()) {
+ opts->implementation()->consume(n, p, v, cp);
+ }
}
const Options::Option * get(const Glib::ustring & n) const {
- const Options::Option * rtn = NULL;
- InstanceSet<Options>::OnAll([n,&rtn](const Options * os) {
- const Options::Option * o = os->find(n);
+ for (auto opts : AdHoc::PluginManager::getDefault()->getAll<Options>()) {
+ const Options::Option * o = opts->implementation()->find(n);
if (o) {
- rtn = o;
+ return o;
}
- });
- return rtn;
+ }
+ return nullptr;
}
};
@@ -25,22 +26,24 @@ boost::posix_time::ptime OptionsSource::loadedTime = boost::posix_time::special_
void
OptionsSource::loadSources(const Options::CurrentPlatform & platform)
{
- const auto & configs = InstanceSet<OptionsSource>::GetAll();
- if (std::find_if(configs.begin(), configs.end(), [](const OptionsSourcePtr & c) { return c->modifiedTime() > loadedTime; }) != configs.end()) {
- InstanceSet<Options>::OnAll(boost::bind(&Options::reset, _1));
+ const auto & configs = AdHoc::PluginManager::getDefault()->getAll<OptionsSource>();
+ if (std::find_if(configs.begin(), configs.end(), [](boost::shared_ptr<const AdHoc::PluginOf<OptionsSource>> c) { return c->implementation()->modifiedTime() > loadedTime; }) != configs.end()) {
+ for (auto opts : AdHoc::PluginManager::getDefault()->getAll<Options>()) {
+ opts->implementation()->reset();
+ }
DefaultConfigConsumer dcc;
- std::set<boost::shared_ptr<OptionsSource>> loadedConfigs;
+ std::set<const OptionsSource *> loadedConfigs;
while (loadedConfigs.size() != configs.size()) {
for (const auto & c : configs) {
- if (loadedConfigs.find(c) == loadedConfigs.end()) {
- c->loadInto(dcc, platform);
- loadedConfigs.insert(c);
+ if (loadedConfigs.find(c->implementation()) == loadedConfigs.end()) {
+ c->implementation()->loadInto(dcc, platform);
+ loadedConfigs.insert(c->implementation());
}
}
}
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onConfigLoad, _1));
-
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onConfigLoad, _1));
+
loadedTime = boost::posix_time::microsec_clock::universal_time();
Logger()->messagebf(LOG_DEBUG, "Loaded configuration at %s", loadedTime);
}
@@ -49,15 +52,17 @@ OptionsSource::loadSources(const Options::CurrentPlatform & platform)
void
OptionsSource::loadSource(const Options::CurrentPlatform & platform, OptionsSourcePtr opts)
{
- InstanceSet<Options>::OnAll(boost::bind(&Options::reset, _1));
+ for (auto opts : AdHoc::PluginManager::getDefault()->getAll<Options>()) {
+ opts->implementation()->reset();
+ }
DefaultConfigConsumer dcc;
opts->loadInto(dcc, platform);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onConfigLoad, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onConfigLoad, _1));
loadedTime = boost::posix_time::microsec_clock::universal_time();
Logger()->messagebf(LOG_DEBUG, "Loaded configuration at %s", loadedTime);
}
-INSTANTIATESTORE(std::string, OptionsSource);
+INSTANTIATEPLUGINOF(OptionsSource);
diff --git a/project2/common/optionsSource.h b/project2/common/optionsSource.h
index 7f1deee..32c43ed 100644
--- a/project2/common/optionsSource.h
+++ b/project2/common/optionsSource.h
@@ -18,7 +18,7 @@ class OptionsSource;
typedef boost::shared_ptr<OptionsSource> OptionsSourcePtr;
/// Base class of things that load options
-class OptionsSource {
+class OptionsSource : public AdHoc::AbstractPluginImplementation {
public:
virtual ~OptionsSource() = default;
@@ -32,12 +32,8 @@ class OptionsSource {
static boost::posix_time::ptime loadedTime;
};
-typedef PluginsSameBase<OptionsSource, std::string> OptionsSources;
#define DECLARE_OPTIONSSOURCE(Id, Inst) \
- static void init_optionsSource() __attribute__ ((constructor(200))); \
- static void init_optionsSource() { OptionsSources::Add(Id, Inst); } \
- static void kill_optionsSource() __attribute__ ((destructor(200))); \
- static void kill_optionsSource() { OptionsSources::Remove(Id); }
+ NAMEDPLUGIN(Id, Inst, OptionsSource)
#endif
diff --git a/project2/common/pch.hpp b/project2/common/pch.hpp
index a18ebbb..2feca3c 100644
--- a/project2/common/pch.hpp
+++ b/project2/common/pch.hpp
@@ -5,15 +5,10 @@
#include <algorithm>
#include <boost/any.hpp>
#include <boost/bind.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/function.hpp>
+#include <boost/function/function_fwd.hpp>
#include <boost/intrusive_ptr.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include "options.h"
#include <boost/shared_ptr.hpp>
-#include <boost/variant.hpp>
+#include <boost/variant/variant_fwd.hpp>
#include <glibmm/ustring.h>
#include <intrusivePtrBase.h>
#include <iostream>
@@ -25,13 +20,6 @@
#include <string.h>
#include <string>
#include <vector>
-#include "scriptStorage.h"
-#include "scriptLoader.h"
-#include "plugable.h"
-#include "variables.h"
-#include "variableType.h"
-#include "sourceObject.h"
-#include "scripts.h"
#endif
#endif
diff --git a/project2/common/plugable.cpp b/project2/common/plugable.cpp
deleted file mode 100644
index 969f530..0000000
--- a/project2/common/plugable.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "plugable.h"
-
-void
-Plugable::onAllComponents(const boost::function<void(ComponentLoader *)> & func)
-{
- InstanceSet<ComponentLoader>::OnAll(func);
-}
-
diff --git a/project2/common/plugable.h b/project2/common/plugable.h
deleted file mode 100644
index eaccd49..0000000
--- a/project2/common/plugable.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef PLUGABLE_H
-#define PLUGABLE_H
-
-#include <boost/function.hpp>
-#include <boost/shared_ptr.hpp>
-#include "instanceStore.h"
-#include "exceptions.h"
-
-class ComponentLoader;
-
-class Plugable : public InstanceSet<ComponentLoader> {
- public:
- static void onAllComponents(const boost::function<void(ComponentLoader *)> & func);
-};
-
-/// All loaders, keyed by string, enum, int, etc
-template<class Base, class Key, class AnonBase>
-class PluginsDiffBase {
- public:
- typedef Key KeyType;
- typedef InstanceMap<Base, KeyType> Map;
- typedef InstanceSet<Base> Set;
- typedef InstanceSet<AnonBase> AnonSet;
-
- static void Add(const KeyType & k, Base * i)
- {
- auto p = boost::shared_ptr<Base>(i);
- Map::Add(k, p);
- Set::Add(p);
- AnonSet::Add(p);
- }
-
- static void Remove(const KeyType & k)
- {
- auto p = Map::GetAll().find(k)->second;
- Set::Remove(p);
- AnonSet::Remove(p);
- Map::Remove(k);
- }
-};
-
-template<class Base, class Key>
-class PluginsSameBase {
- public:
- typedef Key KeyType;
- typedef InstanceMap<Base, KeyType> Map;
- typedef InstanceSet<Base> Set;
-
- static void Add(const KeyType & k, Base * i)
- {
- auto p = boost::shared_ptr<Base>(i);
- Map::Add(k, p);
- Set::Add(p);
- }
-
- static void Remove(const KeyType & k)
- {
- Set::Remove(Map::GetAll().find(k)->second);
- Map::Remove(k);
- }
-};
-
-#define TOKENPASTE(x, y) x ## y
-#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
-#define DECLARE_CUSTOM_COMPONENT_LOADER(Key, Impl, Loader, BaseLoader) \
-namespace TOKENPASTE2(Impl, __LINE__) { \
- static void init_loader_##Impl() __attribute__ ((constructor(201))); \
- static void init_loader_##Impl() { PluginsDiffBase<BaseLoader, BaseLoader::KeyType, ComponentLoader>::Add(Key, new Loader()); } \
- static void kill_loader_##Impl() __attribute__ ((destructor(201))); \
- static void kill_loader_##Impl() { PluginsDiffBase<BaseLoader, BaseLoader::KeyType, ComponentLoader>::Remove(Key); } \
-}
-#define DECLARE_CUSTOM_LOADER(Key, T) \
- DECLARE_CUSTOM_COMPONENT_LOADER(Key, T, T, ElementLoader)
-#define DECLARE_COMPONENT_LOADER(Key, Type, BaseLoader) \
- DECLARE_CUSTOM_COMPONENT_LOADER(Key, Type, BaseLoader::For<Type>, BaseLoader)
-#define DECLARE_LOADER(Key, Loader) \
- DECLARE_COMPONENT_LOADER(Key, Loader, ElementLoader)
-#define DECLARE_GENERIC_LOADER(Key, B, T) \
- DECLARE_CUSTOM_COMPONENT_LOADER(Key, T, B::For<T>, B);
-
-#endif
-
diff --git a/project2/common/presenter.cpp b/project2/common/presenter.cpp
index 012020d..a28f00c 100644
--- a/project2/common/presenter.cpp
+++ b/project2/common/presenter.cpp
@@ -1,7 +1,7 @@
#include <pch.hpp>
#include "presenter.h"
#include "dataSource.h"
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
NameValuePairPresenter::NameValuePairPresenter()
{
@@ -120,5 +120,5 @@ MultiRowSetPresenter::finalizeContent() const
{
}
-INSTANTIATESTORE(std::string, PresenterLoader);
+INSTANTIATEFACTORY(MultiRowSetPresenter, ScriptNodePtr, ObjectSource, ExecContext *);
diff --git a/project2/common/presenter.h b/project2/common/presenter.h
index 107e878..037e7bf 100644
--- a/project2/common/presenter.h
+++ b/project2/common/presenter.h
@@ -77,7 +77,7 @@ typedef boost::intrusive_ptr<RowSetPresenter> RowSetPresenterPtr;
typedef boost::intrusive_ptr<MultiRowSetPresenter> MultiRowSetPresenterPtr;
typedef boost::intrusive_ptr<NameValuePairPresenter> NameValuePairPresenterPtr;
-typedef GenLoader<MultiRowSetPresenter, std::string, ScriptNodePtr, ObjectSource, ExecContext *> PresenterLoader;
+typedef AdHoc::Factory<MultiRowSetPresenter, ScriptNodePtr, ObjectSource, ExecContext *> PresenterFactory;
#endif
diff --git a/project2/common/presenterCache.cpp b/project2/common/presenterCache.cpp
index 78122d0..429f93e 100644
--- a/project2/common/presenterCache.cpp
+++ b/project2/common/presenterCache.cpp
@@ -1,4 +1,5 @@
#include "presenterCache.h"
+#include <factory.impl.h>
PresenterCache::PresenterCache(ScriptNodePtr s) :
SourceObject(s),
@@ -12,6 +13,8 @@ PresenterCache::flushCache()
{
}
+INSTANTIATEFACTORY(PresenterCache, ScriptNodePtr);
+
class WriteToCache : public TransformImpl<WritableContent, PresenterCache> {
public:
void transform(const WritableContent * wc, PresenterCache * pc, ExecContext * ec) const {
diff --git a/project2/common/presenterCache.h b/project2/common/presenterCache.h
index b0adab8..c90c077 100644
--- a/project2/common/presenterCache.h
+++ b/project2/common/presenterCache.h
@@ -15,5 +15,6 @@ class PresenterCache : public SourceObject, public virtual TransformSource, publ
const std::string encoding;
};
typedef boost::intrusive_ptr<PresenterCache> PresenterCachePtr;
+typedef AdHoc::Factory<PresenterCache, ScriptNodePtr> PresenterCacheFactory;
#endif
diff --git a/project2/common/rowProcessor.cpp b/project2/common/rowProcessor.cpp
index acfaec5..a83fe00 100644
--- a/project2/common/rowProcessor.cpp
+++ b/project2/common/rowProcessor.cpp
@@ -13,8 +13,8 @@ RowProcessor::RowProcessor(ScriptNodePtr p) :
CROE(p->value("cacheRowsOnError", false, NULL)),
IRSE(p->value("ignoreRowSourceError", false, NULL))
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&caches));
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&tests));
+ p->script->loader.addLoadTarget(p, Storer::into<RowSetCacheFactory>(&caches));
+ p->script->loader.addLoadTarget(p, Storer::into<TestFactory>(&tests));
}
void
diff --git a/project2/common/rowSet.cpp b/project2/common/rowSet.cpp
index a050bab..1299818 100644
--- a/project2/common/rowSet.cpp
+++ b/project2/common/rowSet.cpp
@@ -6,6 +6,7 @@
#include "variables.h"
#include <boost/bind.hpp>
#include "execContext.h"
+#include <factory.impl.h>
RowSet::RowSet(ScriptNodePtr p) :
SourceObject(p)
@@ -87,3 +88,5 @@ RowState::foreachAttr(const AttrAction &) const
// rowNum is magic, so it doesn't count :)
}
+INSTANTIATEFACTORY(RowSet, ScriptNodePtr);
+
diff --git a/project2/common/rowSet.h b/project2/common/rowSet.h
index f36f79f..5cb991e 100644
--- a/project2/common/rowSet.h
+++ b/project2/common/rowSet.h
@@ -55,6 +55,7 @@ class RowState {
private:
unsigned int rowNum;
};
+typedef AdHoc::Factory<RowSet, ScriptNodePtr> RowSetFactory;
#endif
diff --git a/project2/common/rowSetCache.cpp b/project2/common/rowSetCache.cpp
index 95a949b..e6d2884 100644
--- a/project2/common/rowSetCache.cpp
+++ b/project2/common/rowSetCache.cpp
@@ -4,6 +4,7 @@
#include "rowProcessor.h"
#include "logger.h"
#include <glibmm/exception.h>
+#include <factory.impl.h>
RowSetCache::RowSetCache(ScriptNodePtr p) :
IHaveParameters(p),
@@ -47,3 +48,5 @@ RowSetCache::applyKeys(ExecContext * ec, const KeyApplier & f, const IHaveParame
}
}
+INSTANTIATEFACTORY(RowSetCache, ScriptNodePtr);
+
diff --git a/project2/common/rowSetCache.h b/project2/common/rowSetCache.h
index 055b07e..b365c72 100644
--- a/project2/common/rowSetCache.h
+++ b/project2/common/rowSetCache.h
@@ -26,6 +26,7 @@ class RowSetCache : public IHaveParameters, public SourceObject {
const bool inherit;
};
typedef boost::intrusive_ptr<RowSetCache> RowSetCachePtr;
+typedef AdHoc::Factory<RowSetCache, ScriptNodePtr> RowSetCacheFactory;
#endif
diff --git a/project2/common/scriptLoader.cpp b/project2/common/scriptLoader.cpp
index 523a316..e3abd86 100644
--- a/project2/common/scriptLoader.cpp
+++ b/project2/common/scriptLoader.cpp
@@ -5,11 +5,8 @@
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/function_equal.hpp>
-#include "instanceStore.impl.h"
#include "appInstance.h"
-
-typedef std::map<std::string, boost::shared_ptr<ElementLoader> > ElementLoaderMap;
-typedef std::set<boost::shared_ptr<ComponentLoader> > ComponentLoaderSet;
+#include <factory.impl.h>
LoaderBase::LoaderBase() :
recursive(true)
@@ -68,7 +65,7 @@ LoaderBase::collectAll(ScriptNodePtr node, LoadedObjects & loadedObjects, bool c
node->obj = s->create(node);
break;
}
- catch (const NotSupported &) {
+ catch (const AdHoc::NoSuchPluginException &) {
}
}
if (!node->obj) {
@@ -99,9 +96,8 @@ LoaderBase::collectAll(ScriptNodePtr node, LoadedObjects & loadedObjects, bool c
}
void
-LoaderBase::collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr node)
+LoaderBase::collectAll(const CommonObjects * co, bool childrenOnly)
{
- addLoadTarget(node, Storer::into<ElementLoader>(&libraries));
Targets::iterator i;
LoadedObjects loadedObjects;
while ((i = targets.begin()) != targets.end()) {
@@ -115,5 +111,5 @@ LoaderBase::collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePt
}
}
-INSTANTIATESTORE(std::string, ScriptReaderLoader);
+INSTANTIATEFACTORY(ScriptReader, const std::string &, const std::string &);
diff --git a/project2/common/scriptLoader.h b/project2/common/scriptLoader.h
index ca888cf..fed7cef 100644
--- a/project2/common/scriptLoader.h
+++ b/project2/common/scriptLoader.h
@@ -6,13 +6,12 @@
#include <boost/intrusive_ptr.hpp>
#include "intrusivePtrBase.h"
#include "sourceObject.h"
-#include "genLoader.h"
+#include <factory.h>
#include "scripts_fwd.h"
#include <glibmm/ustring.h>
#include <map>
#include <vector>
-class ComponentLoader;
class CommonObjects;
class Storer;
class ScriptReader;
@@ -29,7 +28,7 @@ class LoaderBase {
LoaderBase();
virtual ~LoaderBase();
- void collectAll(const CommonObjects * co, bool childrenOnly, ScriptNodePtr script);
+ void collectAll(const CommonObjects * co, bool childrenOnly);
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();
@@ -45,8 +44,5 @@ class LoaderBase {
const Glib::ustring ns;
};
-/// Helper for loading and maintaining Project2 script components
-typedef GenLoader<SourceObject, std::string, ScriptNodePtr> ElementLoader;
-
#endif
diff --git a/project2/common/scriptStorage.h b/project2/common/scriptStorage.h
index cb947aa..c4155f2 100644
--- a/project2/common/scriptStorage.h
+++ b/project2/common/scriptStorage.h
@@ -5,6 +5,7 @@
#include "scriptLoader.h"
#include "exceptions.h"
#include "scripts.h"
+#include "lifeCycle.h"
#include <set>
#include <list>
#include <map>
@@ -44,16 +45,20 @@ class Storer : public virtual IntrusivePtrBase {
template <class X, class L>
class StorerBase : public Storer {
public:
- typedef boost::function2<boost::intrusive_ptr<IntrusivePtrBase>, L *, ScriptNodePtr> Creator;
+ typedef boost::function2<boost::intrusive_ptr<IntrusivePtrBase>, const L *, ScriptNodePtr> Creator;
StorerBase(const Creator & c) :
creator(c)
{
}
boost::intrusive_ptr<IntrusivePtrBase> create(ScriptNodePtr p) const {
- return creator(InstanceMap<L, std::string>::template Get<NotSupported>(p->get_name()).get(), p);
+ return creator(L::get(p->get_name()), p);
}
bool cacheable(ScriptNodePtr p) const {
- return InstanceMap<L, std::string>::template Get<NotSupported>(p->get_name())->cacheable();
+ auto f = AdHoc::PluginManager::getDefault()->get<L>(p->get_name());
+ if (auto c = dynamic_cast<const LifeCycle *>(f->implementation())) {
+ return c->cacheable();
+ }
+ return true;
}
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.cpp b/project2/common/scripts.cpp
index ff80870..3714d37 100644
--- a/project2/common/scripts.cpp
+++ b/project2/common/scripts.cpp
@@ -2,7 +2,9 @@
#include <algorithm>
#include "variables/fixed.h"
#include <boost/filesystem/convenience.hpp>
+#include <boost/filesystem/path.hpp>
#include "appInstance.h"
+#include <plugins.impl.h>
DECLARE_OPTIONS(Scripts, "Project2 Script options")
("common.namespace", Options::value(&scriptNamespace, "http://project2.randomdan.homeip.net"),
@@ -61,7 +63,7 @@ ScriptNode::value(const Glib::ustring & n, ExecContext * ec) const
void
ScriptReader::load(const CommonObjects * co, bool childrenOnly) const
{
- loader.collectAll(co, childrenOnly, root());
+ loader.collectAll(co, childrenOnly);
}
ScriptReaderPtr
@@ -75,8 +77,8 @@ ScriptReader::resolveScript(const std::string & group, const std::string & name,
return rs;
}
else {
- for (const auto & rl : InstanceSet<ScriptReaderLoader>::GetAll()) {
- rs = rl->resolveScript(group, e.string());
+ for (const auto & rl : AdHoc::PluginManager::getDefault()->getAll<ScriptReaderFactory>()) {
+ rs = rl->implementation()->create(group, e.string());
if (rs) {
AppInstance::current().cacheScript(sk, rs);
return rs;
diff --git a/project2/common/scripts.h b/project2/common/scripts.h
index 8bf450d..2442558 100644
--- a/project2/common/scripts.h
+++ b/project2/common/scripts.h
@@ -80,13 +80,7 @@ class ScriptReader : public virtual IntrusivePtrBase {
mutable std::map<std::string, SourceObject *> namedComponents;
};
-/// Base class to implement script reader modules
-class ScriptReaderLoader : public ComponentLoader {
- public:
- typedef std::string KeyType;
-
- virtual ScriptReaderPtr resolveScript(const std::string & group, const std::string & name) const = 0;
-};
+typedef AdHoc::Factory<ScriptReader, const std::string &, const std::string &> ScriptReaderFactory;
#endif
diff --git a/project2/common/sessionContainer.cpp b/project2/common/sessionContainer.cpp
index ae82dd9..1db2d36 100644
--- a/project2/common/sessionContainer.cpp
+++ b/project2/common/sessionContainer.cpp
@@ -1,6 +1,6 @@
#include <pch.hpp>
#include "sessionContainer.h"
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
SessionContainer::SessionContainer()
{
@@ -28,5 +28,5 @@ SessionContainer::GetSession(const boost::uuids::uuid & id) const
return s;
}
-INSTANTIATESTORE(std::string, SessionContainerLoader);
+INSTANTIATEVOIDFACTORY(SessionContainer);
diff --git a/project2/common/sessionContainer.h b/project2/common/sessionContainer.h
index b842457..4f62e96 100644
--- a/project2/common/sessionContainer.h
+++ b/project2/common/sessionContainer.h
@@ -5,6 +5,7 @@
#include <intrusivePtrBase.h>
#include "session.h"
#include "options.h"
+#include <factory.h>
class SessionContainer : public IntrusivePtrBase {
public:
@@ -21,7 +22,7 @@ class SessionContainer : public IntrusivePtrBase {
virtual SessionPtr getSession(const boost::uuids::uuid & sid) const = 0;
};
typedef boost::intrusive_ptr<SessionContainer> SessionContainerPtr;
-typedef GenLoader<SessionContainer, std::string> SessionContainerLoader;
+typedef AdHoc::Factory<SessionContainer> SessionContainerFactory;
#endif
diff --git a/project2/common/sourceObject.cpp b/project2/common/sourceObject.cpp
index 45c7d19..09fe94e 100644
--- a/project2/common/sourceObject.cpp
+++ b/project2/common/sourceObject.cpp
@@ -1,5 +1,4 @@
#include <pch.hpp>
-#include "instanceStore.impl.h"
#include "sourceObject.h"
#include "exceptions.h"
#include "safeMapFind.h"
@@ -48,6 +47,3 @@ SourceObject::findComponent(const std::string & name) const
return AdHoc::safeMapLookup<ComponentNotFound>(script->namedComponents, name);
}
-INSTANTIATESTORE(std::string, ComponentLoader);
-INSTANTIATESTORE(std::string, ElementLoader);
-
diff --git a/project2/common/stream.cpp b/project2/common/stream.cpp
index 0db9225..d97d1ab 100644
--- a/project2/common/stream.cpp
+++ b/project2/common/stream.cpp
@@ -1,5 +1,6 @@
#include "stream.h"
#include <boost/bind.hpp>
+#include <factory.impl.h>
Glib::ustring
Stream::getContentType(ExecContext *) const
@@ -20,3 +21,5 @@ Stream::writeTo(std::ostream & os, const std::string &, ExecContext * ec) const
runStream(boost::bind(&Stream::write, &os, _1, _2), ec);
}
+INSTANTIATEFACTORY(Stream, ScriptNodePtr);
+
diff --git a/project2/common/stream.h b/project2/common/stream.h
index bf0dc41..4fe47f0 100644
--- a/project2/common/stream.h
+++ b/project2/common/stream.h
@@ -21,6 +21,7 @@ class Stream : public SourceObject, public WritableContent {
static size_t write(std::ostream * os, const char * data, size_t len);
};
typedef boost::intrusive_ptr<Stream> StreamPtr;
+typedef AdHoc::Factory<Stream, ScriptNodePtr> StreamFactory;
#endif
diff --git a/project2/common/task.cpp b/project2/common/task.cpp
index 2cfe761..f77d518 100644
--- a/project2/common/task.cpp
+++ b/project2/common/task.cpp
@@ -1,9 +1,14 @@
#include <pch.hpp>
#include "task.h"
+#include <factory.impl.h>
Task::Task(ScriptNodePtr p) :
- SourceObject(p),
- NoOutputExecute(p)
+ SourceObject(p)
+{
+}
+
+Task::Task(const std::string & n) :
+ SourceObject(n)
{
}
@@ -11,3 +16,5 @@ Task::~Task()
{
}
+INSTANTIATEFACTORY(Task, ScriptNodePtr);
+
diff --git a/project2/common/task.h b/project2/common/task.h
index 15ccfbd..9a9548f 100644
--- a/project2/common/task.h
+++ b/project2/common/task.h
@@ -2,15 +2,17 @@
#define TASK_H
#include "sourceObject.h"
-#include "noOutputExecute.h"
+#include "execContext.h"
/// Base class for Project2 components that perform some specific task
-class Task : public NoOutputExecute {
+class Task : public virtual SourceObject {
public:
Task(ScriptNodePtr p);
+ Task(const std::string & name);
virtual ~Task();
virtual void execute(ExecContext *) const = 0;
};
+typedef AdHoc::Factory<Task, ScriptNodePtr> TaskFactory;
#endif
diff --git a/project2/common/taskHost.cpp b/project2/common/taskHost.cpp
index 035e701..136f481 100644
--- a/project2/common/taskHost.cpp
+++ b/project2/common/taskHost.cpp
@@ -1,6 +1,6 @@
#include <pch.hpp>
#include "taskHost.h"
-#include "noOutputExecute.h"
+#include "task.h"
#include "dataSource.h"
#include <scopeExit.h>
#include "scriptLoader.h"
@@ -12,7 +12,7 @@ TaskHost::TaskHost(ScriptNodePtr s) :
CheckHost(s),
IHaveSubTasks(s)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&tasks));
+ s->script->loader.addLoadTarget(s, Storer::into<TaskFactory>(&tasks));
}
TaskHost::~TaskHost()
diff --git a/project2/common/taskHost.h b/project2/common/taskHost.h
index e4b8b3a..84c04c9 100644
--- a/project2/common/taskHost.h
+++ b/project2/common/taskHost.h
@@ -6,9 +6,6 @@
#include "iHaveSubTasks.h"
#include "commonObjects.h"
-class NoOutputExecute;
-class DataSource;
-
class TaskHost : public IHaveSubTasks, virtual public CheckHost, virtual public CommonObjects {
protected:
TaskHost(ScriptNodePtr script);
diff --git a/project2/common/test.cpp b/project2/common/test.cpp
index 427848a..db7514d 100644
--- a/project2/common/test.cpp
+++ b/project2/common/test.cpp
@@ -1,4 +1,5 @@
#include "test.h"
+#include <factory.impl.h>
Test::Test(ScriptNodePtr s) :
SourceObject(s)
@@ -10,3 +11,5 @@ Test::reset() const
{
}
+INSTANTIATEFACTORY(Test, ScriptNodePtr);
+
diff --git a/project2/common/test.h b/project2/common/test.h
index 7cf563c..b821844 100644
--- a/project2/common/test.h
+++ b/project2/common/test.h
@@ -13,5 +13,6 @@ class Test : public virtual SourceObject {
virtual void reset() const;
};
typedef boost::intrusive_ptr<const Test> TestPtr;
+typedef AdHoc::Factory<Test, ScriptNodePtr> TestFactory;
#endif
diff --git a/project2/common/transform.cpp b/project2/common/transform.cpp
index 37173c7..6b44da0 100644
--- a/project2/common/transform.cpp
+++ b/project2/common/transform.cpp
@@ -3,7 +3,7 @@
#include "logger.h"
#include "ostreamWrapper.h"
#include "scriptStorage.h"
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
class TransformTargetStorer : public Storer {
public:
@@ -13,7 +13,7 @@ class TransformTargetStorer : public Storer {
}
boost::intrusive_ptr<IntrusivePtrBase> create(ScriptNodePtr p) const
{
- return InstanceMap<TransformTargetLoader, std::string>::Get<NotSupported>(p->get_name())->create(p, Scripted);
+ return TransformTargetFactory::createNew(p->get_name(), p, Scripted);
}
bool save(boost::intrusive_ptr<IntrusivePtrBase> o, ScriptNodePtr s)
{
@@ -42,12 +42,12 @@ TransformChainLink::~TransformChainLink()
{
}
-typedef std::map<std::string, boost::shared_ptr<TransformLoader> > TransformLoaderMap;
+typedef std::map<std::string, boost::shared_ptr<TransformFactory> > TransformFactoryMap;
void
TransformSource::addTarget(TransformChainLinkPtr tcl, ExecContext * ec, ScriptNodePtr e)
{
- for (const auto & tl : InstanceSet<TransformLoader>::GetAll()) {
- TransformPtr t = tl->create();
+ for (const auto & tl : AdHoc::PluginManager::getDefault()->getAll<TransformFactory>()) {
+ TransformPtr t = tl->implementation()->create();
if (t->canTransform(this, tcl.get())) {
if (e) {
t->configure(e, ec);
@@ -106,6 +106,6 @@ class TransformStaticContentToStdStream : public TransformImpl<StaticContent, os
};
DECLARE_TRANSFORM(TransformStaticContentToStdStream);
-INSTANTIATESTORE(std::string, TransformLoader);
-INSTANTIATESTORE(std::string, TransformTargetLoader);
+INSTANTIATEVOIDFACTORY(Transform);
+INSTANTIATEFACTORY(TransformChainLink, ScriptNodePtr, ObjectSource);
diff --git a/project2/common/transform.h b/project2/common/transform.h
index 7a46c7f..d450d8d 100644
--- a/project2/common/transform.h
+++ b/project2/common/transform.h
@@ -5,6 +5,7 @@
#include "intrusivePtrBase.h"
#include "scriptLoader.h"
#include <map>
+#include <factory.h>
#include "range.h"
class ExecContext;
@@ -49,11 +50,11 @@ class Transform : public virtual IntrusivePtrBase {
virtual void configure(ScriptNodePtr, ExecContext *) { };
};
-typedef GenLoader<Transform, std::string> TransformLoader;
-#define DECLARE_TRANSFORM(T) DECLARE_COMPONENT_LOADER(#T, T, TransformLoader)
+typedef AdHoc::Factory<Transform> TransformFactory;
+#define DECLARE_TRANSFORM(T) NAMEDFACTORY(#T, T, TransformFactory)
-typedef GenLoader<TransformChainLink, std::string, ScriptNodePtr, ObjectSource> TransformTargetLoader;
-#define DECLARE_TRANSFORMTARGET(N, T) DECLARE_COMPONENT_LOADER(N, T, TransformTargetLoader)
+typedef AdHoc::Factory<TransformChainLink, ScriptNodePtr, ObjectSource> TransformTargetFactory;
+#define DECLARE_TRANSFORMTARGET(N, T) NAMEDFACTORY(N, T, TransformTargetFactory)
template <class Source, class Destination>
class TransformImpl : public Transform {
diff --git a/project2/common/unittests/testConfig.cpp b/project2/common/unittests/testConfig.cpp
index 8c25394..10e2a04 100644
--- a/project2/common/unittests/testConfig.cpp
+++ b/project2/common/unittests/testConfig.cpp
@@ -9,7 +9,7 @@ BOOST_AUTO_TEST_CASE( config_application_value )
TestOptionsSource::LoadTestOptions({
{ "application.data", "testvalue" }
});
- Variable::VariableImplPtr c = VariableLoader::createNew("config", new TestScriptNode({
+ Variable::VariableImplPtr c = VariableFactory::createNew("config", new TestScriptNode({
{ "name", VariableType("data") }
}));
BOOST_REQUIRE(c);
diff --git a/project2/common/variableType.cpp b/project2/common/variableType.cpp
index 2902638..84170b7 100644
--- a/project2/common/variableType.cpp
+++ b/project2/common/variableType.cpp
@@ -1,6 +1,7 @@
#include <pch.hpp>
#include "variableType.h"
#include "logger.h"
+#include "exceptions.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/algorithm/string/predicate.hpp>
diff --git a/project2/common/variables.cpp b/project2/common/variables.cpp
index 87673a7..526f90c 100644
--- a/project2/common/variables.cpp
+++ b/project2/common/variables.cpp
@@ -12,8 +12,8 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
-#include "instanceStore.impl.h"
#include "execContext.h"
+#include <factory.impl.h>
VariableImplDyn::VariableImplDyn(ScriptNodePtr e)
{
@@ -72,7 +72,7 @@ class VariableParent : public VariableImplDyn {
const bool attr;
const Glib::ustring name;
};
-DECLARE_COMPONENT_LOADER("parent", VariableParent, VariableLoader);
+NAMEDFACTORY("parent", VariableParent, VariableFactory);
Variable::Variable(VariableType def) :
@@ -116,5 +116,5 @@ Variable::fromScriptNode(ScriptNodePtr p)
return p->variable();
}
-INSTANTIATESTORE(std::string, VariableLoader);
+INSTANTIATEFACTORY(VariableImpl, ScriptNodePtr);
diff --git a/project2/common/variables.h b/project2/common/variables.h
index cee9037..89aeeaf 100644
--- a/project2/common/variables.h
+++ b/project2/common/variables.h
@@ -5,15 +5,13 @@
#include <boost/optional.hpp>
#include <stdint.h>
#include "intrusivePtrBase.h"
-#include "genLoader.h"
+#include <factory.h>
#include "scripts.h"
#include "variableType.h"
#include <boost/shared_ptr.hpp>
class ExecContext;
-SimpleMessageException(UnknownVariableSource);
-
/// Base class for Project2 variable accessors
class VariableImpl : public IntrusivePtrBase {
public:
@@ -55,7 +53,7 @@ class VariableImplDyn : public VariableImpl {
};
/// Base class to create variables
-typedef GenLoader<VariableImpl, std::string, ScriptNodePtr> VariableLoader;
+typedef AdHoc::Factory<VariableImpl, ScriptNodePtr> VariableFactory;
#endif
diff --git a/project2/common/variables/config.cpp b/project2/common/variables/config.cpp
index e134d07..9ac3dd0 100644
--- a/project2/common/variables/config.cpp
+++ b/project2/common/variables/config.cpp
@@ -32,7 +32,7 @@ class VariableConfig : public VariableImplDyn {
const Glib::ustring name;
};
-class VariableConfigLoader : public VariableLoader::For<VariableConfig> {
+class VariableConfigFactory : public VariableFactory::For<VariableConfig> {
public:
class AppSettings : public Options::Option {
public:
@@ -68,16 +68,16 @@ class VariableConfigLoader : public VariableLoader::For<VariableConfig> {
return "Load settings into the client application";
}
};
- VariableConfigLoader() :
+ VariableConfigFactory() :
opts(new Options("Variables - ModConfig options"))
{
(*opts)(new AppSettings());
- OptionsSets::Add(typeid(AppSettings).name(), opts);
+ AdHoc::PluginManager::getDefault()->add<Options>(opts, typeid(AppSettings).name(), __FILE__, __LINE__);
}
- ~VariableConfigLoader()
+ ~VariableConfigFactory()
{
- OptionsSets::Remove(typeid(AppSettings).name());
+ AdHoc::PluginManager::getDefault()->remove<Options>(typeid(AppSettings).name());
}
const Options * options() const {
@@ -88,5 +88,5 @@ class VariableConfigLoader : public VariableLoader::For<VariableConfig> {
Options * opts;
};
-DECLARE_CUSTOM_COMPONENT_LOADER("config", VariableConfigLoader, VariableConfigLoader, VariableLoader);
+NAMEDPLUGIN("config", VariableConfigFactory, VariableFactory);
diff --git a/project2/common/variables/literal.cpp b/project2/common/variables/literal.cpp
index 529be6e..4f8e029 100644
--- a/project2/common/variables/literal.cpp
+++ b/project2/common/variables/literal.cpp
@@ -72,8 +72,7 @@ VariableLiteral::VarPart::value(ExecContext * ec) const
return (*this)(ec);
}
-DECLARE_COMPONENT_LOADER("literal", VariableLiteral, VariableLoader);
-DECLARE_CUSTOM_COMPONENT_LOADER("", VariableLiteralDef, VariableLoader::For<VariableLiteral>, VariableLoader);
-
+NAMEDFACTORY("literal", VariableLiteral, VariableFactory);
+NAMEDFACTORY("", VariableLiteral, VariableFactory);
diff --git a/project2/common/variables/localparam.cpp b/project2/common/variables/localparam.cpp
index cf2f165..63d6f55 100644
--- a/project2/common/variables/localparam.cpp
+++ b/project2/common/variables/localparam.cpp
@@ -28,5 +28,5 @@ class VariableLocalParam : public VariableImplDyn {
private:
const Glib::ustring name;
};
-DECLARE_COMPONENT_LOADER("local", VariableLocalParam, VariableLoader);
+NAMEDFACTORY("local", VariableLocalParam, VariableFactory);
diff --git a/project2/common/variables/lookup.cpp b/project2/common/variables/lookup.cpp
index 42ddff2..6c6ca55 100644
--- a/project2/common/variables/lookup.cpp
+++ b/project2/common/variables/lookup.cpp
@@ -34,7 +34,7 @@ class VariableLookup : public VariableImplDyn, public RowProcessor {
RowProcessor(e),
name(e->value("name", NULL).as<Glib::ustring>())
{
- e->script->loader.addLoadTarget(e, Storer::into<ElementLoader>(&rowSets));
+ e->script->loader.addLoadTarget(e, Storer::into<RowSetFactory>(&rowSets));
}
VariableType value(ExecContext * ec) const
{
@@ -70,4 +70,4 @@ class VariableLookup : public VariableImplDyn, public RowProcessor {
RowSets rowSets;
const Glib::ustring name;
};
-DECLARE_COMPONENT_LOADER("lookup", VariableLookup, VariableLoader);
+NAMEDFACTORY("lookup", VariableLookup, VariableFactory);
diff --git a/project2/common/variables/param.cpp b/project2/common/variables/param.cpp
index a1ef9b7..8e4125a 100644
--- a/project2/common/variables/param.cpp
+++ b/project2/common/variables/param.cpp
@@ -27,5 +27,5 @@ class VariableParam : public VariableImplDyn {
private:
const VariableType name;
};
-DECLARE_COMPONENT_LOADER("param", VariableParam, VariableLoader);
+NAMEDFACTORY("param", VariableParam, VariableFactory);
diff --git a/project2/common/variables/session.cpp b/project2/common/variables/session.cpp
index ed2077d..d3331c0 100644
--- a/project2/common/variables/session.cpp
+++ b/project2/common/variables/session.cpp
@@ -27,5 +27,5 @@ class VariableSession : public VariableImplDyn {
private:
const Glib::ustring name;
};
-DECLARE_COMPONENT_LOADER("session", VariableSession, VariableLoader);
+NAMEDFACTORY("session", VariableSession, VariableFactory);
diff --git a/project2/common/view.cpp b/project2/common/view.cpp
index 30a6491..5ab8f0a 100644
--- a/project2/common/view.cpp
+++ b/project2/common/view.cpp
@@ -1,5 +1,6 @@
#include <pch.hpp>
#include "view.h"
+#include <factory.impl.h>
View::View(ScriptNodePtr p) :
SourceObject(p)
@@ -10,3 +11,5 @@ View::~View()
{
}
+INSTANTIATEFACTORY(View, ScriptNodePtr);
+
diff --git a/project2/common/view.h b/project2/common/view.h
index 52a4130..fa0f37b 100644
--- a/project2/common/view.h
+++ b/project2/common/view.h
@@ -16,6 +16,7 @@ class View : public virtual SourceObject {
virtual void execute(const MultiRowSetPresenter *, ExecContext *) const = 0;
};
+typedef AdHoc::Factory<View, ScriptNodePtr> ViewFactory;
#endif
diff --git a/project2/common/viewHost.cpp b/project2/common/viewHost.cpp
index ce99506..a276e99 100644
--- a/project2/common/viewHost.cpp
+++ b/project2/common/viewHost.cpp
@@ -8,7 +8,7 @@ ViewHost::ViewHost(ScriptNodePtr s) :
CommonObjects(s),
CheckHost(s)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&views));
+ s->script->loader.addLoadTarget(s, Storer::into<ViewFactory>(&views));
}
ViewHost::~ViewHost()
diff --git a/project2/common/viewHost.h b/project2/common/viewHost.h
index 5ede3e4..09196f3 100644
--- a/project2/common/viewHost.h
+++ b/project2/common/viewHost.h
@@ -5,7 +5,6 @@
#include "presenter.h"
#include "checkHost.h"
#include <set>
-#include <boost/filesystem/path.hpp>
#include "commonObjects.h"
class ViewHost : virtual public CheckHost, virtual public CommonObjects {
diff --git a/project2/compression/decompressStream.cpp b/project2/compression/decompressStream.cpp
index c1d52ab..7d4023b 100644
--- a/project2/compression/decompressStream.cpp
+++ b/project2/compression/decompressStream.cpp
@@ -1,10 +1,8 @@
#include "stream.h"
-#include "componentLoader.h"
#include "decompressor.h"
#include "scripts.h"
#include "variables.h"
#include "scriptStorage.h"
-#include "instanceStore.impl.h"
class DecompressStream : public Stream {
public:
@@ -12,12 +10,12 @@ class DecompressStream : public Stream {
Stream(p),
method(p, "method")
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&stream));
+ p->script->loader.addLoadTarget(p, Storer::into<StreamFactory>(&stream));
}
void runStream(const Sink & sink, ExecContext * ec) const
{
- DecompressorPtr decomp = DecompressorLoader::getFor(method(ec))->create();
+ DecompressorPtr decomp = DecompressorFactory::createNew(method(ec));
stream->runStream([&](const char * data, size_t len) -> size_t {
decomp->decompress(data, len, sink);
return len;
@@ -28,6 +26,5 @@ class DecompressStream : public Stream {
const Variable method;
};
-DECLARE_LOADER("decompstream", DecompressStream);
-INSTANTIATESTORE(std::string, DecompressorLoader);
+NAMEDFACTORY("decompstream", DecompressStream, StreamFactory);
diff --git a/project2/compression/decompressor.cpp b/project2/compression/decompressor.cpp
new file mode 100644
index 0000000..b727aa8
--- /dev/null
+++ b/project2/compression/decompressor.cpp
@@ -0,0 +1,7 @@
+#include "decompressor.h"
+#include <factory.impl.h>
+
+Decompressor::~Decompressor() = default;
+
+INSTANTIATEVOIDFACTORY(Decompressor);
+
diff --git a/project2/compression/decompressor.h b/project2/compression/decompressor.h
index c57ff61..c15fef2 100644
--- a/project2/compression/decompressor.h
+++ b/project2/compression/decompressor.h
@@ -3,15 +3,15 @@
#include "stream.h"
#include "intrusivePtrBase.h"
+#include <factory.h>
class Decompressor : public IntrusivePtrBase {
public:
- virtual ~Decompressor()
- {
- }
+ virtual ~Decompressor();
+
virtual void decompress(const char * dataIn, size_t lengthIn, const Stream::Sink &) = 0;
};
typedef boost::intrusive_ptr<Decompressor> DecompressorPtr;
-typedef GenLoader<Decompressor, std::string> DecompressorLoader;
+typedef AdHoc::Factory<Decompressor> DecompressorFactory;
#endif
diff --git a/project2/compression/gzip.cpp b/project2/compression/gzip.cpp
index 2bf0a8d..653143f 100644
--- a/project2/compression/gzip.cpp
+++ b/project2/compression/gzip.cpp
@@ -49,5 +49,5 @@ class GZip : public Decompressor {
z_stream strm;
int status;
};
-DECLARE_GENERIC_LOADER("gz", DecompressorLoader, GZip);
+NAMEDFACTORY("gz", GZip, DecompressorFactory);
diff --git a/project2/compression/nocomp.cpp b/project2/compression/nocomp.cpp
index 6861171..78f4d4c 100644
--- a/project2/compression/nocomp.cpp
+++ b/project2/compression/nocomp.cpp
@@ -9,6 +9,5 @@ class NoComp : public Decompressor {
sink(data, len);
}
};
-DECLARE_GENERIC_LOADER("nocomp", DecompressorLoader, NoComp);
-
+NAMEDFACTORY("nocomp", NoComp, DecompressorFactory);
diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp
index 54c9b2f..df7010f 100644
--- a/project2/console/consoleAppEngine.cpp
+++ b/project2/console/consoleAppEngine.cpp
@@ -106,14 +106,14 @@ void
ConsoleApplicationEngine::process()
{
for (const auto & todo : todolist) {
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onBefore, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onBefore, _1));
Logger()->messagebf(LOG_DEBUG, "%s: Beginning script '%s/%s'", __FUNCTION__, todo.get<0>(), todo.get<1>());
Logger()->messagef(LOG_DEBUG, "%s: Processing file", __FUNCTION__);
process(ScriptReader::resolveScript(todo.get<0>(), todo.get<1>(), false));
Logger()->messagef(LOG_DEBUG, "%s: Complete", __FUNCTION__);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIteration, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIteration, _1));
}
}
diff --git a/project2/console/p2consoleMain.cpp b/project2/console/p2consoleMain.cpp
index 62f09b0..3c86600 100644
--- a/project2/console/p2consoleMain.cpp
+++ b/project2/console/p2consoleMain.cpp
@@ -6,15 +6,16 @@
int
main(int argc, char ** argv)
{
- OptionsSources::Add("", new CommandLineArguments(argc, argv, &ConsoleApplicationEngine::appendScript));
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));
+ AdHoc::PluginManager::getDefault()->add<OptionsSource>(
+ new CommandLineArguments(argc, argv, &ConsoleApplicationEngine::appendScript), "", __FILE__, __LINE__);
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onBegin, _1));
ConsoleApplicationEngine app;
OptionsSource::loadSources([] { return ConsoleApplicationEngine::reqPlatform;} );
app.process();
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1));
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onPeriodic, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIdle, _1));
}
diff --git a/project2/console/pch.hpp b/project2/console/pch.hpp
index fa98d28..829f4a0 100644
--- a/project2/console/pch.hpp
+++ b/project2/console/pch.hpp
@@ -2,13 +2,8 @@
#ifndef CONSOLE_PCH
#define CONSOLE_PCH
-#include "consoleAppEngine.h"
-#include "consolePresenter.h"
-#include "exceptions.h"
-#include "logger.h"
-#include "scriptLoader.h"
+#include <boost/variant/variant_fwd.hpp>
#include <boost/bind.hpp>
-#include "options.h"
#include <iostream>
#include <string>
diff --git a/project2/daemon/lib/daemon.cpp b/project2/daemon/lib/daemon.cpp
index bde0f45..f4af1c8 100644
--- a/project2/daemon/lib/daemon.cpp
+++ b/project2/daemon/lib/daemon.cpp
@@ -1,5 +1,5 @@
#include "daemon.h"
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
Daemon::Daemon()
{
@@ -19,5 +19,5 @@ Daemon::teardown() const
{
}
-INSTANTIATESTORE(std::string, DaemonLoader);
+INSTANTIATEFACTORY(Daemon, int &, char **);
diff --git a/project2/daemon/lib/daemon.h b/project2/daemon/lib/daemon.h
index d565e57..261d2f0 100644
--- a/project2/daemon/lib/daemon.h
+++ b/project2/daemon/lib/daemon.h
@@ -2,7 +2,7 @@
#define DAEMON_H
#include <glibmm/ustring.h>
-#include <genLoader.h>
+#include <factory.h>
#include <intrusivePtrBase.h>
class Daemon : public IntrusivePtrBase {
@@ -17,7 +17,7 @@ class Daemon : public IntrusivePtrBase {
};
typedef boost::intrusive_ptr<Daemon> DaemonPtr;
-typedef GenLoader<Daemon, std::string, int &, char **> DaemonLoader;
+typedef AdHoc::Factory<Daemon, int &, char **> DaemonFactory;
#endif
diff --git a/project2/daemon/p2daemonAppEngine.cpp b/project2/daemon/p2daemonAppEngine.cpp
index 42b4cda..27dff10 100644
--- a/project2/daemon/p2daemonAppEngine.cpp
+++ b/project2/daemon/p2daemonAppEngine.cpp
@@ -53,8 +53,8 @@ END_OPTIONS(DaemonAppEngine);
DaemonAppEngine::DaemonAppEngine(int argc, char ** argv) :
main_loop(Glib::MainLoop::create()),
- daemonFactory(boost::bind(&DaemonLoader::create,
- boost::bind(DaemonLoader::getFor, boost::cref(daemonType)), argc, argv))
+ daemonFactory(boost::bind(&::DaemonFactory::create,
+ boost::bind(::DaemonFactory::get, boost::cref(daemonType)), argc, argv))
{
}
@@ -123,7 +123,7 @@ bool
DaemonAppEngine::periodicCallback()
{
Logger()->messagebf(LOG_DEBUG, "%s: firing component periodics.", __PRETTY_FUNCTION__);
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onPeriodic, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onPeriodic, _1));
return true;
}
@@ -174,6 +174,6 @@ class DummyDaemon : public Daemon {
private:
mutable bool stop;
};
-DECLARE_GENERIC_LOADER("dummydaemon", DaemonLoader, DummyDaemon);
+NAMEDFACTORY("dummydaemon", DummyDaemon, DaemonFactory);
#endif
diff --git a/project2/daemon/p2daemonMain.cpp b/project2/daemon/p2daemonMain.cpp
index 95de88e..21eb748 100644
--- a/project2/daemon/p2daemonMain.cpp
+++ b/project2/daemon/p2daemonMain.cpp
@@ -44,9 +44,9 @@ daemonize()
int
main(int argc, char ** argv)
{
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onBegin, _1));
- OptionsSources::Add("_2", new CommandLineArguments(argc, argv,
- [](const char * a) { throw UnsupportedArguments(a); }));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onBegin, _1));
+ AdHoc::PluginManager::getDefault()->add<OptionsSource>(
+ new CommandLineArguments(argc, argv, [](const char * a) { throw UnsupportedArguments(a); }), "_2", __FILE__, __LINE__);
DaemonAppEngine dae(argc, argv);
OptionsSource::loadSources([] { return DaemonAppEngine::reqPlatform;} );
@@ -56,6 +56,6 @@ main(int argc, char ** argv)
}
dae.process();
- Plugable::onAllComponents(boost::bind(&ComponentLoader::onIdle, _1));
+ LifeCycle::onAllComponents(boost::bind(&LifeCycle::onIdle, _1));
}
diff --git a/project2/files/fileLog.cpp b/project2/files/fileLog.cpp
index 078e00b..8a56f6d 100644
--- a/project2/files/fileLog.cpp
+++ b/project2/files/fileLog.cpp
@@ -1,5 +1,5 @@
-#include "logger.h"
-#include "options.h"
+#include <loggerFactory.impl.h>
+#include <options.h>
/// Logger that writes to a file
class FileLogDriver : public LogDriverBase {
@@ -47,5 +47,5 @@ int FileLogDriver::level;
std::string FileLogDriver::path;
std::string FileLogDriver::openmode;
-DECLARE_LOGGER_LOADER("file", FileLogDriver);
+DECLARE_LOGGER("file", FileLogDriver);
diff --git a/project2/files/fileStream.cpp b/project2/files/fileStream.cpp
index 62bfa5b..ddfa30b 100644
--- a/project2/files/fileStream.cpp
+++ b/project2/files/fileStream.cpp
@@ -7,7 +7,6 @@
#include "exceptions.h"
#include <boost/algorithm/string/predicate.hpp>
-
class FileStream : public Stream {
public:
FileStream(ScriptNodePtr p) :
@@ -22,7 +21,7 @@ class FileStream : public Stream {
throw NotSupported(__PRETTY_FUNCTION__);
}
- void runStream(const Sink & sink, ExecContext * ec) const
+ void runStream(const Sink & sink, ExecContext * ec) const override
{
FILE * file = fopen(path(ec), "r");
if (!file) {
@@ -46,4 +45,5 @@ class FileStream : public Stream {
const Variable contentType;
const Variable path;
};
-DECLARE_LOADER("filestream", FileStream);
+NAMEDFACTORY("filestream", FileStream, StreamFactory);
+
diff --git a/project2/files/fsFilterMaxDepth.cpp b/project2/files/fsFilterMaxDepth.cpp
index 089737a..d55b0d1 100644
--- a/project2/files/fsFilterMaxDepth.cpp
+++ b/project2/files/fsFilterMaxDepth.cpp
@@ -19,4 +19,5 @@ class FsRowSpecMaxDepth : public FsRows::SpecBase {
Variable maxDepth;
};
-DECLARE_COMPONENT_LOADER("maxdepth", FsRowSpecMaxDepth, FsRows::SpecBaseLoader);
+NAMEDFACTORY("maxdepth", FsRowSpecMaxDepth, FsRows::SpecBaseFactory);
+NAMEDFACTORY("maxdepth", FsRowSpecMaxDepth, FsRows::SpecBaseStringFactory);
diff --git a/project2/files/fsFilterName.cpp b/project2/files/fsFilterName.cpp
index 92279c2..62ca04b 100644
--- a/project2/files/fsFilterName.cpp
+++ b/project2/files/fsFilterName.cpp
@@ -54,4 +54,5 @@ class FsRowSpecName : public FsRows::SpecBase {
const Variable pattern;
};
-DECLARE_COMPONENT_LOADER("name", FsRowSpecName, FsRows::SpecBaseLoader);
+NAMEDFACTORY("name", FsRowSpecName, FsRows::SpecBaseFactory);
+NAMEDFACTORY("name", FsRowSpecName, FsRows::SpecBaseStringFactory);
diff --git a/project2/files/fsFilterType.cpp b/project2/files/fsFilterType.cpp
index ba9ad72..2aecfee 100644
--- a/project2/files/fsFilterType.cpp
+++ b/project2/files/fsFilterType.cpp
@@ -40,4 +40,6 @@ class FsRowSpecType : public FsRows::SpecBase {
const Variable typelist;
};
-DECLARE_COMPONENT_LOADER("type", FsRowSpecType, FsRows::SpecBaseLoader);
+NAMEDFACTORY("type", FsRowSpecType, FsRows::SpecBaseFactory);
+NAMEDFACTORY("type", FsRowSpecType, FsRows::SpecBaseStringFactory);
+
diff --git a/project2/files/fsRows.cpp b/project2/files/fsRows.cpp
index d22b6ea..c67c02f 100644
--- a/project2/files/fsRows.cpp
+++ b/project2/files/fsRows.cpp
@@ -14,11 +14,11 @@
#include <grp.h>
#include <stdio.h>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
typedef boost::filesystem::directory_iterator DirEnt;
-DECLARE_LOADER("fsrows", FsRows);
+NAMEDFACTORY("fsrows", FsRows, RowSetFactory);
const Glib::ustring field_absPath("absPath");
const Glib::ustring field_relPath("relPath");
@@ -50,7 +50,7 @@ FsRows::FsRows(ScriptNodePtr p) :
spec(p, "spec", ""),
ignoreErrors(p, "ignoreerrors", true)
{
- p->script->loader.addLoadTarget(p, Storer::into<SpecBaseLoader>(&specs));
+ p->script->loader.addLoadTarget(p, Storer::into<SpecBaseFactory>(&specs));
}
FsRows::~FsRows()
@@ -81,7 +81,7 @@ FsRows::execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecCont
for (SpecSpec::const_iterator sf = s.begin(); sf != s.end(); ) {
const Glib::ustring & name = (*sf++);
if (name[0] == '-') {
- ss.specs.insert(InstanceMap<SpecBaseLoader, std::string>::Get<NotSupported>(name.substr(1))->createWith(*sf++));
+ ss.specs.insert(SpecBaseStringFactory::createNew(name.substr(1), *sf++));
}
else {
throw NotSupported(name);
@@ -237,5 +237,6 @@ FsRows::SearchState::fileType() const
throw NotSupported(__PRETTY_FUNCTION__);
}
-INSTANTIATESTORE(std::string, FsRows::SpecBaseLoader);
+INSTANTIATEFACTORY(FsRows::SpecBase, ScriptNodePtr);
+INSTANTIATEFACTORY(FsRows::SpecBase, const Glib::ustring &);
diff --git a/project2/files/fsRows.h b/project2/files/fsRows.h
index 2e44750..897f274 100644
--- a/project2/files/fsRows.h
+++ b/project2/files/fsRows.h
@@ -8,6 +8,7 @@
#include "rowSet.h"
#include "scriptStorage.h"
#include "scriptLoader.h"
+#include <factory.h>
class CommonObjects;
@@ -25,22 +26,8 @@ class FsRows : public RowSet {
const struct stat & curStat(const SearchState * fs) const;
};
typedef boost::intrusive_ptr<SpecBase> SpecBasePtr;
- template <class X>
- class SpecBaseLoaderX : public GenLoader<SpecBase, std::string, ScriptNodePtr> {
- public:
- virtual SpecBase * createWith(const Glib::ustring &) const = 0;
- template <class T, class BaseLoader = SpecBaseLoaderX<X>>
- class For : public BaseLoader {
- public:
- inline SpecBase * create(const ScriptNodePtr & v) const {
- return new T(v);
- }
- inline SpecBase * createWith(const Glib::ustring & v) const {
- return new T(v);
- }
- };
- };
- typedef SpecBaseLoaderX<void> SpecBaseLoader;
+ typedef AdHoc::Factory<SpecBase, ScriptNodePtr> SpecBaseFactory;
+ typedef AdHoc::Factory<SpecBase, const Glib::ustring &> SpecBaseStringFactory;
typedef ANONSTORAGEOF(SpecBase) SpecBases;
typedef std::list<Glib::ustring> SpecSpec;
typedef boost::filesystem::path Path;
diff --git a/project2/files/functions/pwd.cpp b/project2/files/functions/pwd.cpp
index 644c934..af06fe7 100644
--- a/project2/files/functions/pwd.cpp
+++ b/project2/files/functions/pwd.cpp
@@ -16,6 +16,6 @@ class Pwd : public VariableImplDyn {
return boost::filesystem::current_path().string();
}
};
-DECLARE_COMPONENT_LOADER("pwd", Pwd, VariableLoader);
+NAMEDFACTORY("pwd", Pwd, VariableFactory);
diff --git a/project2/files/optionsSource.cpp b/project2/files/optionsSource.cpp
index 8e98df0..2ce320c 100644
--- a/project2/files/optionsSource.cpp
+++ b/project2/files/optionsSource.cpp
@@ -38,19 +38,27 @@ FileOptions::modifiedTime() const
FileOptions::ExtraFileOptions FileOptions::extraFileOptions;
+class DefaultFileOptions : public FileOptions {
+ public:
+ DefaultFileOptions() :
+ FileOptions(".p2config")
+ {
+ }
+};
+
// Z... process last :)
-DECLARE_OPTIONSSOURCE("Z_configfile", new FileOptions(".p2config"))
+DECLARE_OPTIONSSOURCE("Z_configfile", DefaultFileOptions)
DECLARE_OPTIONS(FileOptions, "File Options options")
("file.options.read", Options::functions(
[](const VariableType & vt) {
auto fo = new FileOptions(vt.as<std::string>());
extraFileOptions[vt] = boost::shared_ptr<FileOptions>(fo);
- OptionsSources::Add(vt, fo);
+ AdHoc::PluginManager::getDefault()->add<OptionsSource>(fo, vt, __FILE__, __LINE__);
},
[]() {
for (const auto & fo : extraFileOptions) {
- OptionsSources::Remove(fo.first);
+ AdHoc::PluginManager::getDefault()->remove<OptionsSource>(fo.first);
}
extraFileOptions.clear();
}),
diff --git a/project2/files/pch.hpp b/project2/files/pch.hpp
index 58f05b9..91c45d8 100644
--- a/project2/files/pch.hpp
+++ b/project2/files/pch.hpp
@@ -2,29 +2,11 @@
#ifndef FILES_PCH
#define FILES_PCH
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/trim.hpp>
#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/intrusive_ptr.hpp>
-#include <boost/lexical_cast.hpp>
-#include "definedColumns.h"
-#include "exceptions.h"
-#include "fsRows.h"
-#include <glibmm/fileutils.h>
-#include <glibmm/iochannel.h>
-#include "logger.h"
-#include "optionsSource.h"
-#include "rowProcessor.h"
-#include "rowSet.h"
-#include "scopeExit.h"
-#include "scriptLoader.h"
-#include "scripts.h"
-#include "scriptStorage.h"
-#include "variables.h"
+#include <boost/variant/variant_fwd.hpp>
#endif
#endif
diff --git a/project2/files/presenterCache.cpp b/project2/files/presenterCache.cpp
index 1c6cae6..9651c20 100644
--- a/project2/files/presenterCache.cpp
+++ b/project2/files/presenterCache.cpp
@@ -87,7 +87,7 @@ class FilePresenterCache : public PresenterCache {
FilePresenterCache(ScriptNodePtr s) :
PresenterCache(s),
- idProvider(VariableLoader::createNew(Provider, s)) {
+ idProvider(VariableFactory::createNew(Provider, s)) {
}
~FilePresenterCache()
{
@@ -228,7 +228,7 @@ class FilePresenterCache : public PresenterCache {
static std::string FileName;
static std::string Provider;
static time_t CacheLife;
- friend class FilePresenterCacheLoader;
+ friend class FilePresenterCacheFactory;
};
FilePresenterCache::OpenCaches FilePresenterCache::openCaches;
boost::filesystem::path FilePresenterCache::Store;
@@ -247,9 +247,9 @@ DECLARE_OPTIONS(FilePresenterCache, "File Presenter Cache options")
"The name of the component used to provide a unique request ID")
END_OPTIONS(FilePresenterCache)
-class FilePresenterCacheLoader : public ElementLoader::For<FilePresenterCache> {
+class FilePresenterCacheFactory : public LifeCycle {
public:
- FilePresenterCacheLoader()
+ FilePresenterCacheFactory()
{
gcry_check_version(GCRYPT_VERSION);
}
@@ -299,4 +299,5 @@ class FilePresenterCacheLoader : public ElementLoader::For<FilePresenterCache> {
return files;
}
};
-DECLARE_CUSTOM_LOADER("filecache", FilePresenterCacheLoader);
+NAMEDFACTORY("filecache", FilePresenterCache, PresenterCacheFactory);
+
diff --git a/project2/files/writeStream.cpp b/project2/files/writeStream.cpp
index 954ec8b..485c138 100644
--- a/project2/files/writeStream.cpp
+++ b/project2/files/writeStream.cpp
@@ -2,6 +2,7 @@
#include "task.h"
#include "stream.h"
#include "variables.h"
+#include <scriptStorage.h>
#include <fstream>
SimpleMessageException(OpenTargetFile);
@@ -13,7 +14,7 @@ class WriteStream : public Task {
Task(s),
path(s, "path")
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&stream));
+ s->script->loader.addLoadTarget(s, Storer::into<StreamFactory>(&stream));
}
void execute(ExecContext * ec) const
@@ -32,5 +33,5 @@ class WriteStream : public Task {
StreamPtr stream;
};
-DECLARE_LOADER("writestream", WriteStream);
+NAMEDFACTORY("writestream", WriteStream, TaskFactory);
diff --git a/project2/ice/iceDaemon.cpp b/project2/ice/iceDaemon.cpp
index ccd64a0..e6769b5 100644
--- a/project2/ice/iceDaemon.cpp
+++ b/project2/ice/iceDaemon.cpp
@@ -24,14 +24,14 @@ std::string IceDaemon::viewRoot;
std::string IceDaemon::taskRoot;
IceBase::Libs IceDaemon::libs;
-class IceDaemonLoader : public DaemonLoader::For<IceDaemon> {
+class IceDaemonFactory : public DaemonFactory::For<IceDaemon>, public LifeCycle {
public:
void onConfigLoad() override {
IceBase::FinaliseLoad(IceDaemon::libs);
}
};
-DECLARE_CUSTOM_COMPONENT_LOADER("ice", IceDaemon, IceDaemonLoader, DaemonLoader);
+NAMEDPLUGIN("ice", IceDaemonFactory, DaemonFactory);
DECLARE_OPTIONS(IceDaemon, "ICE Daemon Options")
("ice.daemon.viewRoot", Options::value(&viewRoot, "views"),
"The folder in which to find view scripts")
@@ -72,9 +72,9 @@ IceDaemon::setup() const
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(adapterName, adapterEndpoint);
Logger()->messagebf(LOG_DEBUG, " %s installing servants...", __PRETTY_FUNCTION__);
- InstanceSet<IceDaemonAdapterHandlerLoader>::OnAll([this, adapter](IceDaemonAdapterHandlerLoader * loader) {
- loader->create(this)->add(adapter, ic);
- });
+ for(auto p : AdHoc::PluginManager::getDefault()->getAll<IceDaemonAdapterHandlerFactory>()) {
+ p->implementation()->create(this)->add(adapter, ic);
+ }
Logger()->messagebf(LOG_DEBUG, " %s starting...", __PRETTY_FUNCTION__);
adapter->activate();
@@ -96,7 +96,7 @@ class IceDaemonViewHost : public virtual CommonObjects, public virtual CheckHost
CommonObjects(s),
CheckHost(s)
{
- s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&view));
+ s->script->loader.addLoadTarget(s, Storer::into<FlatViewFactory>(&view));
}
void executeView(RowSetPresenterPtr presenter, ExecContext * ec) const
{
diff --git a/project2/ice/iceDataSource.cpp b/project2/ice/iceDataSource.cpp
index aa033fc..cce2dd8 100644
--- a/project2/ice/iceDataSource.cpp
+++ b/project2/ice/iceDataSource.cpp
@@ -44,12 +44,12 @@ IceDataSource::ClearSlice()
libs.clear();
}
-class IceDataSourceLoader : public ElementLoader::For<IceDataSource> {
+class IceDataSourceFactory : public DataSourceFactory::For<IceDataSource>, public LifeCycle {
public:
void onConfigLoad() override {
IceBase::FinaliseLoad(IceDataSource::libs);
}
};
-DECLARE_CUSTOM_LOADER("icedatasource", IceDataSourceLoader);
+NAMEDPLUGIN("icedatasource", IceDataSourceFactory, DataSourceFactory);
diff --git a/project2/ice/iceModule.cpp b/project2/ice/iceModule.cpp
index 7e39858..309e9a5 100644
--- a/project2/ice/iceModule.cpp
+++ b/project2/ice/iceModule.cpp
@@ -1,7 +1,7 @@
#include <pch.hpp>
#include "iceModule.h"
#include "iceDaemon.h"
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
IceDaemonModule::IceDaemonModule(const std::string & n, const IceDaemon * id) :
name(n),
@@ -31,5 +31,5 @@ IceDaemonModule::remove(Ice::ObjectAdapterPtr adapter, Ice::CommunicatorPtr ic)
adapter->remove(ic->stringToIdentity(name));
}
-INSTANTIATESTORE(std::string, IceDaemonAdapterHandlerLoader);
+INSTANTIATEFACTORY(IceDaemonModule, const IceDaemon *);
diff --git a/project2/ice/iceModule.h b/project2/ice/iceModule.h
index fcdd3e4..49aa63b 100644
--- a/project2/ice/iceModule.h
+++ b/project2/ice/iceModule.h
@@ -9,6 +9,7 @@
#include <boost/function.hpp>
#include <slicer/modelParts.h>
#include "iceConvert.h"
+#include <factory.h>
typedef std::map<std::string, VariableType> ParamMap;
class IceDaemon;
@@ -29,7 +30,7 @@ class IceDaemonModule : virtual public ::Ice::Object {
const IceDaemon * const iceDaemon;
};
-typedef GenLoader<IceDaemonModule, std::string, const IceDaemon *> IceDaemonAdapterHandlerLoader;
+typedef AdHoc::Factory<IceDaemonModule, const IceDaemon *> IceDaemonAdapterHandlerFactory;
#endif
diff --git a/project2/ice/iceRows.h b/project2/ice/iceRows.h
index dc729ff..7fcda85 100644
--- a/project2/ice/iceRows.h
+++ b/project2/ice/iceRows.h
@@ -30,7 +30,8 @@ class IceRows : public RowSet, public IceClient<Interface> {
IceClient<Interface>(p)
{
}
- void loadComplete(const CommonObjects * co) {
+ void loadComplete(const CommonObjects * co) override
+ {
IceClient<Interface>::loadComplete(co);
}
};
diff --git a/project2/ice/iceTask.h b/project2/ice/iceTask.h
index 2d71818..281429f 100644
--- a/project2/ice/iceTask.h
+++ b/project2/ice/iceTask.h
@@ -15,7 +15,10 @@ class IceTask : public Task, public IceClient<Interface> {
{
}
- void loadComplete(const CommonObjects * co) { IceClient<Interface>::loadComplete(co); }
+ void loadComplete(const CommonObjects * co) override
+ {
+ IceClient<Interface>::loadComplete(co);
+ }
};
#endif
diff --git a/project2/ice/pch.hpp b/project2/ice/pch.hpp
index 3ed09f0..1268e36 100644
--- a/project2/ice/pch.hpp
+++ b/project2/ice/pch.hpp
@@ -4,16 +4,12 @@
#include <Ice/Ice.h>
#include <boost/filesystem.hpp>
-#include <boost/function.hpp>
+#include <boost/function/function_fwd.hpp>
#include <boost/optional.hpp>
-#include <commonObjects.h>
-#include <exceptions.h>
-#include <logger.h>
#include <map>
-#include <options.h>
#include <Slice/Parser.h>
#include <string>
-#include <variables.h>
+#include <boost/variant/variant_fwd.hpp>
#include <slicer/modelParts.h>
#include <slicer/serializer.h>
diff --git a/project2/ice/slice2Common.cpp b/project2/ice/slice2Common.cpp
index 9dfcf9f..9bd79aa 100644
--- a/project2/ice/slice2Common.cpp
+++ b/project2/ice/slice2Common.cpp
@@ -59,10 +59,10 @@ Slice2Common::ParameterVariables(Slice::OperationPtr o)
}
void
-Slice2Common::Declaration(Slice::OperationPtr o)
+Slice2Common::Declaration(Slice::OperationPtr o, const std::string & base)
{
- fprintf(code, "\t\t\tDECLARE_LOADER(\"%s-%s-%s\", %s);\n\n",
- module.c_str(), interface.c_str(), o->name().c_str(), o->name().c_str());
+ fprintf(code, "\t\t\tNAMEDFACTORY(\"%s-%s-%s\", %s, %s);\n\n",
+ module.c_str(), interface.c_str(), o->name().c_str(), o->name().c_str(), base.c_str());
}
void
diff --git a/project2/ice/slice2Common.h b/project2/ice/slice2Common.h
index 170f0e7..8ea21d0 100644
--- a/project2/ice/slice2Common.h
+++ b/project2/ice/slice2Common.h
@@ -9,7 +9,7 @@ class Slice2Common : public Slice::ParserVisitor {
void FunctionBegin(Slice::OperationPtr o);
void ParameterVariables(Slice::OperationPtr o);
- void Declaration(Slice::OperationPtr o);
+ void Declaration(Slice::OperationPtr o, const std::string &);
void CallOperation(Slice::OperationPtr o);
unsigned int Components() const;
diff --git a/project2/ice/slice2Daemon.cpp b/project2/ice/slice2Daemon.cpp
index 177e406..41e71f1 100644
--- a/project2/ice/slice2Daemon.cpp
+++ b/project2/ice/slice2Daemon.cpp
@@ -65,7 +65,7 @@ Slice2Daemon::visitClassDefEnd(const Slice::ClassDefPtr & c)
{
if (code) {
fprintf(code, "\t}; // class %sImpl\n\n", c->name().c_str());
- fprintf(code, "\tDECLARE_GENERIC_LOADER(\"%s-%s\", IceDaemonAdapterHandlerLoader, %sImpl);\n\n",
+ fprintf(code, "\tNAMEDFACTORY(\"%s-%s\", %sImpl, IceDaemonAdapterHandlerFactory);\n\n",
module.c_str(), c->name().c_str(), c->name().c_str());
}
components += 1;
diff --git a/project2/ice/slice2Rows.cpp b/project2/ice/slice2Rows.cpp
index 8c67222..b91d158 100644
--- a/project2/ice/slice2Rows.cpp
+++ b/project2/ice/slice2Rows.cpp
@@ -63,7 +63,7 @@ Slice2Rows::visitOperation(const Slice::OperationPtr & o)
fprintf(code, "\t\t\t\t\t}\n\n");
ParameterVariables(o);
fprintf(code, "\t\t\t};\n");
- Declaration(o);
+ Declaration(o, "RowSetFactory");
}
}
diff --git a/project2/ice/slice2Task.cpp b/project2/ice/slice2Task.cpp
index 84a4f29..f6dc58f 100644
--- a/project2/ice/slice2Task.cpp
+++ b/project2/ice/slice2Task.cpp
@@ -61,7 +61,7 @@ Slice2Task::visitOperation(const Slice::OperationPtr & o)
fprintf(code, "\t\t\t\t\t}\n\n");
ParameterVariables(o);
fprintf(code, "\t\t\t};\n");
- Declaration(o);
+ Declaration(o, "TaskFactory");
}
}
diff --git a/project2/ice/unittests/testClient.cpp b/project2/ice/unittests/testClient.cpp
index e979f82..e151055 100644
--- a/project2/ice/unittests/testClient.cpp
+++ b/project2/ice/unittests/testClient.cpp
@@ -105,13 +105,13 @@ void
commonTests(ExecContext * ec)
{
BOOST_TEST_CHECKPOINT("Verify loaded");
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexParam"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexRow"));
+ BOOST_REQUIRE(TaskFactory::get("UnitTest-SimpleInterface-SomeTask"));
+ BOOST_REQUIRE(TaskFactory::get("UnitTest-SimpleInterface-SomeTaskParams"));
+ BOOST_REQUIRE(RowSetFactory::get("UnitTest-SimpleInterface-SingleRow"));
+ BOOST_REQUIRE(RowSetFactory::get("UnitTest-SimpleInterface-SomeRows"));
+ BOOST_REQUIRE(RowSetFactory::get("UnitTest-SimpleInterface-SomeRowsParams"));
+ BOOST_REQUIRE(TaskFactory::get("UnitTestComplex-ComplexInterface-ComplexParam"));
+ BOOST_REQUIRE(RowSetFactory::get("UnitTestComplex-ComplexInterface-ComplexRow"));
BOOST_TEST_CHECKPOINT("Load test script");
ScriptReaderPtr r = new XmlScriptParser(iceroot / "testClient.xml");
@@ -142,13 +142,13 @@ void
unloadTests()
{
BOOST_TEST_CHECKPOINT("Verify unloaded");
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexParam"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexRow"), NotSupported);
+ BOOST_REQUIRE_THROW(TaskFactory::get("UnitTest-SimpleInterface-SomeTask"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(TaskFactory::get("UnitTest-SimpleInterface-SomeTaskParams"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(RowSetFactory::get("UnitTest-SimpleInterface-SingleRow"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(RowSetFactory::get("UnitTest-SimpleInterface-SomeRows"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(RowSetFactory::get("UnitTest-SimpleInterface-SomeRowsParams"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(TaskFactory::get("UnitTestComplex-ComplexInterface-ComplexParam"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(RowSetFactory::get("UnitTestComplex-ComplexInterface-ComplexRow"), AdHoc::NoSuchPluginException);
}
void test_client_run(ExecContext *, const boost::filesystem::path & tmpdir);
diff --git a/project2/ice/unittests/testClientCompile.cpp b/project2/ice/unittests/testClientCompile.cpp
index 0332da7..a299fff 100644
--- a/project2/ice/unittests/testClientCompile.cpp
+++ b/project2/ice/unittests/testClientCompile.cpp
@@ -21,11 +21,11 @@ void
commonTests()
{
BOOST_TEST_CHECKPOINT("Verify loaded");
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"));
- BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"));
+ BOOST_REQUIRE(TaskFactory::get("UnitTest-SimpleInterface-SomeTask"));
+ BOOST_REQUIRE(TaskFactory::get("UnitTest-SimpleInterface-SomeTaskParams"));
+ BOOST_REQUIRE(RowSetFactory::get("UnitTest-SimpleInterface-SingleRow"));
+ BOOST_REQUIRE(RowSetFactory::get("UnitTest-SimpleInterface-SomeRows"));
+ BOOST_REQUIRE(RowSetFactory::get("UnitTest-SimpleInterface-SomeRowsParams"));
}
static
@@ -33,11 +33,11 @@ void
unloadTests()
{
BOOST_TEST_CHECKPOINT("Verify unloaded");
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"), NotSupported);
- BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"), NotSupported);
+ BOOST_REQUIRE_THROW(TaskFactory::get("UnitTest-SimpleInterface-SomeTask"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(TaskFactory::get("UnitTest-SimpleInterface-SomeTaskParams"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(RowSetFactory::get("UnitTest-SimpleInterface-SingleRow"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(RowSetFactory::get("UnitTest-SimpleInterface-SomeRows"), AdHoc::NoSuchPluginException);
+ BOOST_REQUIRE_THROW(RowSetFactory::get("UnitTest-SimpleInterface-SomeRowsParams"), AdHoc::NoSuchPluginException);
}
BOOST_FIXTURE_TEST_SUITE( Core, TestAppInstance );
diff --git a/project2/ice/unittests/testDaemon.cpp b/project2/ice/unittests/testDaemon.cpp
index f12935d..3a31ebd 100644
--- a/project2/ice/unittests/testDaemon.cpp
+++ b/project2/ice/unittests/testDaemon.cpp
@@ -27,7 +27,7 @@ class DummyTask : public Task {
static unsigned int execCount;
};
-DECLARE_LOADER("DummyTask", DummyTask);
+NAMEDFACTORY("DummyTask", DummyTask, TaskFactory);
unsigned int DummyTask::execCount = 0;
class DummyParamTask : public Task {
@@ -53,7 +53,7 @@ class DummyParamTask : public Task {
static VariableType execA;
static VariableType execB;
};
-DECLARE_LOADER("DummyParamTask", DummyParamTask);
+NAMEDFACTORY("DummyParamTask", DummyParamTask, TaskFactory);
unsigned int DummyParamTask::execCount = 0;
VariableType DummyParamTask::execA;
VariableType DummyParamTask::execB;
@@ -85,7 +85,7 @@ class DummyComplexParamTask : public Task {
static VariableType execB;
static VariableType execD;
};
-DECLARE_LOADER("DummyComplexParamTask", DummyComplexParamTask);
+NAMEDFACTORY("DummyComplexParamTask", DummyComplexParamTask, TaskFactory);
unsigned int DummyComplexParamTask::execCount = 0;
VariableType DummyComplexParamTask::execA;
VariableType DummyComplexParamTask::execB;
@@ -96,8 +96,8 @@ void
commonTests()
{
BOOST_TEST_CHECKPOINT("Verify loaded");
- BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTest-SimpleInterface"));
- BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTestComplex-ComplexInterface"));
+ BOOST_REQUIRE(IceDaemonAdapterHandlerFactory::get("UnitTest-SimpleInterface"));
+ BOOST_REQUIRE(IceDaemonAdapterHandlerFactory::get("UnitTestComplex-ComplexInterface"));
int dummy = 0;
BOOST_TEST_CHECKPOINT("Run daemon");
@@ -195,7 +195,7 @@ void
unloadTests()
{
BOOST_TEST_CHECKPOINT("Verify unloaded");
- BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerLoader::createNew("UnitTest-SimpleInterface", NULL), NotSupported);
+ BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerFactory::createNew("UnitTest-SimpleInterface", NULL), AdHoc::NoSuchPluginException);
}
BOOST_FIXTURE_TEST_SUITE( Core, TestAppInstance );
diff --git a/project2/ice/unittests/testDaemonCompile.cpp b/project2/ice/unittests/testDaemonCompile.cpp
index 95fb6f2..c3f7064 100644
--- a/project2/ice/unittests/testDaemonCompile.cpp
+++ b/project2/ice/unittests/testDaemonCompile.cpp
@@ -18,7 +18,7 @@ void
commonTests()
{
BOOST_TEST_CHECKPOINT("Verify loaded");
- BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTest-SimpleInterface"));
+ BOOST_REQUIRE(IceDaemonAdapterHandlerFactory::get("UnitTest-SimpleInterface"));
}
static
@@ -26,7 +26,7 @@ void
unloadTests()
{
BOOST_TEST_CHECKPOINT("Verify unloaded");
- BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerLoader::createNew("UnitTest-SimpleInterface", NULL), NotSupported);
+ BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerFactory::createNew("UnitTest-SimpleInterface", NULL), AdHoc::NoSuchPluginException);
}
BOOST_FIXTURE_TEST_SUITE( Core, TestAppInstance );
diff --git a/project2/json/pch.hpp b/project2/json/pch.hpp
index 1309317..3aa19d4 100644
--- a/project2/json/pch.hpp
+++ b/project2/json/pch.hpp
@@ -2,10 +2,8 @@
#ifndef JSON_PCH
#define JSON_PCH
-#include <boost/variant.hpp>
+#include <boost/variant/variant_fwd.hpp>
#include <glibmm/ustring.h>
-#include <variables.h>
-#include <presenter.h>
#include <map>
#include <stack>
diff --git a/project2/json/presenter-p.cpp b/project2/json/presenter-p.cpp
index 92ba8c1..29db13c 100644
--- a/project2/json/presenter-p.cpp
+++ b/project2/json/presenter-p.cpp
@@ -20,4 +20,5 @@ class Json_P_Presenter : public JsonPresenter {
Variable Callback;
};
-DECLARE_GENERIC_LOADER("json-p", PresenterLoader, Json_P_Presenter)
+NAMEDFACTORY("json-p", Json_P_Presenter, PresenterFactory)
+
diff --git a/project2/json/presenter.cpp b/project2/json/presenter.cpp
index 8db182c..fe0a75d 100644
--- a/project2/json/presenter.cpp
+++ b/project2/json/presenter.cpp
@@ -141,4 +141,5 @@ JsonPresenter::writeTo(std::ostream & o, const std::string & encoding, ExecConte
}
}
-DECLARE_GENERIC_LOADER("json", PresenterLoader, JsonPresenter)
+NAMEDFACTORY("json", JsonPresenter, PresenterFactory);
+
diff --git a/project2/mail/sendmailTask.cpp b/project2/mail/sendmailTask.cpp
index 054f844..5442887 100644
--- a/project2/mail/sendmailTask.cpp
+++ b/project2/mail/sendmailTask.cpp
@@ -19,7 +19,7 @@ DECLARE_OPTIONS(SendMailTask, "Send Email Task options")
"The default encoding to use in email content")
END_OPTIONS(SendMailTask);
-DECLARE_LOADER("sendmail", SendMailTask);
+NAMEDFACTORY("sendmail", SendMailTask, TaskFactory);
uint8_t SendMailTask::MailPart::mimeIdx;
diff --git a/project2/mail/sendmailTask.h b/project2/mail/sendmailTask.h
index 035fe2b..e09b871 100644
--- a/project2/mail/sendmailTask.h
+++ b/project2/mail/sendmailTask.h
@@ -49,7 +49,6 @@ class SendMailTask : public Task {
PresenterPtr createDefaultPresenter(ScriptNodePtr n) const;
// Configurables
- friend class CustomSendMailTaskLoader;
friend class TransformWritableContentToEmail;
static std::string defaultMailServer;
static std::string defaultMailEncoding;
diff --git a/project2/processes/processStream.cpp b/project2/processes/processStream.cpp
index a4b5567..079def9 100644
--- a/project2/processes/processStream.cpp
+++ b/project2/processes/processStream.cpp
@@ -49,4 +49,5 @@ class ProcessStream : public Stream, IHaveParameters {
const Variable path;
};
-DECLARE_LOADER("processstream", ProcessStream);
+NAMEDFACTORY("processstream", ProcessStream, StreamFactory);
+
diff --git a/project2/regex/regexRows.cpp b/project2/regex/regexRows.cpp
index 6d72ccc..8939b2a 100644
--- a/project2/regex/regexRows.cpp
+++ b/project2/regex/regexRows.cpp
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <glibmm/regex.h>
-DECLARE_LOADER("regexrows", RegexRows);
+NAMEDFACTORY("regexrows", RegexRows, RowSetFactory);
RegexRows::RegexRows(ScriptNodePtr p) :
DefinedColumns(p, "columns", boost::bind(&Column::make, _1, _2)),
diff --git a/project2/regex/regexTest.cpp b/project2/regex/regexTest.cpp
index 59dca68..ab1bb47 100644
--- a/project2/regex/regexTest.cpp
+++ b/project2/regex/regexTest.cpp
@@ -3,7 +3,7 @@
#include "commonObjects.h"
#include <glibmm/regex.h>
-DECLARE_LOADER("regextest", RegexTest);
+NAMEDFACTORY("regextest", RegexTest, TestFactory);
RegexTest::RegexTest(ScriptNodePtr p) :
SourceObject(p),
diff --git a/project2/sql/pch.hpp b/project2/sql/pch.hpp
index e3dcda2..857eb5b 100644
--- a/project2/sql/pch.hpp
+++ b/project2/sql/pch.hpp
@@ -2,31 +2,11 @@
#ifndef SQL_PCH
#define SQL_PCH
-#include "cache.h"
-#include "column.h"
-#include "columns.h"
-#include "command.h"
-#include "commonObjects.h"
-#include "exceptions.h"
-#include "iHaveParameters.h"
-#include "logger.h"
-#include "modifycommand.h"
-#include "rdbmsDataSource.h"
-#include "rowProcessor.h"
-#include "rowSet.h"
-#include "selectcommand.h"
-#include "sqlHandleAsVariableType.h"
-#include "sqlVariableBinder.h"
-#include "sqlWriter.h"
-#include "variables.h"
-#include "scriptLoader.h"
-#include "scripts.h"
-#include <boost/bind.hpp>
-#include "options.h"
-#include <buffer.h>
-#include <column.h>
-#include <errno.h>
#include <stdexcept>
+#include <string>
+#include <glibmm/ustring.h>
+#include <boost/variant/variant_fwd.hpp>
+#include <connection.h>
#endif
#endif
diff --git a/project2/sql/rdbmsDataSource.cpp b/project2/sql/rdbmsDataSource.cpp
index e1091a3..46e97a8 100644
--- a/project2/sql/rdbmsDataSource.cpp
+++ b/project2/sql/rdbmsDataSource.cpp
@@ -7,8 +7,8 @@
#define LOCK(l) std::lock_guard<std::mutex> _lock##l(l)
-/// Specialized ElementLoader for instances of RdbmsDataSource; handles persistent DB connections
-class RdbmsDataSourceLoader : public ElementLoader::For<RdbmsDataSource> {
+/// Life cycle component for handling closure of persistent DB connections
+class RdbmsDataSourceFactory : public LifeCycle {
public:
void onIdle() override
{
@@ -32,7 +32,7 @@ class RdbmsDataSourceLoader : public ElementLoader::For<RdbmsDataSource> {
RdbmsDataSource::changedDSNs.clear();
}
};
-DECLARE_CUSTOM_LOADER("rdbmsdatasource", RdbmsDataSourceLoader);
+NAMEDFACTORY("rdbmsdatasource", RdbmsDataSource, DataSourceFactory);
RdbmsDataSource::DBHosts RdbmsDataSource::dbhosts;
RdbmsDataSource::FailedHosts RdbmsDataSource::failedhosts;
diff --git a/project2/sql/rdbmsDataSource.h b/project2/sql/rdbmsDataSource.h
index 4b7763f..979cec6 100644
--- a/project2/sql/rdbmsDataSource.h
+++ b/project2/sql/rdbmsDataSource.h
@@ -94,7 +94,7 @@ class RdbmsDataSource : public DataSource {
typedef std::set<ChangedDSN> ChangedDSNs;
static ChangedDSNs changedDSNs;
- friend class RdbmsDataSourceLoader;
+ friend class RdbmsDataSourceFactory;
};
#endif
diff --git a/project2/sql/sqlBulkLoad.cpp b/project2/sql/sqlBulkLoad.cpp
index d976997..4f17837 100644
--- a/project2/sql/sqlBulkLoad.cpp
+++ b/project2/sql/sqlBulkLoad.cpp
@@ -15,7 +15,7 @@ class SqlBulkLoad : public Task {
extras(p, "extras"),
db(NULL)
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&stream));
+ p->script->loader.addLoadTarget(p, Storer::into<StreamFactory>(&stream));
}
void loadComplete(const CommonObjects * co)
@@ -41,4 +41,5 @@ class SqlBulkLoad : public Task {
const RdbmsDataSource * db;
};
-DECLARE_LOADER("sqlbulkload", SqlBulkLoad);
+NAMEDFACTORY("sqlbulkload", SqlBulkLoad, TaskFactory);
+
diff --git a/project2/sql/sqlCache.cpp b/project2/sql/sqlCache.cpp
index cf33f8e..d20a8fc 100644
--- a/project2/sql/sqlCache.cpp
+++ b/project2/sql/sqlCache.cpp
@@ -253,7 +253,7 @@ class SqlCache : public RowSetCache {
INITOPTIONS;
private:
- friend class CustomSqlCacheLoader;
+ friend class CustomSqlCacheFactory;
const RdbmsDataSource * db;
static std::string DataSource;
static std::string HeaderTable;
@@ -264,7 +264,7 @@ std::string SqlCache::DataSource;
std::string SqlCache::HeaderTable;
time_t SqlCache::CacheLife;
-class CustomSqlCacheLoader : public ElementLoader::For<SqlCache> {
+class CustomSqlCacheFactory : public RowSetCacheFactory::For<SqlCache>, public LifeCycle {
public:
void onIdle() override
{
@@ -284,7 +284,7 @@ class CustomSqlCacheLoader : public ElementLoader::For<SqlCache> {
}
}
};
-DECLARE_CUSTOM_LOADER("sqlcache", CustomSqlCacheLoader);
+NAMEDPLUGIN("sqlcache", CustomSqlCacheFactory, RowSetCacheFactory);
DECLARE_OPTIONS(SqlCache, "SQL Cache options")
("cache.sql.dataSource", Options::value(&DataSource),
diff --git a/project2/sql/sqlMergeTask.cpp b/project2/sql/sqlMergeTask.cpp
index b6c504f..6e2e002 100644
--- a/project2/sql/sqlMergeTask.cpp
+++ b/project2/sql/sqlMergeTask.cpp
@@ -40,13 +40,13 @@ class SqlMergeInsert : IHaveParameters, public Task {
DB::ModifyCommand * insert;
};
-DECLARE_LOADER("sqlmerge", SqlMergeTask);
-DECLARE_LOADER("sqlmergeinsert", SqlMergeInsert);
+NAMEDFACTORY("sqlmerge", SqlMergeTask, TaskFactory);
+NAMEDFACTORY("sqlmergeinsert", SqlMergeInsert, TaskFactory);
// Conversion logic
SqlMergeTask::SqlMergeTask(const std::string & datasource, const std::string & target) :
SourceObject(__PRETTY_FUNCTION__),
- Task(NULL),
+ Task(__PRETTY_FUNCTION__),
insteadOfDelete(NULL),
updateWhere(NULL),
patchOrder(NULL),
@@ -85,7 +85,7 @@ SqlMergeTask::SqlMergeTask(ScriptNodePtr p) :
dtable(p->value("targettable", NULL).as<std::string>()),
dtablet(stringf("tmp_%s_%d", dtable.c_str(), getpid()))
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&sources));
+ p->script->loader.addLoadTarget(p, Storer::into<TaskFactory>(&sources));
if (!sources.empty() && useView(NULL)) {
throw NotSupported("useview not supported with iterate fillers");
@@ -265,11 +265,11 @@ SqlMergeTask::insertCommand() const
return destdb->newModifyCommand(ins);
}
-class Populate : public NoOutputExecute {
+class Populate : public Task {
public:
Populate(DB::ModifyCommand * c) :
SourceObject(__FUNCTION__),
- NoOutputExecute(__FUNCTION__),
+ Task(__FUNCTION__),
cmd(c)
{
}
diff --git a/project2/sql/sqlRows.cpp b/project2/sql/sqlRows.cpp
index f8a16e1..b6e40cc 100644
--- a/project2/sql/sqlRows.cpp
+++ b/project2/sql/sqlRows.cpp
@@ -10,7 +10,7 @@
#include "commonObjects.h"
#include <boost/date_time/gregorian/gregorian_types.hpp>
-DECLARE_LOADER("sqlrows", SqlRows);
+NAMEDFACTORY("sqlrows", SqlRows, RowSetFactory);
SqlRows::SqlRows(ScriptNodePtr p) :
RowSet(p),
diff --git a/project2/sql/sqlTask.cpp b/project2/sql/sqlTask.cpp
index a98748f..78c6d81 100644
--- a/project2/sql/sqlTask.cpp
+++ b/project2/sql/sqlTask.cpp
@@ -6,7 +6,7 @@
#include "commonObjects.h"
#include "sqlVariableBinder.h"
-DECLARE_LOADER("sqltask", SqlTask);
+NAMEDFACTORY("sqltask", SqlTask, TaskFactory);
StaticMessageException(RunOnNotSpecified, "runon attribute must be specified");
SqlTask::SqlTask(ScriptNodePtr p) :
@@ -17,8 +17,8 @@ SqlTask::SqlTask(ScriptNodePtr p) :
sqlCommand(p->child("sql")),
db(NULL)
{
- p->script->loader.addLoadTargetSub(p, "changes", false, Storer::into<ElementLoader>(&changesNOEs));
- p->script->loader.addLoadTargetSub(p, "nochanges", false, Storer::into<ElementLoader>(&noChangesNOEs));
+ p->script->loader.addLoadTargetSub(p, "changes", false, Storer::into<TaskFactory>(&changesTasks));
+ p->script->loader.addLoadTargetSub(p, "nochanges", false, Storer::into<TaskFactory>(&noChangesTasks));
}
SqlTask::~SqlTask()
@@ -40,12 +40,12 @@ SqlTask::execute(ExecContext * ec) const
unsigned int offset = 0;
sqlCommand.bindParams(ec, modify.get(), offset);
if (modify->execute() == 0) {
- for (const SubNOEs::value_type & sq : noChangesNOEs) {
+ for (const auto & sq : noChangesTasks) {
sq->execute(ec);
}
}
else {
- for (const SubNOEs::value_type & sq : changesNOEs) {
+ for (const auto & sq : changesTasks) {
sq->execute(ec);
}
}
diff --git a/project2/sql/sqlTask.h b/project2/sql/sqlTask.h
index 94901a9..20f7415 100644
--- a/project2/sql/sqlTask.h
+++ b/project2/sql/sqlTask.h
@@ -6,6 +6,7 @@
#include "task.h"
#include "variables.h"
#include "sqlWriter.h"
+#include <scriptStorage.h>
namespace DB { class ModifyCommand; }
class RdbmsDataSource;
@@ -21,9 +22,9 @@ class SqlTask : public Task {
const Variable dataSource;
const Variable filter;
- typedef ANONORDEREDSTORAGEOF(NoOutputExecute) SubNOEs;
- SubNOEs changesNOEs;
- SubNOEs noChangesNOEs;
+ typedef ANONORDEREDSTORAGEOF(Task) SubTasks;
+ SubTasks changesTasks;
+ SubTasks noChangesTasks;
protected:
const DynamicSql::SqlCommand sqlCommand;
diff --git a/project2/sql/sqlTest.cpp b/project2/sql/sqlTest.cpp
index fedc2a0..f3a5516 100644
--- a/project2/sql/sqlTest.cpp
+++ b/project2/sql/sqlTest.cpp
@@ -8,7 +8,7 @@
#include "sqlVariableBinder.h"
#include <boost/date_time/posix_time/posix_time.hpp>
-DECLARE_LOADER("sqltest", SqlTest);
+NAMEDFACTORY("sqltest", SqlTest, TestFactory);
class CantCompareNulls : public std::exception { };
diff --git a/project2/streams/streamNvpRows.cpp b/project2/streams/streamNvpRows.cpp
index 2e97a5f..01242cf 100644
--- a/project2/streams/streamNvpRows.cpp
+++ b/project2/streams/streamNvpRows.cpp
@@ -157,7 +157,7 @@ class StreamNvpRows : public RowSet {
assign(p->value("assign", "=", NULL).as<Glib::ustring>()),
encoding(p->value("encoding", "utf-8", NULL).as<std::string>())
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&stream));
+ p->script->loader.addLoadTarget(p, Storer::into<StreamFactory>(&stream));
}
void execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecContext * ec) const
@@ -178,5 +178,5 @@ class StreamNvpRows : public RowSet {
const Glib::ustring assign;
const std::string encoding;
};
-DECLARE_LOADER("streamnvprows", StreamNvpRows);
+NAMEDFACTORY("streamnvprows", StreamNvpRows, RowSetFactory);
diff --git a/project2/streams/streamPresenter.cpp b/project2/streams/streamPresenter.cpp
index 229799c..37553c3 100644
--- a/project2/streams/streamPresenter.cpp
+++ b/project2/streams/streamPresenter.cpp
@@ -8,7 +8,7 @@ class StreamPresenter : public Presenter, public SourceOf<WritableContent> {
StreamPresenter(ScriptNodePtr e, ObjectSource os, ExecContext * ) :
Presenter(os)
{
- e->script->loader.addLoadTarget(e, Storer::into<ElementLoader>(&stream));
+ e->script->loader.addLoadTarget(e, Storer::into<StreamFactory>(&stream));
}
void addNewArray(const Glib::ustring&, bool) const
@@ -44,4 +44,5 @@ class StreamPresenter : public Presenter, public SourceOf<WritableContent> {
StreamPtr stream;
};
-DECLARE_GENERIC_LOADER("stream", PresenterLoader, StreamPresenter)
+NAMEDFACTORY("stream", StreamPresenter, PresenterFactory);
+
diff --git a/project2/streams/streamRows.cpp b/project2/streams/streamRows.cpp
index c8f7ee1..a4f8aae 100644
--- a/project2/streams/streamRows.cpp
+++ b/project2/streams/streamRows.cpp
@@ -55,7 +55,7 @@ class StreamRows : public DefinedColumns, public RowSet {
encoding(p->value("encoding", "utf-8", NULL).as<std::string>()),
skipheader(p->value("skipheader", 0, NULL).as<int64_t>())
{
- p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&stream));
+ p->script->loader.addLoadTarget(p, Storer::into<StreamFactory>(&stream));
}
void execute(const Glib::ustring &, const RowProcessorCallback & rp, ExecContext * ec) const
@@ -143,5 +143,5 @@ class StreamRows : public DefinedColumns, public RowSet {
const std::string encoding;
const size_t skipheader;
};
-DECLARE_LOADER("streamrows", StreamRows);
+NAMEDFACTORY("streamrows", StreamRows, RowSetFactory);
diff --git a/project2/streams/viewStream.cpp b/project2/streams/viewStream.cpp
index 17763ab..0f2308a 100644
--- a/project2/streams/viewStream.cpp
+++ b/project2/streams/viewStream.cpp
@@ -5,6 +5,7 @@
#include "viewHost.h"
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/concepts.hpp>
+#include <scripts.h>
class SinkStream : public boost::iostreams::sink {
public:
@@ -27,7 +28,7 @@ class ViewStream : public Stream, public ViewHost {
Stream(p),
ViewHost(p)
{
- p->script->loader.addLoadTarget(p, Storer::into<PresenterLoader>(&presenter, Scripted, (ExecContext*)NULL));
+ p->script->loader.addLoadTarget(p, Storer::into<PresenterFactory>(&presenter, Scripted, (ExecContext*)NULL));
}
void runStream(const Stream::Sink & s, ExecContext * ec) const
{
@@ -49,4 +50,5 @@ class ViewStream : public Stream, public ViewHost {
MultiRowSetPresenterPtr presenter;
};
-DECLARE_LOADER("viewstream", ViewStream);
+NAMEDFACTORY("viewstream", ViewStream, StreamFactory);
+
diff --git a/project2/url/downloadToFile.cpp b/project2/url/downloadToFile.cpp
index af23112..3b90ffc 100644
--- a/project2/url/downloadToFile.cpp
+++ b/project2/url/downloadToFile.cpp
@@ -31,5 +31,5 @@ class Download : public Task, VariableCurlHelper {
const Variable destination;
};
-DECLARE_LOADER("download", Download);
+NAMEDFACTORY("download", Download, TaskFactory);
diff --git a/project2/url/urlStream.cpp b/project2/url/urlStream.cpp
index e3ee862..21bf5c2 100644
--- a/project2/url/urlStream.cpp
+++ b/project2/url/urlStream.cpp
@@ -19,5 +19,5 @@ class UrlStream : public Stream, VariableCurlHelper {
}
};
-DECLARE_LOADER("urlstream", UrlStream);
+NAMEDFACTORY("urlstream", UrlStream, StreamFactory);
diff --git a/project2/ut/butf_logger.cpp b/project2/ut/butf_logger.cpp
index c5f45b4..42afd41 100644
--- a/project2/ut/butf_logger.cpp
+++ b/project2/ut/butf_logger.cpp
@@ -1,6 +1,6 @@
#include <boost/test/unit_test_log.hpp>
-#include "logger.h"
-#include "options.h"
+#include <loggerFactory.impl.h>
+#include <options.h>
/// Logger that writes Boost Unit Test Framework messages
class BoostUTFLogDriver : public LogDriverBase {
@@ -17,5 +17,5 @@ class BoostUTFLogDriver : public LogDriverBase {
int BoostUTFLogDriver::level = LOG_DEBUG;
-DECLARE_LOGGER_LOADER("boostutf", BoostUTFLogDriver);
+DECLARE_LOGGER("boostutf", BoostUTFLogDriver);
diff --git a/project2/ut/testScriptHost.cpp b/project2/ut/testScriptHost.cpp
index c3090ff..c989abb 100644
--- a/project2/ut/testScriptHost.cpp
+++ b/project2/ut/testScriptHost.cpp
@@ -11,7 +11,7 @@ TestScriptHost::TestScriptHost(ScriptReaderPtr script) :
ViewHost(script->root())
{
Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__);
- script->loader.addLoadTarget(script->root(), Storer::into<PresenterLoader>(&presenter, Scripted, (ExecContext*)NULL));
+ script->loader.addLoadTarget(script->root(), Storer::into<PresenterFactory>(&presenter, Scripted, (ExecContext*)NULL));
}
TestScriptHost::~TestScriptHost()
diff --git a/project2/xml/mutators/copy.cpp b/project2/xml/mutators/copy.cpp
index f58bef7..c94d76d 100644
--- a/project2/xml/mutators/copy.cpp
+++ b/project2/xml/mutators/copy.cpp
@@ -27,5 +27,5 @@ class Copy : public XmlDocMutator {
Variable delAfter;
};
-DECLARE_GENERIC_LOADER("copy", XmlDocMutatorLoader, Copy);
+NAMEDFACTORY("copy", Copy, XmlDocMutatorFactory);
diff --git a/project2/xml/mutators/copyToAttr.cpp b/project2/xml/mutators/copyToAttr.cpp
index a58ac93..6311f1a 100644
--- a/project2/xml/mutators/copyToAttr.cpp
+++ b/project2/xml/mutators/copyToAttr.cpp
@@ -31,6 +31,5 @@ class CopyToAttr : public XmlDocMutator {
Variable delAfter;
};
-DECLARE_GENERIC_LOADER("copytoattr", XmlDocMutatorLoader, CopyToAttr);
-
+NAMEDFACTORY("copytoattr", CopyToAttr, XmlDocMutatorFactory);
diff --git a/project2/xml/mutators/create.cpp b/project2/xml/mutators/create.cpp
index 88d8808..645914f 100644
--- a/project2/xml/mutators/create.cpp
+++ b/project2/xml/mutators/create.cpp
@@ -20,4 +20,5 @@ class Create : public XmlDocMutator {
Variable name;
};
-DECLARE_GENERIC_LOADER("create", XmlDocMutatorLoader, Create);
+NAMEDFACTORY("create", Create, XmlDocMutatorFactory);
+
diff --git a/project2/xml/mutators/delete.cpp b/project2/xml/mutators/delete.cpp
index 6e4d597..f1c3f61 100644
--- a/project2/xml/mutators/delete.cpp
+++ b/project2/xml/mutators/delete.cpp
@@ -18,6 +18,5 @@ class Delete : public XmlDocMutator {
Variable xpath;
};
-DECLARE_GENERIC_LOADER("delete", XmlDocMutatorLoader, Delete);
-
+NAMEDFACTORY("delete", Delete, XmlDocMutatorFactory);
diff --git a/project2/xml/mutators/rename.cpp b/project2/xml/mutators/rename.cpp
index ec347d8..ed1a5ca 100644
--- a/project2/xml/mutators/rename.cpp
+++ b/project2/xml/mutators/rename.cpp
@@ -20,7 +20,5 @@ class Rename : public XmlDocMutator {
Variable newname;
};
-DECLARE_GENERIC_LOADER("rename", XmlDocMutatorLoader, Rename);
-
-
+NAMEDFACTORY("rename", Rename, XmlDocMutatorFactory);
diff --git a/project2/xml/pch.hpp b/project2/xml/pch.hpp
index 1eb8309..5832628 100644
--- a/project2/xml/pch.hpp
+++ b/project2/xml/pch.hpp
@@ -2,16 +2,8 @@
#ifndef XML_PCH
#define XML_PCH
-#include "cache.h"
-#include "exceptions.h"
-#include "iHaveParameters.h"
-#include "logger.h"
-#include "presenter.h"
-#include "rowProcessor.h"
-#include "safeMapFind.h"
-#include "variables.h"
#include <boost/filesystem/path.hpp>
-#include "options.h"
+#include <boost/variant/variant_fwd.hpp>
#include <libxml++/document.h>
#include <libxml++/nodes/element.h>
#include <libxml++/nodes/textnode.h>
diff --git a/project2/xml/rawView.cpp b/project2/xml/rawView.cpp
index ace271c..69009aa 100644
--- a/project2/xml/rawView.cpp
+++ b/project2/xml/rawView.cpp
@@ -68,7 +68,7 @@ class RawView : public RawViewBase {
private:
const xmlpp::Element * copyRoot;
};
-DECLARE_LOADER("rawview", RawView);
+NAMEDFACTORY("rawview", RawView, ViewFactory);
class XmlResourceView : public RawViewBase, XmlDocumentCache, VariableCurlHelper {
public:
@@ -91,5 +91,5 @@ class XmlResourceView : public RawViewBase, XmlDocumentCache, VariableCurlHelper
private:
Variable encoding;
};
-DECLARE_LOADER("xmlresourceview", XmlResourceView);
+NAMEDFACTORY("xmlresourceview", XmlResourceView, ViewFactory);
diff --git a/project2/xml/sessionXml.cpp b/project2/xml/sessionXml.cpp
index 866d5b2..403e91a 100644
--- a/project2/xml/sessionXml.cpp
+++ b/project2/xml/sessionXml.cpp
@@ -10,7 +10,7 @@
#include "options.h"
#include "logger.h"
-class CustomSessionContainerLoaderXml : public SessionContainerLoader::For<SessionContainerXml> {
+class CustomSessionContainerFactoryXml : public SessionContainerFactory::For<SessionContainerXml>, public LifeCycle {
public:
void onPeriodic() override
{
@@ -38,7 +38,7 @@ DECLARE_OPTIONS(SessionContainerXml, "Session XML options")
END_OPTIONS(SessionContainerXml)
boost::filesystem::path SessionContainerXml::xmlDir;
-DECLARE_CUSTOM_COMPONENT_LOADER("xml", SessionContainerXml, CustomSessionContainerLoaderXml, SessionContainerLoader);
+NAMEDPLUGIN("xml", CustomSessionContainerFactoryXml, SessionContainerFactory);
SessionContainerXml::SessionContainerXml()
{
diff --git a/project2/xml/sessionXml.h b/project2/xml/sessionXml.h
index 4288d9e..d3300bd 100644
--- a/project2/xml/sessionXml.h
+++ b/project2/xml/sessionXml.h
@@ -18,7 +18,7 @@ class SessionContainerXml : public SessionContainer {
private:
// Configurables
static boost::filesystem::path xmlDir;
- friend class CustomSessionContainerLoaderXml;
+ friend class CustomSessionContainerFactoryXml;
};
#endif
diff --git a/project2/xml/transformHtml.cpp b/project2/xml/transformHtml.cpp
index 6d1e925..2cfc181 100644
--- a/project2/xml/transformHtml.cpp
+++ b/project2/xml/transformHtml.cpp
@@ -82,21 +82,20 @@ class TransformXmlToHtml : public TransformImpl<xmlpp::Document, HtmlDocument> {
}
};
-class XmlTransformLoader : public TransformLoader::For<TransformXmlToHtml> {
- public:
- XmlTransformLoader()
- {
- xmlInitParser();
- exsltRegisterAll();
- }
+static void initLibXml() __attribute__((constructor(102)));
+void initLibXml()
+{
+ xmlInitParser();
+ exsltRegisterAll();
+}
- ~XmlTransformLoader()
- {
- xsltCleanupGlobals();
- xmlCleanupParser();
- }
-};
+static void cleanupLibXml() __attribute__((constructor(102)));
+void cleanupLibXml()
+{
+ xsltCleanupGlobals();
+ xmlCleanupParser();
+}
-DECLARE_CUSTOM_COMPONENT_LOADER("TransformXmlToHtml", TransformXmlToHtml, XmlTransformLoader, TransformLoader)
-DECLARE_TRANSFORMTARGET("htmldocument", HtmlDocument)
+NAMEDFACTORY("TransformXmlToHtml", TransformXmlToHtml, TransformFactory);
+NAMEDFACTORY("htmldocument", HtmlDocument, TransformTargetFactory);
diff --git a/project2/xml/transformText.cpp b/project2/xml/transformText.cpp
index 662674d..525b910 100644
--- a/project2/xml/transformText.cpp
+++ b/project2/xml/transformText.cpp
@@ -96,6 +96,6 @@ END_OPTIONS(TransformHtmlToText)
int TransformHtmlToText::defaultWidth;
bool TransformHtmlToText::defaultLinks;
-DECLARE_COMPONENT_LOADER("TransformHtmlToText", TransformHtmlToText, TransformLoader);
-DECLARE_TRANSFORMTARGET("textdocument", TextDocument)
+NAMEDFACTORY("TransformHtmlToText", TransformHtmlToText, TransformFactory);
+NAMEDFACTORY("textdocument", TextDocument, TransformTargetFactory)
diff --git a/project2/xml/xmlCache.cpp b/project2/xml/xmlCache.cpp
index 52e693a..40adec9 100644
--- a/project2/xml/xmlCache.cpp
+++ b/project2/xml/xmlCache.cpp
@@ -74,7 +74,7 @@ class XmlCache : public RowSetCache {
XmlPresenterPtr writeTo;
- friend class CustomXmlCacheLoader;
+ friend class CustomXmlCacheFactory;
static boost::filesystem::path Store;
static std::string FileName;
static time_t CacheLife;
@@ -84,7 +84,7 @@ boost::filesystem::path XmlCache::Store;
std::string XmlCache::FileName;
time_t XmlCache::CacheLife;
-class CustomXmlCacheLoader : public ElementLoader::For<XmlCache> {
+class CustomXmlCacheFactory : public AdHoc::Factory<RowSetCache, ScriptNodePtr>::For<XmlCache>, public LifeCycle {
public:
void onIdle() override
{
@@ -125,7 +125,7 @@ class CustomXmlCacheLoader : public ElementLoader::For<XmlCache> {
return files;
}
};
-DECLARE_CUSTOM_LOADER("xmlcache", CustomXmlCacheLoader);
+NAMEDPLUGIN("xmlcache", CustomXmlCacheFactory, RowSetCacheFactory);
DECLARE_OPTIONS(XmlCache, "XML Cache options")
("cache.xml.store", Options::value(&XmlCache::Store, "/tmp/project2.cache"),
diff --git a/project2/xml/xmlDocumentCache.cpp b/project2/xml/xmlDocumentCache.cpp
index 81833f9..98e4993 100644
--- a/project2/xml/xmlDocumentCache.cpp
+++ b/project2/xml/xmlDocumentCache.cpp
@@ -58,7 +58,7 @@ XmlDocumentCache::queue(const Glib::ustring & url, const char *, ExecContext *)
}
}
-class XmlDocumentCacheClearer : public ComponentLoader {
+class XmlDocumentCacheClearer : public LifeCycle {
public:
typedef bool KeyType;
@@ -69,5 +69,5 @@ class XmlDocumentCacheClearer : public ComponentLoader {
Logger()->messagef(LOG_DEBUG, "%s: Cleared XML document cache", __PRETTY_FUNCTION__);
}
};
-DECLARE_COMPONENT("XmlDocumentCacheClearer", XmlDocumentCacheClearer);
+NAMEDPLUGIN("XmlDocumentCacheClearer", XmlDocumentCacheClearer, LifeCycle);
diff --git a/project2/xml/xmlDocumentPrefetch.cpp b/project2/xml/xmlDocumentPrefetch.cpp
index 4af0055..357f50b 100644
--- a/project2/xml/xmlDocumentPrefetch.cpp
+++ b/project2/xml/xmlDocumentPrefetch.cpp
@@ -2,7 +2,8 @@
#include "xmlDocumentPrefetch.h"
#include "scriptLoader.h"
-DECLARE_LOADER("xmldocumentprefetch", XmlDocumentPrefetch);
+NAMEDFACTORY("xmldocumentprefetch", XmlDocumentPrefetch, ViewFactory);
+NAMEDFACTORY("xmldocumentprefetch", XmlDocumentPrefetch, TaskFactory);
XmlDocumentPrefetch::XmlDocumentPrefetch(ScriptNodePtr p) :
SourceObject(p),
diff --git a/project2/xml/xmlPresenter.cpp b/project2/xml/xmlPresenter.cpp
index a43f9f8..ec3d2f3 100644
--- a/project2/xml/xmlPresenter.cpp
+++ b/project2/xml/xmlPresenter.cpp
@@ -7,7 +7,7 @@
#include <libxml++/document.h>
#include <boost/date_time/posix_time/time_formatters.hpp>
#include <boost/date_time/gregorian/formatters.hpp>
-#include "instanceStore.impl.h"
+#include <factory.impl.h>
DECLARE_OPTIONS(XmlPresenter, "XML Presenter options")
("presenter.xml.typeid.null", Options::value(&typeidNull, false),
@@ -43,7 +43,7 @@ bool XmlPresenter::dateAttr;
bool XmlPresenter::timeAttr;
boost::optional<std::string> XmlPresenter::customFormat;
-DECLARE_GENERIC_LOADER("xml", PresenterLoader, XmlPresenter)
+NAMEDFACTORY("xml", XmlPresenter, PresenterFactory)
XmlPresenter::XmlPresenter(const Glib::ustring & responseRootNodeName, const Glib::ustring & responseStyle, const Glib::ustring & ct) :
Presenter(Default),
@@ -67,7 +67,7 @@ XmlPresenter::XmlPresenter(ScriptNodePtr e, ObjectSource os, ExecContext * ec) :
style(e, "style", Null())
{
if (os == Scripted) {
- e->script->loader.addLoadTarget(e, Storer::into<XmlDocMutatorLoader>(&mutators));
+ e->script->loader.addLoadTarget(e, Storer::into<XmlDocMutatorFactory>(&mutators));
}
}
@@ -275,5 +275,5 @@ XmlDocMutator::XmlDocMutator(ScriptNodePtr)
{
}
-INSTANTIATESTORE(std::string, XmlDocMutatorLoader);
+INSTANTIATEFACTORY(XmlDocMutator, ScriptNodePtr);
diff --git a/project2/xml/xmlPresenter.h b/project2/xml/xmlPresenter.h
index 6e3dac2..996ce9b 100644
--- a/project2/xml/xmlPresenter.h
+++ b/project2/xml/xmlPresenter.h
@@ -18,7 +18,7 @@ class XmlDocMutator : public IntrusivePtrBase {
virtual void mutateElement(xmlpp::Element *) const = 0;
};
typedef boost::intrusive_ptr<XmlDocMutator> XmlDocMutatorPtr;
-typedef GenLoader<XmlDocMutator, std::string, ScriptNodePtr> XmlDocMutatorLoader;
+typedef AdHoc::Factory<XmlDocMutator, ScriptNodePtr> XmlDocMutatorFactory;
class XmlPresenter : public Presenter, public ContentPresenter, public SourceOf<xmlpp::Document>, public SourceOf<xmlDoc>, public SourceOf<boost::shared_ptr<xmlpp::Document> >, public WritableContent, public SourceOf<WritableContent> {
public:
diff --git a/project2/xml/xmlRawRows.cpp b/project2/xml/xmlRawRows.cpp
index eb6e003..5b46279 100644
--- a/project2/xml/xmlRawRows.cpp
+++ b/project2/xml/xmlRawRows.cpp
@@ -3,7 +3,7 @@
#include <libxml++/parsers/domparser.h>
#include <libxml++/nodes/textnode.h>
-DECLARE_LOADER("xmlrawrows", XmlRawRows);
+NAMEDFACTORY("xmlrawrows", XmlRawRows, RowSetFactory);
class XmlRowState : public RowState {
public:
diff --git a/project2/xml/xmlRows.cpp b/project2/xml/xmlRows.cpp
index 2d3e631..1277274 100644
--- a/project2/xml/xmlRows.cpp
+++ b/project2/xml/xmlRows.cpp
@@ -10,7 +10,7 @@
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/predicate.hpp>
-DECLARE_LOADER("xmlrows", XmlRows);
+NAMEDFACTORY("xmlrows", XmlRows, RowSetFactory);
XmlRows::XmlRows(ScriptNodePtr p) :
RowSet(p),
diff --git a/project2/xml/xmlScriptParser.cpp b/project2/xml/xmlScriptParser.cpp
index 1c4c798..33b464e 100644
--- a/project2/xml/xmlScriptParser.cpp
+++ b/project2/xml/xmlScriptParser.cpp
@@ -90,9 +90,9 @@ XmlScriptParser::isCurrent() const
return true;
}
-class XmlScriptReaderLoader : public ScriptReaderLoader {
+class XmlScriptReaderFactory : public ScriptReaderFactory {
public:
- ScriptReaderPtr resolveScript(const std::string & group, const std::string & name) const {
+ XmlScriptParser * create(const std::string & group, const std::string & name) const {
boost::filesystem::path script(boost::filesystem::path(group) / (name + ".xml"));
if (boost::filesystem::is_regular_file(script)) {
return new XmlScriptParser(script);
@@ -187,7 +187,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 InstanceMap<VariableLoader, std::string>::Get<UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(c, script));
+ return VariableFactory::createNew(source->get_value(), new XmlScriptNode(c, script));
}
else {
return new VariableLiteral(new XmlScriptNode(c, script));
@@ -201,10 +201,10 @@ VariableImpl *
XmlScriptNode::variable(const boost::optional<Glib::ustring> & defaultSource) const
{
if (const xmlpp::Attribute * source = element->get_attribute("source")) {
- return InstanceMap<VariableLoader, std::string>::Get<UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(element, script));
+ return VariableFactory::createNew(source->get_value(), new XmlScriptNode(element, script));
}
else if (defaultSource) {
- return InstanceMap<VariableLoader, std::string>::Get<UnknownVariableSource>(defaultSource.get())->create(new XmlScriptNode(element, script));
+ return VariableFactory::createNew(defaultSource.get(), new XmlScriptNode(element, script));
}
else {
return new VariableLiteral(new XmlScriptNode(element, script));
@@ -223,7 +223,7 @@ XmlScriptNode::applyValue(const Glib::ustring & n, VariableType & val, ExecConte
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 = InstanceMap<VariableLoader, std::string>::Get<UnknownVariableSource>(source->get_value())->create(new XmlScriptNode(c, script));
+ v = VariableFactory::createNew(source->get_value(), new XmlScriptNode(c, script));
}
else {
v = new VariableLiteral(new XmlScriptNode(c, script));
@@ -248,4 +248,5 @@ XmlScriptNode::composeWithCallbacks(const LiteralCallback & lcb, const NodeCallb
}
}
-DECLARE_CUSTOM_COMPONENT_LOADER("xmlScriptReader", XmlScriptReaderLoader, XmlScriptReaderLoader, ScriptReaderLoader);
+NAMEDPLUGIN("xmlScriptReader", XmlScriptReaderFactory, ScriptReaderFactory);
+
diff --git a/project2/xml/xpathRows.cpp b/project2/xml/xpathRows.cpp
index 656bbac..0501012 100644
--- a/project2/xml/xpathRows.cpp
+++ b/project2/xml/xpathRows.cpp
@@ -9,7 +9,7 @@
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
-DECLARE_LOADER("xpathrows", XPathRows);
+NAMEDFACTORY("xpathrows", XPathRows, RowSetFactory);
SimpleMessageException(XpathInitError);
SimpleMessageException(XpathEvalError);