diff options
Diffstat (limited to 'project2/ice/iceDataSource.cpp')
-rw-r--r-- | project2/ice/iceDataSource.cpp | 66 |
1 files changed, 11 insertions, 55 deletions
diff --git a/project2/ice/iceDataSource.cpp b/project2/ice/iceDataSource.cpp index 064a69f..c3d5b36 100644 --- a/project2/ice/iceDataSource.cpp +++ b/project2/ice/iceDataSource.cpp @@ -1,18 +1,18 @@ #include <pch.hpp> -#include "iceDataSource.h" -#include "buildComms.h" -#include "buildShared.h" #include "buildClient.h" +#include "iceDataSource.h" #include <Ice/Ice.h> -IceDataSource::Libs IceDataSource::libs; +IceBase::Libs IceDataSource::libs; IceDataSource::Proxies IceDataSource::proxies; DECLARE_OPTIONS(IceDataSource, "ICE Data Source") -("ice.client.slice", Options::functions(boost::bind(&IceDataSource::SetSlice, _1), boost::bind(&IceDataSource::ClearSlice)), +("ice.client.slice", Options::functions(boost::bind(&IceBase::SetSlice, boost::ref(IceDataSource::libs), &IceDataSource::GetComponentCompiler, _1, true, true), boost::bind(&IceDataSource::ClearSlice)), "The ICE Slice file(s) to compile") -("ice.client.sliceclient", Options::functions(boost::bind(&IceDataSource::SetSliceClient, _1), boost::bind(&IceDataSource::ClearSlice)), +("ice.client.sliceclient", Options::functions(boost::bind(&IceBase::SetSlice, boost::ref(IceDataSource::libs), &IceDataSource::GetComponentCompiler, _1, false, true), boost::bind(&IceDataSource::ClearSlice)), "The ICE Slice file(s) to compile (client only, assumes comms library referenced)") +("ice.client.slicerclient", Options::functions(boost::bind(&IceBase::SetSlice, boost::ref(IceDataSource::libs), &IceDataSource::GetComponentCompiler, _1, false, false), boost::bind(&IceDataSource::ClearSlice)), + "The ICE Slice file(s) to compile (client only, assumes comms library referenced and built with Slicer support)") END_OPTIONS(IceDataSource); int dummy = 0; @@ -21,57 +21,13 @@ IceDataSource::IceDataSource(ScriptNodePtr p) : endpoint(p, "endpoint"), ic(Ice::initialize(dummy, NULL)) { + Logger()->messagebf(LOG_DEBUG, "%s: endpoint: %s", __PRETTY_FUNCTION__, endpoint(NULL)); } -void -IceDataSource::SetSlice(const VariableType & vslice) -{ - auto slice = vslice.as<std::string>(); - IceCompile::CPtr bc(new BuildComms(slice)); - bc->Update(IceCompile::UpdateBuild); - IceCompile::CPtr bcs(new BuildShared(slice, { bc })); - IceCompile::CPtr bcl(new BuildClient(slice, { bcs })); - libs.push_back(LibCompile(bcl, new std::thread(&IceCompile::Update, bcl.get(), - IceCompile::UpdateBuild | IceCompile::UpdateCompile | IceCompile::UpdateLink))); -} - -void -IceDataSource::SetSliceClient(const VariableType & vslice) -{ - auto slice = vslice.as<std::string>(); - IceCompile::CPtr bc(new BuildComms(slice)); - bc->Update(IceCompile::UpdateBuild); - IceCompile::CPtr bcs(new BuildShared(slice, { })); - IceCompile::CPtr bcl(new BuildClient(slice, { bcs })); - libs.push_back(LibCompile(bcl, new std::thread(&IceCompile::Update, bcl.get(), - IceCompile::UpdateBuild | IceCompile::UpdateCompile | IceCompile::UpdateLink))); -} - -class WaitAndLoad : public boost::static_visitor<> { - public: - WaitAndLoad(IceDataSource::LibPromise & l) : lib(l) { } - - void operator()(IceDataSource::LibCompile & th) const - { - boost::get<1>(th)->join(); - delete boost::get<1>(th); - lib = boost::get<0>(th)->Open(); - } - - void operator()(IceCompile::LibHandle) const - { - } - - private: - IceDataSource::LibPromise & lib; -}; - -void -IceDataSource::FinaliseLoad() +IceCompile::CPtr +IceDataSource::GetComponentCompiler(const std::string & slice, const IceCompile::Deps & deps) { - BOOST_FOREACH(auto & lib, libs) { - boost::apply_visitor(WaitAndLoad(lib), lib); - } + return IceCompile::CPtr(new BuildClient(slice, deps)); } void @@ -84,7 +40,7 @@ IceDataSource::ClearSlice() class IceDataSourceLoader : public ElementLoader::For<IceDataSource> { public: void onConfigLoad() override { - IceDataSource::FinaliseLoad(); + IceBase::FinaliseLoad(IceDataSource::libs); } }; |