summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-09-30 23:48:05 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-09-30 23:48:05 +0100
commitd10b8914aeb4f297d6b6deca2408cd81b1adad08 (patch)
tree25fb41739387671e8e7a183778686ffdc5a29b4c
parentRemove NoOutputExecute for not being a thing (diff)
downloadproject2-d10b8914aeb4f297d6b6deca2408cd81b1adad08.tar.bz2
project2-d10b8914aeb4f297d6b6deca2408cd81b1adad08.tar.xz
project2-d10b8914aeb4f297d6b6deca2408cd81b1adad08.zip
Use AdHoc plugins for scriptable things and remove legacy plugin support
-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.cpp4
-rw-r--r--project2/basics/if.cpp10
-rw-r--r--project2/basics/options/showHelp.cpp2
-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.cpp1
-rw-r--r--project2/cgi/cgiContentNegotiate.cpp8
-rw-r--r--project2/cgi/cgiOutputOptions.cpp15
-rw-r--r--project2/cgi/cgiOutputOptions.h12
-rw-r--r--project2/cgi/cgiProgRouter.cpp14
-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/p2webCgi.cpp1
-rw-r--r--project2/cgi/p2webFCgi.cpp1
-rw-r--r--project2/cgi/testCgi.cpp5
-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.cpp2
-rw-r--r--project2/common/componentLoader.h12
-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/instanceStore.h52
-rw-r--r--project2/common/instanceStore.impl.h97
-rw-r--r--project2/common/library.cpp5
-rw-r--r--project2/common/optionsSource.cpp1
-rw-r--r--project2/common/plugable.cpp1
-rw-r--r--project2/common/plugable.h70
-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.cpp11
-rw-r--r--project2/common/scriptLoader.h7
-rw-r--r--project2/common/scriptStorage.h10
-rw-r--r--project2/common/scripts.cpp7
-rw-r--r--project2/common/scripts.h9
-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.cpp3
-rw-r--r--project2/common/task.h1
-rw-r--r--project2/common/taskHost.cpp3
-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/variables.cpp1
-rw-r--r--project2/common/variables/lookup.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/compression/decompressStream.cpp5
-rw-r--r--project2/console/consoleAppEngine.cpp1
-rw-r--r--project2/console/p2consoleMain.cpp1
-rw-r--r--project2/daemon/p2daemonAppEngine.cpp1
-rw-r--r--project2/daemon/p2daemonMain.cpp1
-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/presenterCache.cpp5
-rw-r--r--project2/files/writeStream.cpp4
-rw-r--r--project2/ice/iceDaemon.cpp2
-rw-r--r--project2/ice/iceDataSource.cpp4
-rw-r--r--project2/ice/iceRows.h3
-rw-r--r--project2/ice/iceTask.h5
-rw-r--r--project2/ice/slice2Common.cpp6
-rw-r--r--project2/ice/slice2Common.h2
-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.cpp6
-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/processes/processStream.cpp3
-rw-r--r--project2/regex/regexRows.cpp2
-rw-r--r--project2/regex/regexTest.cpp2
-rw-r--r--project2/sql/rdbmsDataSource.cpp4
-rw-r--r--project2/sql/sqlBulkLoad.cpp5
-rw-r--r--project2/sql/sqlCache.cpp4
-rw-r--r--project2/sql/sqlMergeTask.cpp6
-rw-r--r--project2/sql/sqlRows.cpp2
-rw-r--r--project2/sql/sqlTask.cpp6
-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/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/rawView.cpp4
-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.cpp2
-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.cpp7
-rw-r--r--project2/xml/xpathRows.cpp2
153 files changed, 355 insertions, 569 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..5d58a47 100644
--- a/project2/basics/caches/memoryCache.cpp
+++ b/project2/basics/caches/memoryCache.cpp
@@ -145,7 +145,7 @@ class MemoryCache : public RowSetCache {
time_t MemoryCache::CacheLife;
MemoryCache::CacheStore MemoryCache::Store;
-class CustomMemoryCacheLoader : public ElementLoader::For<MemoryCache> {
+class CustomMemoryCacheLoader : public RowSetCacheFactory::For<MemoryCache>, public ComponentLoader {
public:
void onPeriodic() override {
typedef MemoryCache::CacheStore::index<MemoryCache::IndexByTime>::type::iterator iter;
@@ -156,7 +156,7 @@ class CustomMemoryCacheLoader : public ElementLoader::For<MemoryCache> {
INITOPTIONS;
};
-DECLARE_CUSTOM_LOADER("memorycache", CustomMemoryCacheLoader);
+NAMEDPLUGIN("memorycache", CustomMemoryCacheLoader, RowSetCacheFactory);
DECLARE_OPTIONS(CustomMemoryCacheLoader, "Memory Cache options")
("cache.memory.life", Options::value(&MemoryCache::CacheLife, 3600),
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/options/showHelp.cpp b/project2/basics/options/showHelp.cpp
index b7f481c..81c9150 100644
--- a/project2/basics/options/showHelp.cpp
+++ b/project2/basics/options/showHelp.cpp
@@ -29,5 +29,5 @@ ShowHelpComponent::Option()
}
bool ShowHelpComponent::showHelp;
-DECLARE_COMPONENT("ShowHelpComponent", ShowHelpComponent);
+NAMEDPLUGIN("ShowHelpComponent", ShowHelpComponent, ComponentLoader);
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 2b7b988..a263a38 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -15,6 +15,7 @@
#include <boost/lexical_cast.hpp>
#include <glibmm/exception.h>
#include <cxxabi.h>
+#include <plugable.h>
#include <glibmm/regex.h>
typedef boost::uuids::uuid SIDKey;
diff --git a/project2/cgi/cgiContentNegotiate.cpp b/project2/cgi/cgiContentNegotiate.cpp
index 2494ba8..929159f 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 ContentNegotiateLoader : 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;
@@ -46,7 +46,7 @@ class ContentNegotiateLoader : public PresenterLoader {
};
ContentNegotiateLoader::MappedTypes ContentNegotiateLoader::mappedTypes;
-DECLARE_CUSTOM_COMPONENT_LOADER("contentnegotiate", ContentNegotiateLoader, ContentNegotiateLoader, PresenterLoader);
+NAMEDPLUGIN("contentnegotiate", ContentNegotiateLoader, PresenterFactory);
DECLARE_OPTIONS(ContentNegotiateLoader, "Content negotiation options")
("cgi.contentnegotiation.mappedtype", Options::functions(
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 fef9ed8..da04be6 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,8 +127,7 @@ class RoutingTable {
std::list<RoutePtr> routes;
};
-typedef RoutingTable::Route Route;
-DECLARE_LOADER("route", Route);
+NAMEDFACTORY("route", RoutingTable::Route, RoutingTable::RouteFactory);
class ProgRouter;
class ProgRouterFactory : public RouterFactory::For<ProgRouter>, public ComponentLoader {
@@ -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/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/p2webCgi.cpp b/project2/cgi/p2webCgi.cpp
index a4e2328..a59621d 100644
--- a/project2/cgi/p2webCgi.cpp
+++ b/project2/cgi/p2webCgi.cpp
@@ -1,5 +1,6 @@
#include "cgiAppEngine.h"
#include <boost/bind.hpp>
+#include <plugable.h>
class GetEnv : public CgiEnvInput {
public:
diff --git a/project2/cgi/p2webFCgi.cpp b/project2/cgi/p2webFCgi.cpp
index 42a99bc..e31986d 100644
--- a/project2/cgi/p2webFCgi.cpp
+++ b/project2/cgi/p2webFCgi.cpp
@@ -2,6 +2,7 @@
#include "cgiAppEngine.h"
#include <boost/bind.hpp>
#include <boost/filesystem/convenience.hpp>
+#include <plugable.h>
time_t lastPeriodic = 0;
time_t periodicDelay = 600;
diff --git a/project2/cgi/testCgi.cpp b/project2/cgi/testCgi.cpp
index b61a475..3c79a77 100644
--- a/project2/cgi/testCgi.cpp
+++ b/project2/cgi/testCgi.cpp
@@ -8,6 +8,7 @@
#include "cgiRequestContext.h"
#include "cgiAppEngine.h"
#include <options/showHelp.h>
+#include <plugable.h>
#define TESTOPT(name, def, desc) \
(name, Options::value(optStore().insert(OptStore::value_type(name, StrPtr(new std::string()))).first->second.get(), def), desc)
@@ -16,7 +17,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;
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
index 56eb833..5506ed2 100644
--- a/project2/common/componentLoader.cpp
+++ b/project2/common/componentLoader.cpp
@@ -1,4 +1,5 @@
#include "componentLoader.h"
+#include <plugins.impl.h>
ComponentLoader::~ComponentLoader()
{
@@ -34,4 +35,5 @@ ComponentLoader::onConfigLoad()
{
}
+INSTANTIATEPLUGINOF(ComponentLoader);
diff --git a/project2/common/componentLoader.h b/project2/common/componentLoader.h
index 45664e3..d3cff99 100644
--- a/project2/common/componentLoader.h
+++ b/project2/common/componentLoader.h
@@ -1,10 +1,10 @@
#ifndef COMPONENTLOADER_H
#define COMPONENTLOADER_H
-#include "plugable.h"
+#include <plugins.h>
/// Helper for loading and maintaining Project2 components
-class ComponentLoader {
+class ComponentLoader : public virtual AdHoc::AbstractPluginImplementation {
public:
virtual ~ComponentLoader() = 0;
virtual void onBegin(); // App engine start up (before settings are processed)
@@ -15,13 +15,7 @@ class ComponentLoader {
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); }
+typedef AdHoc::PluginOf<ComponentLoader> LifeCycleComponentPlugin;
#endif
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/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..ce753bd 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 ComponentLoader {
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/optionsSource.cpp b/project2/common/optionsSource.cpp
index 1739ed5..f10ff4f 100644
--- a/project2/common/optionsSource.cpp
+++ b/project2/common/optionsSource.cpp
@@ -1,6 +1,7 @@
#include "optionsSource.h"
#include "logger.h"
#include <plugins.impl.h>
+#include <plugable.h>
class DefaultConfigConsumer : public ConfigConsumer {
public:
diff --git a/project2/common/plugable.cpp b/project2/common/plugable.cpp
index 15d8cda..deb7910 100644
--- a/project2/common/plugable.cpp
+++ b/project2/common/plugable.cpp
@@ -5,7 +5,6 @@
void
Plugable::onAllComponents(const boost::function<void(ComponentLoader *)> & func)
{
- InstanceSet<ComponentLoader>::OnAll(func);
for(auto p : AdHoc::PluginManager::getDefault()->getAll()) {
if (auto c = dynamic_cast<ComponentLoader *>(p->implementation())) {
func(c);
diff --git a/project2/common/plugable.h b/project2/common/plugable.h
index eaccd49..8e3889f 100644
--- a/project2/common/plugable.h
+++ b/project2/common/plugable.h
@@ -2,81 +2,13 @@
#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> {
+class Plugable {
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..17ebd19 100644
--- a/project2/common/scriptLoader.cpp
+++ b/project2/common/scriptLoader.cpp
@@ -5,10 +5,10 @@
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/function_equal.hpp>
-#include "instanceStore.impl.h"
#include "appInstance.h"
+#include <factory.impl.h>
-typedef std::map<std::string, boost::shared_ptr<ElementLoader> > ElementLoaderMap;
+typedef std::map<std::string, boost::shared_ptr<ScriptNodePtr> > ElementLoaderMap;
typedef std::set<boost::shared_ptr<ComponentLoader> > ComponentLoaderSet;
LoaderBase::LoaderBase() :
@@ -68,7 +68,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 +99,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 +114,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..032d6c7 100644
--- a/project2/common/scriptLoader.h
+++ b/project2/common/scriptLoader.h
@@ -6,7 +6,7 @@
#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>
@@ -29,7 +29,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 +45,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..9947633 100644
--- a/project2/common/scriptStorage.h
+++ b/project2/common/scriptStorage.h
@@ -44,16 +44,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 ComponentLoader *>(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..0410817 100644
--- a/project2/common/scripts.cpp
+++ b/project2/common/scripts.cpp
@@ -3,6 +3,7 @@
#include "variables/fixed.h"
#include <boost/filesystem/convenience.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 +62,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 +76,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..e3fab9c 100644
--- a/project2/common/scripts.h
+++ b/project2/common/scripts.h
@@ -11,6 +11,7 @@
#include "exceptions.h"
#include "variableType.h"
#include "options.h"
+#include "componentLoader.h"
#include <vector>
SimpleMessageException(ValueNotFound);
@@ -80,13 +81,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/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 bee3767..f77d518 100644
--- a/project2/common/task.cpp
+++ b/project2/common/task.cpp
@@ -1,5 +1,6 @@
#include <pch.hpp>
#include "task.h"
+#include <factory.impl.h>
Task::Task(ScriptNodePtr p) :
SourceObject(p)
@@ -15,3 +16,5 @@ Task::~Task()
{
}
+INSTANTIATEFACTORY(Task, ScriptNodePtr);
+
diff --git a/project2/common/task.h b/project2/common/task.h
index d29b533..9a9548f 100644
--- a/project2/common/task.h
+++ b/project2/common/task.h
@@ -12,6 +12,7 @@ class Task : public virtual SourceObject {
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 23b75fe..136f481 100644
--- a/project2/common/taskHost.cpp
+++ b/project2/common/taskHost.cpp
@@ -1,5 +1,6 @@
#include <pch.hpp>
#include "taskHost.h"
+#include "task.h"
#include "dataSource.h"
#include <scopeExit.h>
#include "scriptLoader.h"
@@ -11,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/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/variables.cpp b/project2/common/variables.cpp
index 71cc36b..526f90c 100644
--- a/project2/common/variables.cpp
+++ b/project2/common/variables.cpp
@@ -12,7 +12,6 @@
#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>
diff --git a/project2/common/variables/lookup.cpp b/project2/common/variables/lookup.cpp
index eac3317..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
{
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/compression/decompressStream.cpp b/project2/compression/decompressStream.cpp
index b986a0a..68f8869 100644
--- a/project2/compression/decompressStream.cpp
+++ b/project2/compression/decompressStream.cpp
@@ -4,7 +4,6 @@
#include "scripts.h"
#include "variables.h"
#include "scriptStorage.h"
-#include "instanceStore.impl.h"
class DecompressStream : public Stream {
public:
@@ -12,7 +11,7 @@ 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
@@ -28,5 +27,5 @@ class DecompressStream : public Stream {
const Variable method;
};
-DECLARE_LOADER("decompstream", DecompressStream);
+NAMEDFACTORY("decompstream", DecompressStream, StreamFactory);
diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp
index 54c9b2f..41bf14c 100644
--- a/project2/console/consoleAppEngine.cpp
+++ b/project2/console/consoleAppEngine.cpp
@@ -12,6 +12,7 @@
#include <boost/bind.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <iostream>
+#include <plugable.h>
StaticMessageException(InvalidScriptName, "Script name should be group/name");
SimpleMessageException(UnknownPlatformAlias);
diff --git a/project2/console/p2consoleMain.cpp b/project2/console/p2consoleMain.cpp
index 87a3293..03771f0 100644
--- a/project2/console/p2consoleMain.cpp
+++ b/project2/console/p2consoleMain.cpp
@@ -2,6 +2,7 @@
#include <boost/bind.hpp>
#include "claOptions.h"
#include "consoleAppEngine.h"
+#include <plugable.h>
int
main(int argc, char ** argv)
diff --git a/project2/daemon/p2daemonAppEngine.cpp b/project2/daemon/p2daemonAppEngine.cpp
index 6ed0472..6d07201 100644
--- a/project2/daemon/p2daemonAppEngine.cpp
+++ b/project2/daemon/p2daemonAppEngine.cpp
@@ -7,6 +7,7 @@
#include <grp.h>
#include <options/flagSet.h>
#include <options/showHelp.h>
+#include <plugable.h>
#include "pidfile.h"
#include "tempPrivs.h"
diff --git a/project2/daemon/p2daemonMain.cpp b/project2/daemon/p2daemonMain.cpp
index 0da41f3..e65f941 100644
--- a/project2/daemon/p2daemonMain.cpp
+++ b/project2/daemon/p2daemonMain.cpp
@@ -5,6 +5,7 @@
#include <boost/bind.hpp>
#include <options.h>
#include <logger.h>
+#include <plugable.h>
SimpleMessageException(UnsupportedArguments);
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/presenterCache.cpp b/project2/files/presenterCache.cpp
index 9e3c8ad..87d1223 100644
--- a/project2/files/presenterCache.cpp
+++ b/project2/files/presenterCache.cpp
@@ -247,7 +247,7 @@ 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 FilePresenterCacheLoader : public ComponentLoader {
public:
FilePresenterCacheLoader()
{
@@ -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 9946ec6..485c138 100644
--- a/project2/files/writeStream.cpp
+++ b/project2/files/writeStream.cpp
@@ -14,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
@@ -33,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 0f56a33..cf1c446 100644
--- a/project2/ice/iceDaemon.cpp
+++ b/project2/ice/iceDaemon.cpp
@@ -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..734eedc 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 IceDataSourceLoader : public DataSourceFactory::For<IceDataSource>, public ComponentLoader {
public:
void onConfigLoad() override {
IceBase::FinaliseLoad(IceDataSource::libs);
}
};
-DECLARE_CUSTOM_LOADER("icedatasource", IceDataSourceLoader);
+NAMEDPLUGIN("icedatasource", IceDataSourceLoader, DataSourceFactory);
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/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/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 a1985a4..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;
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/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/rdbmsDataSource.cpp b/project2/sql/rdbmsDataSource.cpp
index e1091a3..9b295d3 100644
--- a/project2/sql/rdbmsDataSource.cpp
+++ b/project2/sql/rdbmsDataSource.cpp
@@ -8,7 +8,7 @@
#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> {
+class RdbmsDataSourceLoader : public ComponentLoader {
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/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..6e5bd20 100644
--- a/project2/sql/sqlCache.cpp
+++ b/project2/sql/sqlCache.cpp
@@ -264,7 +264,7 @@ std::string SqlCache::DataSource;
std::string SqlCache::HeaderTable;
time_t SqlCache::CacheLife;
-class CustomSqlCacheLoader : public ElementLoader::For<SqlCache> {
+class CustomSqlCacheLoader : public RowSetCacheFactory::For<SqlCache>, public ComponentLoader {
public:
void onIdle() override
{
@@ -284,7 +284,7 @@ class CustomSqlCacheLoader : public ElementLoader::For<SqlCache> {
}
}
};
-DECLARE_CUSTOM_LOADER("sqlcache", CustomSqlCacheLoader);
+NAMEDPLUGIN("sqlcache", CustomSqlCacheLoader, 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 ea334eb..cbf2210 100644
--- a/project2/sql/sqlMergeTask.cpp
+++ b/project2/sql/sqlMergeTask.cpp
@@ -40,8 +40,8 @@ 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) :
@@ -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<RowSetFactory>(&sources));
if (!sources.empty() && useView(NULL)) {
throw NotSupported("useview not supported with iterate fillers");
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 94f5102..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>(&changesTasks));
- p->script->loader.addLoadTargetSub(p, "nochanges", false, Storer::into<ElementLoader>(&noChangesTasks));
+ p->script->loader.addLoadTargetSub(p, "changes", false, Storer::into<TaskFactory>(&changesTasks));
+ p->script->loader.addLoadTargetSub(p, "nochanges", false, Storer::into<TaskFactory>(&noChangesTasks));
}
SqlTask::~SqlTask()
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/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/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/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..6104730 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 ComponentLoader {
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..f37924d 100644
--- a/project2/xml/xmlDocumentCache.cpp
+++ b/project2/xml/xmlDocumentCache.cpp
@@ -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, ComponentLoader);
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 66b6b0b..c86f8c0 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 XmlScriptReaderLoader : 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);
@@ -248,4 +248,5 @@ XmlScriptNode::composeWithCallbacks(const LiteralCallback & lcb, const NodeCallb
}
}
-DECLARE_CUSTOM_COMPONENT_LOADER("xmlScriptReader", XmlScriptReaderLoader, XmlScriptReaderLoader, ScriptReaderLoader);
+NAMEDPLUGIN("xmlScriptReader", XmlScriptReaderLoader, 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);