summaryrefslogtreecommitdiff
path: root/project2/ice/iceDaemon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/ice/iceDaemon.cpp')
-rw-r--r--project2/ice/iceDaemon.cpp82
1 files changed, 53 insertions, 29 deletions
diff --git a/project2/ice/iceDaemon.cpp b/project2/ice/iceDaemon.cpp
index 04d6fdb..7f506d4 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,29 @@ 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();
+ Logger()->messagebf(LOG_DEBUG, " %s creating adapter %s [%s]...", __PRETTY_FUNCTION__, adapterName, adapterEndpoint);
+ Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(adapterName, adapterEndpoint);
- auto library = bd->Open();
+ Logger()->messagebf(LOG_DEBUG, " %s installing servants...", __PRETTY_FUNCTION__);
+ std::set<IceDaemonAdapterHandlerPtr> interfaces;
+ InstanceSet<IceDaemonAdapterHandlerLoader>::OnAll([this, adapter, &interfaces](IceDaemonAdapterHandlerLoader * loader) {
+ IceDaemonAdapterHandlerPtr interfacePtr = loader->create();
+ interfacePtr->add(adapter, this, ic);
+ interfaces.insert(interfacePtr);
+ });
- 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);
+ Logger()->messagebf(LOG_DEBUG, " %s starting...", __PRETTY_FUNCTION__);
adapter->activate();
+
Logger()->messagebf(LOG_INFO, " %s running...", __PRETTY_FUNCTION__);
- interfacePtr->remove(adapter, ic);
ic->waitForShutdown();
- Logger()->messagebf(LOG_INFO, " %s stopped...", __PRETTY_FUNCTION__);
- Logger()->messagebf(LOG_INFO, "<<< %s", __PRETTY_FUNCTION__);
+ Logger()->messagebf(LOG_INFO, " %s stopped", __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 +99,9 @@ class IceDaemonFlatViewHost : public virtual CommonObjects, public virtual Check
void executeView(RowSetPresenterPtr presenter, ExecContext * ec) const
{
loadScriptComponents();
+ Logger()->messagebf(LOG_DEBUG, "%s: run %d checks", __PRETTY_FUNCTION__, CheckHost::checks.size());
+ runChecks(ec);
+ Logger()->messagebf(LOG_DEBUG, "%s: execute view", __PRETTY_FUNCTION__);
view->execute(presenter.get(), ec);
// Caches might open transactions
BOOST_FOREACH(const CommonObjects::DataSources::value_type & ds, CommonObjects::datasources) {
@@ -127,25 +136,28 @@ 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);
+ boost::intrusive_ptr<IceDaemonViewHost> v = new IceDaemonViewHost(s);
IceCallContext icc(pm);
- f.executeView(p, &icc);
+ v->executeView(new IceViewSerializer(p), &icc);
}
class IceDaemonTaskHost : public TaskHost {
public:
IceDaemonTaskHost(ScriptNodePtr s) :
SourceObject(s),
+ CommonObjects(s),
CheckHost(s),
TaskHost(s)
{
}
void executeTask(ExecContext * ec) const
{
+ Logger()->messagebf(LOG_DEBUG, "%s: run %d checks", __PRETTY_FUNCTION__, CheckHost::checks.size());
runChecks(ec);
+ Logger()->messagebf(LOG_DEBUG, "%s: execute %d tasks", __PRETTY_FUNCTION__, TaskHost::tasks.size());
execute(ec);
}
};
@@ -154,8 +166,20 @@ void
IceDaemon::executeTask(const std::string & name, const ParamMap & pm) const
{
ScriptNodePtr s = ScriptReader::resolveScript(IceDaemon::taskRoot, name, false)->root();
- IceDaemonTaskHost t(s);
+ boost::intrusive_ptr<IceDaemonTaskHost> t = new IceDaemonTaskHost(s);
IceCallContext icc(pm);
- t.executeTask(&icc);
+ 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();
}