From 1a7b43c875227527bf180066354f6c3d6515d5cb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 28 Apr 2018 14:24:04 +0100 Subject: C++17 and Ice 3.7 Updates all code to work with C++17 and Ice 3.7 and related updates in used libraries. --- .gitignore | 1 + .gitmodules | 4 ++ Jamroot.jam | 18 ++++---- ice | 1 + project2/Jamfile.jam | 1 - project2/basics/caches/memoryCache.cpp | 12 ++--- project2/basics/if.cpp | 6 +-- project2/basics/options/showHelp.cpp | 4 +- project2/basics/options/showHelp.h | 2 +- project2/basics/tasks/iterate.cpp | 2 +- project2/basics/tasks/iterate.h | 2 +- project2/basics/tasks/structExceptHandling.cpp | 6 +-- project2/basics/tests/compoundTest.cpp | 4 +- project2/basics/unittests/Jamfile.jam | 5 +- project2/basics/unittests/testLibraries.cpp | 7 ++- project2/basics/unittests/testViews.cpp | 6 +-- project2/basics/views/autotree.cpp | 2 +- project2/basics/views/autotree.h | 7 ++- project2/basics/views/flatView.cpp | 2 +- project2/basics/views/flatView.h | 2 +- project2/basics/views/rowView.cpp | 6 +-- project2/basics/views/singleton.cpp | 2 +- project2/basics/views/viewGroup.cpp | 2 +- project2/cgi/cgiAppEngine.cpp | 26 +++++------ project2/cgi/cgiAppEngine.h | 13 +++--- project2/cgi/cgiContentNegotiate.cpp | 8 ++-- project2/cgi/cgiOutputOptions.cpp | 2 +- project2/cgi/cgiOutputOptions.h | 7 ++- project2/cgi/cgiProgRouter.cpp | 18 ++++---- project2/cgi/cgiRouter.h | 4 +- project2/cgi/cgiStageCacheHit.cpp | 4 +- project2/cgi/cgiStageDefaultError.cpp | 10 ++-- project2/cgi/cgiStageDefaultNotFound.cpp | 4 +- project2/cgi/cgiStageFail.cpp | 2 +- project2/cgi/cgiStageInitial.cpp | 4 +- project2/cgi/cgiStagePresent.cpp | 28 ++++++------ project2/cgi/cgiStageRedirect.cpp | 6 +-- project2/cgi/cgiStageRequest.cpp | 12 ++--- project2/cgi/testCgi.cpp | 7 +-- project2/common/aggregate.cpp | 4 +- project2/common/aggregate.h | 8 ++-- project2/common/check.cpp | 4 +- project2/common/check.h | 4 +- project2/common/checkHost.cpp | 2 +- project2/common/columns.cpp | 4 +- project2/common/columns.h | 6 +-- project2/common/commonObjects.cpp | 2 +- project2/common/commonObjects.h | 4 +- project2/common/dataSource.cpp | 2 +- project2/common/dataSource.h | 4 +- project2/common/definedColumns.h | 2 +- project2/common/execContext.cpp | 2 +- project2/common/execContext.h | 5 +- project2/common/iHaveParameters.h | 2 - project2/common/lifeCycle.cpp | 6 +-- project2/common/logger.cpp | 6 --- project2/common/logger.h | 8 ++-- project2/common/loggerFactory.h | 7 ++- project2/common/loggerFactory.impl.h | 6 +-- project2/common/options.cpp | 4 +- project2/common/options.h | 19 ++++---- project2/common/optionsSource.cpp | 2 +- project2/common/optionsSource.h | 1 - project2/common/pch.hpp | 2 - project2/common/presenter.cpp | 2 +- project2/common/presenter.h | 15 +++--- project2/common/presenterCache.cpp | 2 +- project2/common/presenterCache.h | 4 +- project2/common/rowProcessor.cpp | 4 +- project2/common/rowProcessor.h | 2 +- project2/common/rowSet.cpp | 2 +- project2/common/rowSet.h | 6 +-- project2/common/rowSetCache.cpp | 2 +- project2/common/rowSetCache.h | 6 +-- project2/common/scriptLoader.cpp | 14 +++--- project2/common/scriptLoader.h | 10 ++-- project2/common/scriptStorage.h | 63 +++++++++++++------------- project2/common/scripts.cpp | 6 +-- project2/common/scripts.h | 16 +++---- project2/common/scripts_fwd.h | 5 +- project2/common/session.h | 6 +-- project2/common/sessionContainer.cpp | 2 +- project2/common/sessionContainer.h | 5 +- project2/common/sourceObject.cpp | 7 ++- project2/common/sourceObject.h | 11 +++-- project2/common/stream.cpp | 2 +- project2/common/stream.h | 4 +- project2/common/task.cpp | 2 +- project2/common/task.h | 2 +- project2/common/taskHost.cpp | 2 +- project2/common/test.cpp | 2 +- project2/common/test.h | 4 +- project2/common/transform.cpp | 12 ++--- project2/common/transform.h | 14 +++--- project2/common/unittests/testConfig.cpp | 2 +- project2/common/variables.cpp | 6 +-- project2/common/variables.h | 12 ++--- project2/common/variables/config.cpp | 8 ++-- project2/common/variables/literal.cpp | 2 +- project2/common/variables/literal.h | 4 +- project2/common/variables/lookup.cpp | 2 +- project2/common/view.cpp | 4 +- project2/common/view.h | 2 +- project2/common/viewHost.cpp | 4 +- project2/common/viewHost.h | 2 +- project2/compression/decompressStream.cpp | 2 +- project2/compression/decompressor.h | 5 +- project2/compression/gzip.cpp | 1 + project2/console/consoleAppEngine.cpp | 2 +- project2/console/p2consoleMain.cpp | 4 +- project2/daemon/lib/daemon.h | 5 +- project2/daemon/p2daemonAppEngine.cpp | 2 +- project2/daemon/p2daemonMain.cpp | 4 +- project2/files/fsRows.cpp | 6 +-- project2/files/fsRows.h | 7 ++- project2/files/optionsSource.cpp | 4 +- project2/files/optionsSource.h | 2 +- project2/files/presenterCache.cpp | 8 ++-- project2/files/writeStream.cpp | 2 +- project2/ice/Jamfile.jam | 22 ++++----- project2/ice/buildComms.cpp | 11 ++--- project2/ice/iceBase.cpp | 2 +- project2/ice/iceClient.h | 2 +- project2/ice/iceCompile.cpp | 2 +- project2/ice/iceCompile.h | 4 +- project2/ice/iceConvert.h | 8 ++-- project2/ice/iceDaemon.cpp | 14 +++--- project2/ice/iceDaemon.h | 2 +- project2/ice/iceDataSource.cpp | 4 +- project2/ice/iceDataSource.h | 8 ++-- project2/ice/iceModule.cpp | 16 ++++--- project2/ice/iceModule.h | 8 ++-- project2/ice/iceRows.cpp | 2 +- project2/ice/iceboxDaemon.cpp | 8 ++-- project2/ice/iceboxLogger.cpp | 8 ++-- project2/ice/iceboxLogger.h | 4 +- project2/ice/slice/Jamroot.jam | 22 +++++++++ project2/ice/slice2Common.cpp | 2 +- project2/ice/slice2Daemon.cpp | 7 +-- project2/ice/slice2Rows.cpp | 2 +- project2/ice/sliceCompile.cpp | 5 +- project2/ice/unittests/Jamfile.jam | 21 ++++----- project2/ice/unittests/conversions.cpp | 4 +- project2/ice/unittests/testClient.cpp | 35 +++++++------- project2/ice/unittests/testClientCompile.cpp | 5 +- project2/ice/unittests/testDaemon.cpp | 10 ++-- project2/ice/unittests/testDaemonCompile.cpp | 5 +- project2/json/presenter.cpp | 2 +- project2/mail/sendmailTask.cpp | 34 +++++++------- project2/mail/sendmailTask.h | 5 +- project2/sql/mockDatasource.cpp | 2 +- project2/sql/mockDatasource.h | 2 +- project2/sql/rdbmsDataSource.cpp | 9 ++-- project2/sql/rdbmsDataSource.h | 8 ++-- project2/sql/sqlBulkLoad.cpp | 2 +- project2/sql/sqlCache.cpp | 37 +++++++-------- project2/sql/sqlMergeTask.cpp | 62 +++++++++++-------------- project2/sql/sqlMergeTask.h | 8 ++-- project2/sql/sqlRows.cpp | 4 +- project2/sql/sqlRows.h | 5 +- project2/sql/sqlTask.cpp | 4 +- project2/sql/sqlWriters.cpp | 10 ++-- project2/sql/sqlWriters.h | 6 +-- project2/sql/unittests/Jamfile.jam | 9 ---- project2/streams/streamNvpRows.cpp | 4 +- project2/streams/streamPresenter.cpp | 2 +- project2/streams/streamRows.cpp | 2 +- project2/streams/viewStream.cpp | 6 +-- project2/url/curlHelper.cpp | 2 +- project2/ut/testAppInstance.cpp | 8 ++++ project2/ut/testAppInstance.h | 4 ++ project2/ut/testScriptHost.cpp | 4 +- project2/ut/testScriptNode.cpp | 7 ++- project2/ut/testScriptNode.h | 4 +- project2/xml/Jamfile.jam | 4 +- project2/xml/rawView.cpp | 2 +- project2/xml/sessionXml.cpp | 2 +- project2/xml/unittests/testxml.cpp | 6 +-- project2/xml/xmlCache.cpp | 6 +-- project2/xml/xmlPresenter.cpp | 4 +- project2/xml/xmlPresenter.h | 8 ++-- project2/xml/xmlRawRows.cpp | 2 +- project2/xml/xmlRows.cpp | 2 +- project2/xml/xmlScriptParser.cpp | 38 ++++++++-------- project2/xml/xmlScriptParser.h | 9 ++-- project2/xml/xpathRows.cpp | 6 +-- project2/xml/xpathRows.h | 9 ++-- 187 files changed, 642 insertions(+), 662 deletions(-) create mode 100644 .gitmodules create mode 160000 ice create mode 100644 project2/ice/slice/Jamroot.jam delete mode 100644 project2/sql/unittests/Jamfile.jam diff --git a/.gitignore b/.gitignore index e6721ac..511425e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin *.pyc *.sw? +tags diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e0e648c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "ice"] + path = ice + url = https://github.com/zeroc-ice/ice + branch = 3.7 diff --git a/Jamroot.jam b/Jamroot.jam index 5f73725..d92540b 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -3,19 +3,19 @@ import slice ; using gcc : : [ os.environ CXX ] ; -variant component ; variant coverage : debug ; project : requirements - release:"-std=c++1y -fvisibility=hidden" - release:"-Wl,-z,defs,--warn-once,--gc-sections" - debug:"-W -Wall -Werror -Wwrite-strings -std=c++1y -fvisibility=hidden" - debug:"-Wl,-z,defs,--warn-once" - coverage:"-W -Wall -Werror -Wwrite-strings -std=c++1y --coverage -fvisibility=hidden" - coverage:"-Wl,-z,defs,--warn-once --coverage" - component:"-W -Wall -Werror -Wwrite-strings -std=c++1y -fPIC -fvisibility=hidden" - component:"-Wl,-z,lazy,--warn-once,-fPIC" + ICE_CPP11_MAPPING + "-std=c++17 -fvisibility=hidden -fvisibility-inlines-hidden" + "-Wl,--warn-once,--gc-sections" + release:"-flto=2" + release:"-flto=2" + debug:"-W -Wall -Werror -Wextra" + debug:"-Wl,-z,defs" + coverage:"--coverage" + coverage:"--coverage" ; build-project project2 ; diff --git a/ice b/ice new file mode 160000 index 0000000..15eeeb7 --- /dev/null +++ b/ice @@ -0,0 +1 @@ +Subproject commit 15eeeb77ac01c54548486d691774ab6dd63fdf1c diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam index 8de52d5..9a36ada 100644 --- a/project2/Jamfile.jam +++ b/project2/Jamfile.jam @@ -31,7 +31,6 @@ build-project ice ; build-project common//unittests ; build-project basics//unittests ; build-project ice//unittests ; -build-project sql//unittests ; build-project xml//unittests ; build-project files//unittests ; diff --git a/project2/basics/caches/memoryCache.cpp b/project2/basics/caches/memoryCache.cpp index 3138760..04f5344 100644 --- a/project2/basics/caches/memoryCache.cpp +++ b/project2/basics/caches/memoryCache.cpp @@ -31,7 +31,7 @@ class MemoryCache : public RowSetCache { const Columns * columns; AttrMap attrs; }; - typedef boost::shared_ptr MemoryCacheRowPtr; + typedef std::shared_ptr MemoryCacheRowPtr; typedef std::list DataCache; CachedRowSet(const std::vector & k) : @@ -56,14 +56,14 @@ class MemoryCache : public RowSetCache { void addNamedValue(const Glib::ustring & name, const VariableType & value) const { if (cur->fields.size() <= col) { cur->fields.resize(col + 1); - columns.insert(new Column(col, name)); + columns.insert(std::make_shared(col, name)); } cur->fields[col++] = value; } void addNewRow(const Glib::ustring&) const { col = 0; - cur = MemoryCacheRowPtr(new MemoryCacheRow(&columns)); + cur = std::make_shared(&columns); } void finishRow() const { @@ -81,8 +81,8 @@ class MemoryCache : public RowSetCache { mutable MemoryCacheRowPtr cur; }; - typedef boost::intrusive_ptr CachedRowSetPtr; - typedef boost::intrusive_ptr CachedRowSetCPtr; + typedef std::shared_ptr CachedRowSetPtr; + typedef std::shared_ptr CachedRowSetCPtr; struct IndexByKey { }; struct IndexByTime { }; @@ -115,7 +115,7 @@ class MemoryCache : public RowSetCache { } RowSetPresenterPtr openFor(ExecContext * ec, const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * ps) { - return (cur = new CachedRowSet(makeKey(ec, n, f, ps))); + return (cur = std::make_shared(makeKey(ec, n, f, ps))); } void save(ExecContext *, const Glib::ustring & , const Glib::ustring & , const IHaveParameters * ) { diff --git a/project2/basics/if.cpp b/project2/basics/if.cpp index d860b55..4500335 100644 --- a/project2/basics/if.cpp +++ b/project2/basics/if.cpp @@ -15,9 +15,9 @@ If::If(ScriptNodePtr e) : IHaveSubTasks(e), View(e) { - e->script->loader.addLoadTarget(e, Storer::into(&normal)); - e->script->loader.addLoadTarget(e, Storer::into(&subViews)); - e->script->loader.addLoadTarget(e, Storer::into(&test)); + e->script.lock()->loader.addLoadTarget(e, Storer::into(&normal)); + e->script.lock()->loader.addLoadTarget(e, Storer::into(&subViews)); + e->script.lock()->loader.addLoadTarget(e, Storer::into(&test)); } bool diff --git a/project2/basics/options/showHelp.cpp b/project2/basics/options/showHelp.cpp index 395baed..0b32043 100644 --- a/project2/basics/options/showHelp.cpp +++ b/project2/basics/options/showHelp.cpp @@ -14,7 +14,7 @@ void ShowHelpComponent::onConfigLoad() exit(1); } -void ShowHelpComponent::outputOptions(const Options * options) const +void ShowHelpComponent::outputOptions(std::shared_ptr options) const { fprintf(stdout, " * %s\n", options->name.c_str()); for (const auto & option : options->allOptions()) { @@ -25,7 +25,7 @@ void ShowHelpComponent::outputOptions(const Options * options) const Options::TargetPtr ShowHelpComponent::Option() { - return new OptionFlagSet(&showHelp); + return std::make_shared(&showHelp); } bool ShowHelpComponent::showHelp; diff --git a/project2/basics/options/showHelp.h b/project2/basics/options/showHelp.h index eb94155..a0878fe 100644 --- a/project2/basics/options/showHelp.h +++ b/project2/basics/options/showHelp.h @@ -11,7 +11,7 @@ class DLL_PUBLIC ShowHelpComponent : public LifeCycle { static Options::TargetPtr Option(); private: - void outputOptions(const Options * options) const; + void outputOptions(std::shared_ptr options) const; static bool showHelp; }; diff --git a/project2/basics/tasks/iterate.cpp b/project2/basics/tasks/iterate.cpp index 16224f6..6ab1260 100644 --- a/project2/basics/tasks/iterate.cpp +++ b/project2/basics/tasks/iterate.cpp @@ -11,7 +11,7 @@ Iterate::Iterate(ScriptNodePtr p) : IHaveSubTasks(p), RowProcessor(p) { - p->script->loader.addLoadTarget(p, Storer::into(&normal)); + p->script.lock()->loader.addLoadTarget(p, Storer::into(&normal)); } Iterate::~Iterate() diff --git a/project2/basics/tasks/iterate.h b/project2/basics/tasks/iterate.h index 807c8c3..ca3a7ba 100644 --- a/project2/basics/tasks/iterate.h +++ b/project2/basics/tasks/iterate.h @@ -6,7 +6,7 @@ #include "scriptStorage.h" class Iterate; -typedef boost::intrusive_ptr IteratePtr; +typedef std::shared_ptr IteratePtr; /// Project2 component to iterate over a row set, executing its children for each record class DLL_PUBLIC Iterate : public IHaveSubTasks, public RowProcessor { diff --git a/project2/basics/tasks/structExceptHandling.cpp b/project2/basics/tasks/structExceptHandling.cpp index 4e46466..b77a4a8 100644 --- a/project2/basics/tasks/structExceptHandling.cpp +++ b/project2/basics/tasks/structExceptHandling.cpp @@ -11,9 +11,9 @@ StructuredExceptionHandler::StructuredExceptionHandler(ScriptNodePtr e) : SourceObject(e), IHaveSubTasks(e) { - e->script->loader.addLoadTargetSub(e, "try", true, Storer::into(&normal)); - e->script->loader.addLoadTargetSub(e, "catch", false, Storer::into(&catches)); - e->script->loader.addLoadTargetSub(e, "finally", false, Storer::into(&finallies)); + e->script.lock()->loader.addLoadTargetSub(e, "try", true, Storer::into(&normal)); + e->script.lock()->loader.addLoadTargetSub(e, "catch", false, Storer::into(&catches)); + e->script.lock()->loader.addLoadTargetSub(e, "finally", false, Storer::into(&finallies)); } void diff --git a/project2/basics/tests/compoundTest.cpp b/project2/basics/tests/compoundTest.cpp index 88cff62..2b9d1d7 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(&tests)); + s->script.lock()->loader.addLoadTarget(s, Storer::into(&tests)); } class All : public CompoundTest { @@ -64,7 +64,7 @@ class Not : public Test { SourceObject(s), Test(s) { - s->script->loader.addLoadTarget(s, Storer::into(&test)); + s->script.lock()->loader.addLoadTarget(s, Storer::into(&test)); } bool passes(ExecContext * ec) const { if (!test) { diff --git a/project2/basics/unittests/Jamfile.jam b/project2/basics/unittests/Jamfile.jam index 4fef202..c5b14c6 100644 --- a/project2/basics/unittests/Jamfile.jam +++ b/project2/basics/unittests/Jamfile.jam @@ -10,9 +10,7 @@ path-constant me : . ; run testLibraries.cpp - : : : - ROOT=\"$(me)\" - dummylib + : : dummylib : ../../common//p2common ..//p2basics ../../ut//p2ut @@ -29,6 +27,7 @@ run ..//p2basics ../../ut//p2ut ../../xml//p2xml + ../../url//p2url ..//boost_filesystem : standardTests : diff --git a/project2/basics/unittests/testLibraries.cpp b/project2/basics/unittests/testLibraries.cpp index 7797694..a1aef90 100644 --- a/project2/basics/unittests/testLibraries.cpp +++ b/project2/basics/unittests/testLibraries.cpp @@ -25,11 +25,16 @@ BOOST_AUTO_TEST_CASE( load_missing_library ) BOOST_AUTO_TEST_CASE( load_and_unload_library ) { + // Path to test lib needs passing in + BOOST_REQUIRE_EQUAL(2, args.size()); + auto libraryPath = args[1]; + BOOST_REQUIRE(boost::filesystem::exists(libraryPath)); + 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() } + { "library", libraryPath } }); BOOST_TEST_CHECKPOINT("Verify"); BOOST_REQUIRE(TaskFactory::get("DummyTask")); diff --git a/project2/basics/unittests/testViews.cpp b/project2/basics/unittests/testViews.cpp index 0a05c69..2303f1c 100644 --- a/project2/basics/unittests/testViews.cpp +++ b/project2/basics/unittests/testViews.cpp @@ -7,7 +7,7 @@ #include #include -boost::intrusive_ptr +std::shared_ptr executeRowViewTest(ExecContext * ec, const boost::filesystem::path & script, const boost::filesystem::path & expected) { TestOptionsSource::LoadTestOptions({ @@ -15,8 +15,8 @@ executeRowViewTest(ExecContext * ec, const boost::filesystem::path & script, con { "application.dataroot", ("file://" / rootDir / "data").string() }, }); BOOST_TEST_CHECKPOINT("Load"); - ScriptReaderPtr r = new XmlScriptParser(script); - boost::intrusive_ptr sr = new TestScriptHost(r); + ScriptReaderPtr r = std::make_shared(script); + std::shared_ptr sr = std::make_shared(r); BOOST_TEST_CHECKPOINT("Execute"); sr->process(ec); BOOST_TEST_CHECKPOINT("Compare"); diff --git a/project2/basics/views/autotree.cpp b/project2/basics/views/autotree.cpp index bfeabee..f96888e 100644 --- a/project2/basics/views/autotree.cpp +++ b/project2/basics/views/autotree.cpp @@ -55,7 +55,7 @@ AutoTreeNode::AutoTreeNode(ScriptNodePtr sn, unsigned int p, unsigned int d) : includes.insert({n->value("name", NULL).as(), Variable::fromScriptNode(n)} ); } if (sn->valueExists("tree")) { - tree = new AutoTreeNode(sn->child("tree"), pos + keys.size(), depth + 1); + tree = std::make_shared(sn->child("tree"), pos + keys.size(), depth + 1); } } diff --git a/project2/basics/views/autotree.h b/project2/basics/views/autotree.h index ace3d8d..9276bab 100644 --- a/project2/basics/views/autotree.h +++ b/project2/basics/views/autotree.h @@ -1,13 +1,12 @@ #ifndef AUTOTREE_H #define AUTOTREE_H -#include #include "rowProcessor.h" #include "view.h" #include "aggregate.h" class AutoTreeNode; -typedef boost::intrusive_ptr AutoTreeNodePtr; +typedef std::shared_ptr AutoTreeNodePtr; class DLL_PUBLIC AutoTreeState { public: @@ -17,7 +16,7 @@ class DLL_PUBLIC AutoTreeState { std::vector values; }; -class DLL_PUBLIC AutoTreeNode : public IntrusivePtrBase { +class DLL_PUBLIC AutoTreeNode { public: typedef std::map Values; @@ -29,7 +28,7 @@ class DLL_PUBLIC AutoTreeNode : public IntrusivePtrBase { void closeArray(const MultiRowSetPresenter * p, ExecContext *, AutoTreeState & state) const; void closeObject(const MultiRowSetPresenter * p, ExecContext *, AutoTreeState & state) const; AutoTreeNodePtr child() const; - + protected: private: diff --git a/project2/basics/views/flatView.cpp b/project2/basics/views/flatView.cpp index aba684f..36c0427 100644 --- a/project2/basics/views/flatView.cpp +++ b/project2/basics/views/flatView.cpp @@ -6,7 +6,7 @@ #include NAMEDFACTORY("flatview", FlatView, FlatViewFactory); -INSTANTIATEFACTORY(FlatView, const ScriptNode *); +INSTANTIATEFACTORY(FlatView, std::shared_ptr); FlatView::FlatView(ScriptNodePtr p) : SourceObject(p), diff --git a/project2/basics/views/flatView.h b/project2/basics/views/flatView.h index b79162b..72acabc 100644 --- a/project2/basics/views/flatView.h +++ b/project2/basics/views/flatView.h @@ -24,7 +24,7 @@ class DLL_PUBLIC FlatView : public SourceObject, public RowProcessor { typedef std::map Columns; Columns viewColumns; }; -typedef AdHoc::Factory FlatViewFactory; +typedef AdHoc::Factory> FlatViewFactory; #endif diff --git a/project2/basics/views/rowView.cpp b/project2/basics/views/rowView.cpp index a798688..f5e108b 100644 --- a/project2/basics/views/rowView.cpp +++ b/project2/basics/views/rowView.cpp @@ -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(&subViews)); - p->script->loader.addLoadTarget(p, Storer::into(&valueAggregates)); - p->script->loader.addLoadTarget(p, Storer::into(&setAggregates)); + p->script.lock()->loader.addLoadTarget(p, Storer::into(&subViews)); + p->script.lock()->loader.addLoadTarget(p, Storer::into(&valueAggregates)); + p->script.lock()->loader.addLoadTarget(p, Storer::into(&setAggregates)); } RowView::~RowView() diff --git a/project2/basics/views/singleton.cpp b/project2/basics/views/singleton.cpp index 15f2908..913776a 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(&subViews)); + p->script.lock()->loader.addLoadTarget(p, Storer::into(&subViews)); } void execute(const MultiRowSetPresenter * p, ExecContext * ec) const { diff --git a/project2/basics/views/viewGroup.cpp b/project2/basics/views/viewGroup.cpp index 8237e86..591babd 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(&subViews)); + s->script.lock()->loader.addLoadTarget(s, Storer::into(&subViews)); } void execute(const MultiRowSetPresenter * presenter, ExecContext * ec) const diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp index a69fa9e..7f5195b 100644 --- a/project2/cgi/cgiAppEngine.cpp +++ b/project2/cgi/cgiAppEngine.cpp @@ -36,7 +36,7 @@ std::string CgiApplicationEngine::onErrorPresent; std::string CgiApplicationEngine::defaultPresenter; SessionContainerPtr CgiApplicationEngine::sessionsContainer; std::string CgiApplicationEngine::sessionCookie; -const RouterFactory * CgiApplicationEngine::router; +std::shared_ptr CgiApplicationEngine::router; CgiApplicationEngine::PlatformHostnameList CgiApplicationEngine::platHosts; class PlatformHostnameTarget : public Options::Target { @@ -90,7 +90,7 @@ DECLARE_OPTIONS(CgiApplicationEngine, "Project2 CGI options") "The module with which to implement session management") ("cgi.sessionCookie", Options::value(&sessionCookie, "sessionID"), "The name of the cookie for storing session IDs") -("cgi.hostRegex", new PlatformHostnameTarget(), +("cgi.hostRegex", std::make_shared(), "Regular expression used to define a hostname -> platform association") ("cgi.router", Options::function([](const VariableType & r) { router = RouterFactory::get(r); }, "simple"), "Implemenation of router model to map request paths to scripts") @@ -111,7 +111,7 @@ finalTransformSource(TransformSourcePtr ts) return ts; } for (const Targets::value_type & t : ts->getTargets()) { - if (TransformSource * tr = dynamic_cast(t.first.get())) { + if (auto tr = std::dynamic_pointer_cast(t.first)) { if (TransformSourcePtr f = finalTransformSource(tr)) { return f; } @@ -128,22 +128,22 @@ CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const crc->startTime = boost::date_time::microsec_clock::universal_time(); bool triedNotFound = false; bool triedOnError = false; - NextStage currentStage = NextStage(new InitialStage()); + NextStage currentStage = NextStage(std::make_shared()); do { try { currentStage = currentStage.get<0>()->run(crc); } catch (const CheckHost::CheckFailure & cf) { - currentStage = NextStage(new PresentStage(ScriptReader::resolveScript(presentRoot, cf.failedCheck->present(crc), false), crc)); + currentStage = NextStage(std::make_shared(ScriptReader::resolveScript(presentRoot, cf.failedCheck->present(crc), false), crc)); } catch (const ScriptNotFound & nf) { Logger()->messagebf(LOG_ERR, "%s: Resource not found: %s", __FUNCTION__, nf.what()); if (notFoundPresent.empty() || triedNotFound) { - currentStage = NextStage(new DefaultNotFoundStage(nf)); + currentStage = NextStage(std::make_shared(nf)); } else { triedNotFound = true; - currentStage = NextStage(new CustomNotFoundStage(nf, ScriptReader::resolveScript(errorPresentRoot, notFoundPresent, false), crc)); + currentStage = NextStage(std::make_shared(nf, ScriptReader::resolveScript(errorPresentRoot, notFoundPresent, false), crc)); } } catch (const std::exception & ex) { @@ -151,11 +151,11 @@ CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const Logger()->messagebf(LOG_WARNING, "%s: Error processing stage: %s (what: %s)", __FUNCTION__, buf, ex.what()); free(buf); if (onErrorPresent.empty() || triedOnError) { - currentStage = NextStage(new DefaultErrorStage(ex, crc)); + currentStage = NextStage(std::make_shared(ex, crc)); } else { triedNotFound = true; - currentStage = NextStage(new CustomErrorStage(ex, ScriptReader::resolveScript(errorPresentRoot, onErrorPresent, false), crc)); + currentStage = NextStage(std::make_shared(ex, ScriptReader::resolveScript(errorPresentRoot, onErrorPresent, false), crc)); } } } while (currentStage.get<0>()); @@ -176,12 +176,12 @@ CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const TransformSourcePtr final = finalTransformSource(ts); AdHoc::ScopeExit emptyFinal([final] { final->clearTargets(); }); boost::shared_ptr ddd; - ostreamWrapper * osw = NULL; + std::shared_ptr osw; AdHoc::ScopeExit removeDdd([ts, &osw] { if (osw) { ts->removeTarget(osw); } }); if (!dumpdatadoc.empty()) { ddd = boost::shared_ptr(new std::fstream(dumpdatadoc.c_str(), std::fstream::trunc | std::fstream::out)); if (ddd->good()) { - ts->addTarget(osw = new ostreamWrapper(*ddd), crc, NULL); + ts->addTarget(osw = std::make_shared(*ddd), crc, NULL); } else { ddd.reset(); @@ -197,13 +197,13 @@ CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const } if (rs->caches.front()->check(0, crc)) { AdHoc::ScopeExit emptyFinal([rs] { rs->caches.front()->clearTargets(); }); - rs->caches.front()->addTarget(new CgiResult(header, IO, + rs->caches.front()->addTarget(std::make_shared(header, IO, rs && rs->outputOptions ? rs->outputOptions->Encoding(crc).as() : OutputOptions::encoding), crc, NULL); rs->caches.front()->doTransforms(crc); return; } } - final->addTarget(new CgiResult(header, IO, + final->addTarget(std::make_shared(header, IO, rs && rs->outputOptions ? rs->outputOptions->Encoding(crc).as() : OutputOptions::encoding), crc, NULL); ts->doTransforms(crc); } diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h index b9a30d9..3c9ba13 100644 --- a/project2/cgi/cgiAppEngine.h +++ b/project2/cgi/cgiAppEngine.h @@ -10,7 +10,6 @@ #include "xmlPresenter.h" #include "presenterCache.h" #include "sessionContainer.h" -#include #include #include "cgiOutputOptions.h" #include "cgiHttpHeader.h" @@ -27,7 +26,7 @@ namespace cgicc { class DLL_PUBLIC CgiApplicationEngine : AppInstance { public: - typedef boost::shared_ptr HttpHeaderPtr; + typedef std::shared_ptr HttpHeaderPtr; typedef std::pair> PlatformHostname; typedef std::vector PlatformHostnameList; @@ -53,18 +52,18 @@ class DLL_PUBLIC CgiApplicationEngine : AppInstance { public: class Stage; class ResponseStage; - typedef boost::intrusive_ptr StagePtr; - typedef boost::intrusive_ptr ResponseStagePtr; + typedef std::shared_ptr StagePtr; + typedef std::shared_ptr ResponseStagePtr; typedef boost::tuple NextStage; /// Base class for a stage iteration that should eventually produce a response for the client - class Stage : public virtual IntrusivePtrBase { + class Stage { public: virtual ~Stage() = 0; virtual NextStage run(CgiRequestContext *) = 0; }; /// Base class for a stage that can be a response to the client - class ResponseStage : public Stage { + class ResponseStage : public Stage, public std::enable_shared_from_this { public: typedef ANONORDEREDSTORAGEOF(PresenterCache) PresenterCaches; @@ -162,7 +161,7 @@ class DLL_PUBLIC CgiApplicationEngine : AppInstance { INITOPTIONS; static PlatformHostnameList platHosts; - static const RouterFactory * router; + static std::shared_ptr router; static SessionContainerPtr sessionsContainer; static std::string sessionCookie; private: diff --git a/project2/cgi/cgiContentNegotiate.cpp b/project2/cgi/cgiContentNegotiate.cpp index beff91c..d72967a 100644 --- a/project2/cgi/cgiContentNegotiate.cpp +++ b/project2/cgi/cgiContentNegotiate.cpp @@ -5,7 +5,7 @@ class ContentNegotiateFactory : public PresenterFactory { public: - MultiRowSetPresenter * create(const ScriptNode * const & s, const ObjectSource & os, ExecContext * const & ec) const override + MultiRowSetPresenterPtr create(std::shared_ptr const & s, const ObjectSource & os, ExecContext * const & ec) const override { auto accept = static_cast(ec)->getAccept(); typedef boost::tokenizer> tokenizer; @@ -22,7 +22,7 @@ class ContentNegotiateFactory : public PresenterFactory { } INITOPTIONS; - class MappedType : public IntrusivePtrBase { + class MappedType { public: MappedType(const std::string & val) : accept(val.substr(0, val.find('='))), @@ -38,7 +38,7 @@ class ContentNegotiateFactory : public PresenterFactory { const std::string accept; const std::string present; }; - typedef boost::intrusive_ptr MappedTypePtr; + typedef std::shared_ptr MappedTypePtr; typedef std::vector MappedTypes; static MappedTypes mappedTypes; @@ -50,7 +50,7 @@ NAMEDPLUGIN("contentnegotiate", ContentNegotiateFactory, PresenterFactory); DECLARE_OPTIONS(ContentNegotiateFactory, "Content negotiation options") ("cgi.contentnegotiation.mappedtype", Options::functions( - [](const VariableType & v) { mappedTypes.push_back(new MappedType(v)); }, + [](const VariableType & v) { mappedTypes.push_back(std::make_shared(v)); }, boost::bind(&MappedTypes::clear, &mappedTypes)), "mimetype=presenter list of types to negotiate") END_OPTIONS(ContentNegotiateFactory) diff --git a/project2/cgi/cgiOutputOptions.cpp b/project2/cgi/cgiOutputOptions.cpp index 56590ff..a199701 100644 --- a/project2/cgi/cgiOutputOptions.cpp +++ b/project2/cgi/cgiOutputOptions.cpp @@ -32,5 +32,5 @@ DECLARE_OPTIONS(OutputOptions, "CGI default output options") END_OPTIONS(OutputOptions) NAMEDFACTORY("outputoptions", OutputOptions, OutputOptionsFactory) -INSTANTIATEFACTORY(OutputOptions, const ScriptNode *); +INSTANTIATEFACTORY(OutputOptions, std::shared_ptr); diff --git a/project2/cgi/cgiOutputOptions.h b/project2/cgi/cgiOutputOptions.h index 75a19b0..55d75c7 100644 --- a/project2/cgi/cgiOutputOptions.h +++ b/project2/cgi/cgiOutputOptions.h @@ -1,11 +1,10 @@ #ifndef OUTPUTOPTIONS_H #define OUTPUTOPTIONS_H -#include "intrusivePtrBase.h" #include "options.h" #include "variables.h" -class DLL_PUBLIC OutputOptions : public IntrusivePtrBase { +class DLL_PUBLIC OutputOptions : public Something { public: OutputOptions(ScriptNodePtr); @@ -29,7 +28,7 @@ class DLL_PUBLIC OutputOptions : public IntrusivePtrBase { static bool url; static bool parameters; }; -typedef boost::intrusive_ptr OutputOptionsPtr; -typedef AdHoc::Factory OutputOptionsFactory; +typedef std::shared_ptr OutputOptionsPtr; +typedef AdHoc::Factory> OutputOptionsFactory; #endif diff --git a/project2/cgi/cgiProgRouter.cpp b/project2/cgi/cgiProgRouter.cpp index 9993441..983e8cd 100644 --- a/project2/cgi/cgiProgRouter.cpp +++ b/project2/cgi/cgiProgRouter.cpp @@ -16,7 +16,7 @@ typedef std::map VarMap; class RoutingTable { public: class Route; - typedef AdHoc::Factory RouteFactory; + typedef AdHoc::Factory> RouteFactory; void loadRoutesFromFile(const std::string & routeFile) { routeScriptPath = routeFile; @@ -59,11 +59,11 @@ class RoutingTable { throw ScriptNotFound("routed", path); } - class RouteElem : public IntrusivePtrBase { + class RouteElem { public: virtual bool matches(const std::string &, VarMap & vars) const = 0; }; - typedef boost::intrusive_ptr RouteElemPtr; + typedef std::shared_ptr RouteElemPtr; class RouteLiteral : public RouteElem { public: @@ -97,10 +97,10 @@ class RoutingTable { while(p != fspath.end() && p->string() != ".") { switch (p->string().front()) { case '{': - routeElems.push_back(new RouteVar(p->string())); + routeElems.push_back(std::make_shared(p->string())); break; default: - routeElems.push_back(new RouteLiteral(p->string())); + routeElems.push_back(std::make_shared(p->string())); break; } p++; @@ -122,7 +122,7 @@ class RoutingTable { const std::string present; const std::string path; }; - typedef boost::intrusive_ptr RoutePtr; + typedef std::shared_ptr RoutePtr; std::list routes; }; @@ -202,8 +202,8 @@ class Routes : public RowSet { class RouteRowState : public RowState { public: RouteRowState() { - columns.insert(new Column(0, "present")); - columns.insert(new Column(1, "path")); + columns.insert(std::make_shared(0, "present")); + columns.insert(std::make_shared(1, "path")); fields.resize(2); } const Columns & getColumns() const { return columns; } @@ -224,5 +224,5 @@ class Routes : public RowSet { }; NAMEDFACTORY("routes", Routes, RowSetFactory); -INSTANTIATEFACTORY(RoutingTable::Route, const ScriptNode *); +INSTANTIATEFACTORY(RoutingTable::Route, std::shared_ptr); diff --git a/project2/cgi/cgiRouter.h b/project2/cgi/cgiRouter.h index 5417bce..7c9137e 100644 --- a/project2/cgi/cgiRouter.h +++ b/project2/cgi/cgiRouter.h @@ -7,7 +7,7 @@ class MultiRowSetPresenter; -class DLL_PUBLIC Router : public IntrusivePtrBase { +class DLL_PUBLIC Router { public: virtual bool isDefault() const = 0; virtual std::string route() const = 0; @@ -15,7 +15,7 @@ class DLL_PUBLIC Router : public IntrusivePtrBase { virtual unsigned int parameterCount() const = 0; virtual void present(const MultiRowSetPresenter * p) const = 0; }; -typedef boost::intrusive_ptr RouterPtr; +typedef std::shared_ptr RouterPtr; typedef AdHoc::Factory RouterFactory; #endif diff --git a/project2/cgi/cgiStageCacheHit.cpp b/project2/cgi/cgiStageCacheHit.cpp index 3a6a665..a069dc8 100644 --- a/project2/cgi/cgiStageCacheHit.cpp +++ b/project2/cgi/cgiStageCacheHit.cpp @@ -13,12 +13,12 @@ CgiApplicationEngine::CacheHitStage::CacheHitStage(ScriptNodePtr s, PresenterCac CgiApplicationEngine::NextStage CgiApplicationEngine::CacheHitStage::run(CgiRequestContext *) { - return NextStage(NULL, this, pc, NULL); + return NextStage(NULL, shared_from_this(), pc, NULL); } CgiApplicationEngine::HttpHeaderPtr CgiApplicationEngine::CacheHitStage::getHeader(CgiRequestContext *) const { - return HttpHeaderPtr(new Project2HttpHeader("200 OK")); + return std::make_shared("200 OK"); } diff --git a/project2/cgi/cgiStageDefaultError.cpp b/project2/cgi/cgiStageDefaultError.cpp index f932f78..f4c1df9 100644 --- a/project2/cgi/cgiStageDefaultError.cpp +++ b/project2/cgi/cgiStageDefaultError.cpp @@ -11,12 +11,12 @@ CgiApplicationEngine::DefaultErrorStage::DefaultErrorStage(const std::exception CgiApplicationEngine::ResponseStage(NULL), buf(__cxxabiv1::__cxa_demangle(typeid(ex).name(), NULL, NULL, NULL)), what(ex.what()), - pres(new XmlPresenter(DefaultErrorStageResp, CgiApplicationEngine::errorTransformStyle, CgiApplicationEngine::errorContentType)) + pres(std::make_shared(DefaultErrorStageResp, CgiApplicationEngine::errorTransformStyle, CgiApplicationEngine::errorContentType)) { - auto xp = dynamic_cast(pres.get()); - auto cp = dynamic_cast(pres.get()); + auto xp = std::dynamic_pointer_cast(pres); + auto cp = std::dynamic_pointer_cast(pres); if (xp && cp && cp->contentType == CgiApplicationEngine::transformContentType) { - auto h = TransformTargetFactory::createNew(CgiApplicationEngine::transformTargetType, root.get(), Default); + auto h = TransformTargetFactory::createNew(CgiApplicationEngine::transformTargetType, root, Default); xp->addTarget(h, crc, root); } } @@ -38,6 +38,6 @@ CgiApplicationEngine::DefaultErrorStage::run(CgiRequestContext * crc) pres->init(crc); pres->addNamedValue("error-type", Scripts::scriptNamespacePrefix, buf); pres->addNamedValue("error-what", Scripts::scriptNamespacePrefix, what.c_str()); - return NextStage(NULL, this, pres.get(), pres.get()); + return NextStage(NULL, shared_from_this(), pres, pres); } diff --git a/project2/cgi/cgiStageDefaultNotFound.cpp b/project2/cgi/cgiStageDefaultNotFound.cpp index ad4c697..c6b6f1e 100644 --- a/project2/cgi/cgiStageDefaultNotFound.cpp +++ b/project2/cgi/cgiStageDefaultNotFound.cpp @@ -16,7 +16,7 @@ CgiApplicationEngine::DefaultNotFoundStage::DefaultNotFoundStage(const ScriptNot CgiApplicationEngine::HttpHeaderPtr CgiApplicationEngine::DefaultNotFoundStage::getHeader(CgiRequestContext *) const { - return HttpHeaderPtr(new Project2HttpHeader("404 Not found")); + return std::make_shared("404 Not found"); } CgiApplicationEngine::NextStage @@ -24,6 +24,6 @@ CgiApplicationEngine::DefaultNotFoundStage::run(CgiRequestContext * crc) { pres->init(crc); pres->addNamedValue("missing-resource", Scripts::scriptNamespacePrefix, nf.what()); - return NextStage(NULL, this, pres.get(), pres.get()); + return NextStage(NULL, shared_from_this(), pres, pres); } diff --git a/project2/cgi/cgiStageFail.cpp b/project2/cgi/cgiStageFail.cpp index e96f14f..a111a96 100644 --- a/project2/cgi/cgiStageFail.cpp +++ b/project2/cgi/cgiStageFail.cpp @@ -22,7 +22,7 @@ namespace CgiApplicationExtras { CgiApplicationEngine::NextStage run(CgiRequestContext *) { - return CgiApplicationEngine::NextStage(NULL, this, NULL, NULL); + return CgiApplicationEngine::NextStage(NULL, shared_from_this(), NULL, NULL); } private: const int code; diff --git a/project2/cgi/cgiStageInitial.cpp b/project2/cgi/cgiStageInitial.cpp index 1326af8..dbc58fd 100644 --- a/project2/cgi/cgiStageInitial.cpp +++ b/project2/cgi/cgiStageInitial.cpp @@ -7,11 +7,11 @@ CgiApplicationEngine::NextStage CgiApplicationEngine::InitialStage::run(CgiRequestContext * crc) { if (crc->getRequestMethod() == "POST") { - return NextStage(new RequestStage(ScriptReader::resolveScript(CgiApplicationEngine::requestRoot, + return NextStage(std::make_shared(ScriptReader::resolveScript(CgiApplicationEngine::requestRoot, crc->router->route(), false))); } else { - return NextStage(new PresentStage(ScriptReader::resolveScript(CgiApplicationEngine::presentRoot, + return NextStage(std::make_shared(ScriptReader::resolveScript(CgiApplicationEngine::presentRoot, crc->router->isDefault() ? CgiApplicationEngine::defaultPresent : crc->router->route(), false), crc)); } } diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp index 04fae92..33f0298 100644 --- a/project2/cgi/cgiStagePresent.cpp +++ b/project2/cgi/cgiStagePresent.cpp @@ -11,11 +11,11 @@ CgiApplicationEngine::PresentStage::PresentStage(ScriptReaderPtr s, CgiRequestCo CheckHost(s->root()), ViewHost(s->root()), presenter([this, crc] { - auto p = PresenterFactory::createNew(CgiApplicationEngine::defaultPresenter, root.get(), Default, crc); - auto xp = dynamic_cast(p); - auto cp = dynamic_cast(p); + auto p = PresenterFactory::createNew(CgiApplicationEngine::defaultPresenter, root, Default, crc); + auto xp = std::dynamic_pointer_cast(p); + auto cp = std::dynamic_pointer_cast(p); if (xp && cp && cp->contentType == CgiApplicationEngine::transformContentType) { - auto h = TransformTargetFactory::createNew(CgiApplicationEngine::transformTargetType, root.get(), Default); + auto h = TransformTargetFactory::createNew(CgiApplicationEngine::transformTargetType, root, Default); xp->addTarget(h, crc, root); } return p; @@ -34,12 +34,12 @@ CgiApplicationEngine::PresentStage::run(CgiRequestContext * crc) time_t reqMS = crc->getRequestModifiedSince(); CgiRequestContext::ETags etags = crc->getRequestETags(); for (const PresenterCachePtr & pc : caches) { - if (pc->check(root->script->modifiedTime(), crc)) { + if (pc->check(root->script.lock()->modifiedTime(), crc)) { if (reqMS >= pc->getModifiedTime() && (etags.empty() || AdHoc::containerContains(etags, pc->getSHA1()))) { - header = HttpHeaderPtr(new Project2HttpHeader("304 Not Modified")); - return NextStage(NULL, this, NULL, NULL); + header = std::make_shared("304 Not Modified"); + return NextStage(NULL, shared_from_this(), NULL, NULL); } - CacheHitStage * chs = new CacheHitStage(root, pc); + auto chs = std::make_shared(root, pc); chs->caches = backFill; return NextStage(NULL, chs, pc, NULL); } @@ -49,18 +49,18 @@ CgiApplicationEngine::PresentStage::run(CgiRequestContext * crc) } try { executeViews(crc); - header = HttpHeaderPtr(new Project2HttpHeader("200 OK")); - return NextStage(NULL, this, boost::dynamic_pointer_cast(presenter), presenter); + header = std::make_shared("200 OK"); + return NextStage(NULL, shared_from_this(), std::dynamic_pointer_cast(presenter.deref()), presenter); } catch (EmptyRequiredRows) { - header = HttpHeaderPtr(new Project2HttpHeader("404 Not found")); - return NextStage(NULL, this, boost::dynamic_pointer_cast(presenter), presenter); + header = std::make_shared("404 Not found"); + return NextStage(NULL, shared_from_this(), std::dynamic_pointer_cast(presenter.deref()), presenter); } catch (ResponseStagePtr & p) { - return NextStage(NULL, p, boost::dynamic_pointer_cast(p), boost::dynamic_pointer_cast(p)); + return NextStage(NULL, p, std::dynamic_pointer_cast(p), std::dynamic_pointer_cast(p)); } catch (StagePtr & p) { - return NextStage(p, NULL, boost::dynamic_pointer_cast(p), boost::dynamic_pointer_cast(p)); + return NextStage(p, NULL, std::dynamic_pointer_cast(p), std::dynamic_pointer_cast(p)); } } diff --git a/project2/cgi/cgiStageRedirect.cpp b/project2/cgi/cgiStageRedirect.cpp index 18de9f9..ba9e37d 100644 --- a/project2/cgi/cgiStageRedirect.cpp +++ b/project2/cgi/cgiStageRedirect.cpp @@ -14,14 +14,14 @@ namespace CgiApplicationExtras { CgiApplicationEngine::HttpHeaderPtr getHeader(CgiRequestContext *) const { - Project2HttpHeader * header = new Project2HttpHeader("301 Moved Permanently"); + auto header = std::make_shared("301 Moved Permanently"); header->addHeader("Location", url); return CgiApplicationEngine::HttpHeaderPtr(header); } CgiApplicationEngine::NextStage run(CgiRequestContext *) { - return CgiApplicationEngine::NextStage(NULL, this, NULL, NULL); + return CgiApplicationEngine::NextStage(NULL, shared_from_this(), NULL, NULL); } private: const std::string url; @@ -35,7 +35,7 @@ namespace CgiApplicationExtras { url(e, "url") { } void execute(const MultiRowSetPresenter *, ExecContext * ec) const { - throw CgiApplicationEngine::ResponseStagePtr(new RedirectStage(url(ec))); + throw std::make_shared(url(ec)); } private: Variable url; diff --git a/project2/cgi/cgiStageRequest.cpp b/project2/cgi/cgiStageRequest.cpp index 1cf03c9..d58cf38 100644 --- a/project2/cgi/cgiStageRequest.cpp +++ b/project2/cgi/cgiStageRequest.cpp @@ -21,23 +21,23 @@ CgiApplicationEngine::RequestStage::run(CgiRequestContext * ec) runChecks(ec); execute(ec); if (!present(ec).isNull()) { - return NextStage(new PresentStage(ScriptReader::resolveScript(CgiApplicationEngine::presentRoot, present(ec), false), ec), this); + return NextStage(std::make_shared(ScriptReader::resolveScript(CgiApplicationEngine::presentRoot, present(ec), false), ec), shared_from_this()); } - return NextStage(NULL, this); + return NextStage(NULL, shared_from_this()); } CgiApplicationEngine::HttpHeaderPtr CgiApplicationEngine::RequestStage::getHeader(CgiRequestContext * ec) const { - Project2HttpHeader * header; + HttpHeaderPtr header; if (redirect(ec).isNull()) { - header = new Project2HttpHeader("200 OK"); + header = std::make_shared("200 OK"); } else { - header = new Project2HttpHeader("301 Moved Permanently"); + header = std::make_shared("301 Moved Permanently"); header->addHeader("Location", redirect(ec)); } header->addHeader("Cache-control", "no-cache"); - return HttpHeaderPtr(header); + return header; } diff --git a/project2/cgi/testCgi.cpp b/project2/cgi/testCgi.cpp index 7f9df28..b1a5a3b 100644 --- a/project2/cgi/testCgi.cpp +++ b/project2/cgi/testCgi.cpp @@ -29,9 +29,10 @@ class TestInput : public cgicc::CgiInput, public CgiEnvInput { typedef std::map OptStore; TestInput(int argc, char ** argv) { - AdHoc::PluginManager::getDefault()->add(new FileOptions(".testCgi.settings"), "_1", __FILE__, __LINE__); - AdHoc::PluginManager::getDefault()->add( - new CommandLineArguments(argc, argv, [](const char * url) { urls.push_back(url); }), "_2", __FILE__, __LINE__); + AdHoc::PluginManager::getDefault()->create( + "_1", __FILE__, __LINE__, ".testCgi.settings"); + AdHoc::PluginManager::getDefault()->create( + "_2", __FILE__, __LINE__, argc, argv, [](const char * url) { urls.push_back(url); }); } ~TestInput() { diff --git a/project2/common/aggregate.cpp b/project2/common/aggregate.cpp index 07d6902..42e1a42 100644 --- a/project2/common/aggregate.cpp +++ b/project2/common/aggregate.cpp @@ -23,6 +23,6 @@ Aggregate::pushValue(ExecContext * ec) const pushValue(value(ec), ec); } -INSTANTIATEFACTORY(ValueAggregate, const ScriptNode *); -INSTANTIATEFACTORY(SetAggregate, const ScriptNode *); +INSTANTIATEFACTORY(ValueAggregate, std::shared_ptr); +INSTANTIATEFACTORY(SetAggregate, std::shared_ptr); diff --git a/project2/common/aggregate.h b/project2/common/aggregate.h index 90d8248..222cf09 100644 --- a/project2/common/aggregate.h +++ b/project2/common/aggregate.h @@ -24,8 +24,8 @@ class DLL_PUBLIC ValueAggregate : public Aggregate { virtual VariableType resultValue() const = 0; }; -typedef boost::intrusive_ptr ValueAggregateCPtr; -typedef AdHoc::Factory ValueAggregateFactory; +typedef std::shared_ptr ValueAggregateCPtr; +typedef AdHoc::Factory> ValueAggregateFactory; class DLL_PUBLIC SetAggregate : public Aggregate { public: @@ -34,7 +34,7 @@ class DLL_PUBLIC SetAggregate : public Aggregate { virtual void onResultValues(const UseAgg &) const = 0; }; -typedef boost::intrusive_ptr SetAggregateCPtr; -typedef AdHoc::Factory SetAggregateFactory; +typedef std::shared_ptr SetAggregateCPtr; +typedef AdHoc::Factory> SetAggregateFactory; #endif diff --git a/project2/common/check.cpp b/project2/common/check.cpp index 37879e2..3a29a9b 100644 --- a/project2/common/check.cpp +++ b/project2/common/check.cpp @@ -13,7 +13,7 @@ Check::Check(ScriptNodePtr p) : group(p, "group", "default"), present(p, "present", "") { - p->script->loader.addLoadTarget(p, Storer::into(&test)); + p->script.lock()->loader.addLoadTarget(p, Storer::into(&test)); } Check::~Check() @@ -29,5 +29,5 @@ Check::performCheck(ExecContext * ec) const return test->passes(ec); } -INSTANTIATEFACTORY(Check, const ScriptNode *); +INSTANTIATEFACTORY(Check, std::shared_ptr); diff --git a/project2/common/check.h b/project2/common/check.h index 8b9ce14..73dbacb 100644 --- a/project2/common/check.h +++ b/project2/common/check.h @@ -21,8 +21,8 @@ class DLL_PUBLIC Check : public SourceObject { const Variable present; TestPtr test; }; -typedef boost::intrusive_ptr CheckCPtr; -typedef AdHoc::Factory CheckFactory; +typedef std::shared_ptr CheckCPtr; +typedef AdHoc::Factory> CheckFactory; #endif diff --git a/project2/common/checkHost.cpp b/project2/common/checkHost.cpp index eb2bae7..8784ad9 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(&checks)); + s->script.lock()->loader.addLoadTarget(s, Storer::into(&checks)); } CheckHost::~CheckHost() diff --git a/project2/common/columns.cpp b/project2/common/columns.cpp index f98c4e5..bcb3655 100644 --- a/project2/common/columns.cpp +++ b/project2/common/columns.cpp @@ -18,9 +18,9 @@ Column::Column(unsigned int i, const Glib::ustring & n, const Variable & v) : { } -Column * +std::shared_ptr Column::make(unsigned int idx, ScriptNodePtr p) { - return new Column(idx, p); + return std::make_shared(idx, p); } diff --git a/project2/common/columns.h b/project2/common/columns.h index 72fd40b..5845c72 100644 --- a/project2/common/columns.h +++ b/project2/common/columns.h @@ -7,13 +7,13 @@ #include #include -class DLL_PUBLIC Column : public IntrusivePtrBase { +class DLL_PUBLIC Column { public: Column(unsigned int idx, ScriptNodePtr p); Column(unsigned int i, const Glib::ustring & n, const Variable & v = Variable(Null())); virtual ~Column() = default; - static Column * make(unsigned int idx, ScriptNodePtr p); + static std::shared_ptr make(unsigned int idx, ScriptNodePtr p); const unsigned int idx; const Glib::ustring name; @@ -23,7 +23,7 @@ class DLL_PUBLIC Column : public IntrusivePtrBase { struct byColIdx {}; struct byColName {}; -typedef boost::intrusive_ptr ColumnPtr; +typedef std::shared_ptr ColumnPtr; typedef boost::multi_index::multi_index_containerscript), scriptLoaded(false) { - s->script->loader.addLoadTarget(s, Storer::into(&rowSets)); + s->script.lock()->loader.addLoadTarget(s, Storer::into(&rowSets)); } CommonObjects::~CommonObjects() diff --git a/project2/common/commonObjects.h b/project2/common/commonObjects.h index 474e7e4..7ea914d 100644 --- a/project2/common/commonObjects.h +++ b/project2/common/commonObjects.h @@ -7,7 +7,7 @@ #include "options.h" #include -class DLL_PUBLIC CommonObjects : public virtual IntrusivePtrBase { +class DLL_PUBLIC CommonObjects { public: typedef STORAGEOF(RowSet) RowSets; typedef STORAGEOF(DataSource) DataSources; @@ -27,7 +27,7 @@ class DLL_PUBLIC CommonObjects : public virtual IntrusivePtrBase { if (i == datasources.end()) { i = loadDataSource(name); } - DataSourceType * s = boost::dynamic_pointer_cast(i->second).get(); + DataSourceType * s = std::dynamic_pointer_cast(i->second).get(); if (!s) { throw DataSourceNotCompatible(name); } diff --git a/project2/common/dataSource.cpp b/project2/common/dataSource.cpp index da1ab52..1c20056 100644 --- a/project2/common/dataSource.cpp +++ b/project2/common/dataSource.cpp @@ -8,5 +8,5 @@ DataSource::DataSource(ScriptNodePtr p) : { } -INSTANTIATEFACTORY(DataSource, const ScriptNode *); +INSTANTIATEFACTORY(DataSource, std::shared_ptr); diff --git a/project2/common/dataSource.h b/project2/common/dataSource.h index baaaac7..c5326e5 100644 --- a/project2/common/dataSource.h +++ b/project2/common/dataSource.h @@ -6,7 +6,7 @@ #include class DataSource; -typedef boost::intrusive_ptr DataSourcePtr; +typedef std::shared_ptr DataSourcePtr; /// Base class for data sources providing transaction support class DLL_PUBLIC DataSource : public SourceObject { @@ -18,7 +18,7 @@ class DLL_PUBLIC DataSource : public SourceObject { virtual void commit() { }; virtual void rollback() { }; }; -typedef AdHoc::Factory DataSourceFactory; +typedef AdHoc::Factory> DataSourceFactory; #endif diff --git a/project2/common/definedColumns.h b/project2/common/definedColumns.h index 2459872..1afb305 100644 --- a/project2/common/definedColumns.h +++ b/project2/common/definedColumns.h @@ -8,7 +8,7 @@ class DLL_PUBLIC DefinedColumns { public: - typedef boost::function2 ColCreator; + typedef boost::function2, unsigned int, ScriptNodePtr> ColCreator; DefinedColumns(ScriptNodePtr p, const Glib::ustring & colPath, const ColCreator & func); Columns columns; }; diff --git a/project2/common/execContext.cpp b/project2/common/execContext.cpp index bbec92a..aaf725e 100644 --- a/project2/common/execContext.cpp +++ b/project2/common/execContext.cpp @@ -10,7 +10,7 @@ ExecContext::logMessage(bool writeLog, const Glib::ustring & g, const Glib::ustr if (writeLog) { Logger()->messagebf(LOG_NOTICE, "%s: %s: %s", __PRETTY_FUNCTION__, g, m); } - messages.push_back(new Message(g, m)); + messages.push_back(std::make_shared(g, m)); } void diff --git a/project2/common/execContext.h b/project2/common/execContext.h index 4fcf36c..30e2e0e 100644 --- a/project2/common/execContext.h +++ b/project2/common/execContext.h @@ -2,7 +2,6 @@ #define EXECCONTEXT_H #include -#include #include #include "variableType.h" #include "session.h" @@ -14,14 +13,14 @@ class IHaveParameters; class DLL_PUBLIC ExecContext { public: - class Message : public IntrusivePtrBase { + class Message { public: Message(const Glib::ustring & g, const Glib::ustring & m); const Glib::ustring group; const Glib::ustring message; }; - typedef boost::intrusive_ptr MessagePtr; + typedef std::shared_ptr MessagePtr; typedef std::list Messages; typedef std::vector RowValuesStack; typedef std::vector ParameterStack; diff --git a/project2/common/iHaveParameters.h b/project2/common/iHaveParameters.h index e8d7519..e76de52 100644 --- a/project2/common/iHaveParameters.h +++ b/project2/common/iHaveParameters.h @@ -1,10 +1,8 @@ #ifndef IHAVEPARAMETERS #define IHAVEPARAMETERS -#include #include #include "variables.h" -#include "intrusivePtrBase.h" #include /// Mix-in base class to store parameters for component execution diff --git a/project2/common/lifeCycle.cpp b/project2/common/lifeCycle.cpp index 60ed172..420632c 100644 --- a/project2/common/lifeCycle.cpp +++ b/project2/common/lifeCycle.cpp @@ -1,5 +1,5 @@ #include "lifeCycle.h" -#include +#include #include LifeCycle::~LifeCycle() @@ -40,8 +40,8 @@ void LifeCycle::onAllComponents(const boost::function & func) { for(auto p : AdHoc::PluginManager::getDefault()->getAll()) { - if (auto c = dynamic_cast(p->implementation())) { - func(c); + if (auto c = std::dynamic_pointer_cast(p->instance())) { + func(c.get()); } } } diff --git a/project2/common/logger.cpp b/project2/common/logger.cpp index f21bd40..40a72b0 100644 --- a/project2/common/logger.cpp +++ b/project2/common/logger.cpp @@ -82,12 +82,6 @@ Log::vmessagef(int priority, const char * msgfmt, va_list va) const } -boost::shared_ptr -Log::getFormat(const std::string & msgfmt) -{ - return AdHoc::Buffer::getFormat(msgfmt); -} - Log * Logger::operator->() const { diff --git a/project2/common/logger.h b/project2/common/logger.h index c6c1be0..d5c3c01 100644 --- a/project2/common/logger.h +++ b/project2/common/logger.h @@ -4,9 +4,7 @@ #include #include #include // Pulled in for easy client lookups of LOG_* priorties -#include #include -#include "intrusivePtrBase.h" #include #include #include "lifeCycle.h" @@ -15,7 +13,7 @@ class LogDriverBase; class LogDriverFactory; class DLL_PUBLIC Log { public: - typedef boost::intrusive_ptr LogDriverBasePtr; + typedef std::shared_ptr LogDriverBasePtr; typedef std::map LogDrivers; Log(); @@ -28,8 +26,8 @@ class DLL_PUBLIC Log { template void messagebf(int priority, const char * msgfmt, const Args & ... args) const { if (priority > lowestLevel) return; - boost::shared_ptr fmt = getFormat(msgfmt); - messagebf(priority, *fmt, args...); + boost::format fmt = AdHoc::Buffer::getFormat(msgfmt); + messagebf(priority, fmt, args...); } void vmessagef(int priority, const char * msgfmt, va_list) const; diff --git a/project2/common/loggerFactory.h b/project2/common/loggerFactory.h index 1c6033b..780cbcc 100644 --- a/project2/common/loggerFactory.h +++ b/project2/common/loggerFactory.h @@ -3,12 +3,11 @@ #include #include "lifeCycle.h" -#include "intrusivePtrBase.h" #include "logger.h" #include /// Base class for classes providing a logging facility -class DLL_PUBLIC LogDriverBase : public virtual IntrusivePtrBase { +class DLL_PUBLIC LogDriverBase { public: LogDriverBase(); virtual ~LogDriverBase(); @@ -27,13 +26,13 @@ class LogDriverFactoryImpl : public LogDriverFactory, public LifeCycle { LogDriverFactoryImpl(); virtual void onConfigLoad() override; - inline LoggerType * create() const override; + inline std::shared_ptr create() const override; int loggerLevel() const override; const int & level; protected: - mutable boost::intrusive_ptr instance; + mutable std::shared_ptr instance; }; #endif diff --git a/project2/common/loggerFactory.impl.h b/project2/common/loggerFactory.impl.h index 61711fd..2488c6e 100644 --- a/project2/common/loggerFactory.impl.h +++ b/project2/common/loggerFactory.impl.h @@ -20,13 +20,13 @@ LogDriverFactoryImpl::onConfigLoad() } template -T * +std::shared_ptr LogDriverFactoryImpl::create() const { if (!instance) { - instance = new T(); + instance = std::make_shared(); } - return instance.get(); + return instance; } template diff --git a/project2/common/options.cpp b/project2/common/options.cpp index 7819bd9..20577eb 100644 --- a/project2/common/options.cpp +++ b/project2/common/options.cpp @@ -75,7 +75,7 @@ Options::Options(Glib::ustring const & n) : Options & Options::operator()(const Glib::ustring & n, TargetPtr t, const Glib::ustring & d) { - options.push_back(new NamedOption(n, t, d)); + options.push_back(std::make_shared(n, t, d)); return *this; } @@ -84,7 +84,7 @@ Options::operator()(const Glib::ustring & a) { for (OptionList::const_reverse_iterator i = options.rbegin(); i != options.rend(); ++i) { if (const NamedOption * no = dynamic_cast(i->get())) { - options.push_back(new OptionAlias(a, no)); + options.push_back(std::make_shared(a, no)); break; } } diff --git a/project2/common/options.h b/project2/common/options.h index 4c52649..0d61d2f 100644 --- a/project2/common/options.h +++ b/project2/common/options.h @@ -2,7 +2,6 @@ #define OPTIONS_H #include -#include #include #include #include @@ -19,13 +18,13 @@ class DLL_PUBLIC Options : public AdHoc::AbstractPluginImplementation { enum TargetState { Default = 1, Global = 2, Platform = 3 }; typedef boost::function CurrentPlatform; - class Target : public IntrusivePtrBase { + class Target { public: virtual void reset() const = 0; virtual bool paramRequired() const = 0; virtual void consume(const Glib::ustring & platform, const VariableType & value, const CurrentPlatform & currentPlatform) const = 0; }; - typedef boost::intrusive_ptr TargetPtr; + typedef std::shared_ptr TargetPtr; typedef boost::function Assigner; typedef boost::function Resetter; @@ -42,7 +41,7 @@ class DLL_PUBLIC Options : public AdHoc::AbstractPluginImplementation { Resetter resetter; }; - class Option : public IntrusivePtrBase { + class Option { public: virtual void reset() const = 0; virtual bool paramRequired() const = 0; @@ -51,7 +50,7 @@ class DLL_PUBLIC Options : public AdHoc::AbstractPluginImplementation { virtual bool accepts(const Glib::ustring & name) const = 0; virtual void consume(const Glib::ustring & name, const Glib::ustring & platform, const VariableType & value, const CurrentPlatform & currentPlatform) const = 0; }; - typedef boost::intrusive_ptr