diff options
Diffstat (limited to 'project2/ice/iceDaemon.cpp')
-rw-r--r-- | project2/ice/iceDaemon.cpp | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/project2/ice/iceDaemon.cpp b/project2/ice/iceDaemon.cpp index 04d6fdb..a8fb8c2 100644 --- a/project2/ice/iceDaemon.cpp +++ b/project2/ice/iceDaemon.cpp @@ -1,8 +1,8 @@ #include <pch.hpp> #include "iceDaemon.h" #include "buildComms.h" -#include "buildShared.h" #include "buildDaemon.h" +#include "iceViewSerializer.h" #include <scriptLoader.h> #include <options.h> #include <sys/stat.h> @@ -20,12 +20,18 @@ std::string IceDaemon::adapterName; std::string IceDaemon::adapterEndpoint; -std::string IceDaemon::interface; -std::string IceDaemon::slice; std::string IceDaemon::viewRoot; std::string IceDaemon::taskRoot; +IceBase::Libs IceDaemon::libs; -DECLARE_GENERIC_LOADER("ice", DaemonLoader, IceDaemon); +class IceDaemonLoader : public DaemonLoader::For<IceDaemon> { + public: + void onConfigLoad() override { + IceBase::FinaliseLoad(IceDaemon::libs); + } +}; + +DECLARE_CUSTOM_COMPONENT_LOADER("ice", IceDaemon, IceDaemonLoader, DaemonLoader); DECLARE_OPTIONS(IceDaemon, "ICE Daemon Options") ("ice.daemon.viewRoot", Options::value(&viewRoot, "views"), "The folder in which to find view scripts") @@ -35,10 +41,12 @@ DECLARE_OPTIONS(IceDaemon, "ICE Daemon Options") "The name of the ICE adapter created") ("ice.daemon.adapterEndpoint", Options::value(&adapterEndpoint), "The ICE endpoint string for the ICE adapter") -("ice.daemon.slice", Options::value(&slice), - "The ICE Slice file to compile") -("ice.daemon.interface", Options::value(&interface), - "The ICE interface to wrap") +("ice.daemon.slice", Options::functions(boost::bind(&IceBase::SetSlice, boost::ref(IceDaemon::libs), &IceDaemon::GetComponentCompiler, _1, true, true), boost::bind(&IceDaemon::ClearSlice)), + "The ICE Slice file(s) to compile") +("ice.daemon.slicedaemon", Options::functions(boost::bind(&IceDaemon::SetSlice, boost::ref(IceDaemon::libs), &IceDaemon::GetComponentCompiler, _1, false, true), boost::bind(&IceDaemon::ClearSlice)), + "The ICE Slice file(s) to compile (daemon only, assumes comms library referenced)") +("ice.daemon.slicerdaemon", Options::functions(boost::bind(&IceDaemon::SetSlice, boost::ref(IceDaemon::libs), &IceDaemon::GetComponentCompiler, _1, false, false), boost::bind(&IceDaemon::ClearSlice)), + "The ICE Slice file(s) to compile (daemon only, assumes comms library referenced and built with Slicer support)") END_OPTIONS(IceDaemon); IceDaemon::IceDaemon(int & argc, char ** argv) : @@ -60,31 +68,28 @@ IceDaemon::shutdown() const void IceDaemon::run() const { - Logger()->messagebf(LOG_INFO, ">>> %s compiling slice '%s'...", __PRETTY_FUNCTION__, slice); - - IceCompile::CPtr bc(new BuildComms(slice)); - IceCompile::CPtr bds(new BuildShared(slice, { bc })); - IceCompile::CPtr bd(new BuildDaemon(slice, { bds })); - bd->Update(); - - auto library = bd->Open(); - Logger()->messagebf(LOG_INFO, " %s starting...", __PRETTY_FUNCTION__); Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(adapterName, adapterEndpoint); - IceDaemonAdapterHandlerPtr interfacePtr = IceDaemonAdapterHandlerLoader::createNew(interface); - interfacePtr->add(adapter, this, ic); + std::set<IceDaemonAdapterHandlerPtr> interfaces; + InstanceSet<IceDaemonAdapterHandlerLoader>::OnAll([this, adapter, &interfaces](IceDaemonAdapterHandlerLoader * loader) { + IceDaemonAdapterHandlerPtr interfacePtr = loader->create(); + interfacePtr->add(adapter, this, ic); + interfaces.insert(interfacePtr); + }); adapter->activate(); Logger()->messagebf(LOG_INFO, " %s running...", __PRETTY_FUNCTION__); - interfacePtr->remove(adapter, ic); + BOOST_FOREACH(const auto & interfacePtr, interfaces) { + interfacePtr->remove(adapter, ic); + } ic->waitForShutdown(); Logger()->messagebf(LOG_INFO, " %s stopped...", __PRETTY_FUNCTION__); Logger()->messagebf(LOG_INFO, "<<< %s", __PRETTY_FUNCTION__); } -class IceDaemonFlatViewHost : public virtual CommonObjects, public virtual CheckHost { +class IceDaemonViewHost : public virtual CommonObjects, public virtual CheckHost { public: - IceDaemonFlatViewHost(ScriptNodePtr s) : + IceDaemonViewHost(ScriptNodePtr s) : CommonObjects(s), CheckHost(s) { @@ -93,6 +98,7 @@ class IceDaemonFlatViewHost : public virtual CommonObjects, public virtual Check void executeView(RowSetPresenterPtr presenter, ExecContext * ec) const { loadScriptComponents(); + runChecks(ec); view->execute(presenter.get(), ec); // Caches might open transactions BOOST_FOREACH(const CommonObjects::DataSources::value_type & ds, CommonObjects::datasources) { @@ -127,12 +133,12 @@ class IceCallContext : public ExecContext { }; void -IceDaemon::executeView(const std::string & name, RowSetPresenterPtr p, const ParamMap & pm) const +IceDaemon::executeView(const std::string & name, Slicer::ModelPartPtr p, const ParamMap & pm) const { ScriptNodePtr s = ScriptReader::resolveScript(IceDaemon::viewRoot, name, false)->root(); - IceDaemonFlatViewHost f(s); + IceDaemonViewHost f(s); IceCallContext icc(pm); - f.executeView(p, &icc); + f.executeView(new IceViewSerializer(p), &icc); } class IceDaemonTaskHost : public TaskHost { @@ -159,3 +165,15 @@ IceDaemon::executeTask(const std::string & name, const ParamMap & pm) const t.executeTask(&icc); } +IceCompile::CPtr +IceDaemon::GetComponentCompiler(const std::string & slice, const IceCompile::Deps & deps) +{ + return IceCompile::CPtr(new BuildDaemon(slice, deps)); +} + +void +IceDaemon::ClearSlice() +{ + libs.clear(); +} + |