diff options
Diffstat (limited to 'project2/basics')
33 files changed, 68 insertions, 60 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); |