diff options
Diffstat (limited to 'icetray/dryice')
-rw-r--r-- | icetray/dryice/dryice.cpp | 9 | ||||
-rw-r--r-- | icetray/dryice/dryice.h | 10 |
2 files changed, 15 insertions, 4 deletions
diff --git a/icetray/dryice/dryice.cpp b/icetray/dryice/dryice.cpp index 50f85cb..f16a7fc 100644 --- a/icetray/dryice/dryice.cpp +++ b/icetray/dryice/dryice.cpp @@ -7,8 +7,11 @@ namespace IceTray { typedef IceBox::Service *(* SetupFunction)(Ice::CommunicatorPtr); + DryIce * DryIce::currentDryIce = nullptr; + DryIce::DryIce(const Ice::StringSeq & cmdline) { + BOOST_ASSERT(!currentDryIce); void * i = dlsym(NULL, "createIceTrayService"); BOOST_VERIFY(i); auto sf = (SetupFunction)i; @@ -16,16 +19,18 @@ namespace IceTray { Ice::StringSeq args; Ice::InitializationData id; id.properties = Ice::createProperties(); - id.properties->setProperty("DryIce.Endpoints", "tcp -p 9002"); + id.properties->setProperty("DryIce.Endpoints", "default"); id.properties->setProperty("DryIce.PoolProvider", "MockPool"); id.properties->parseCommandLineOptions("", cmdline); ic = Ice::initialize(args, id); s = sf(nullptr); s->start("DryIce", ic, {}); + currentDryIce = this; } DryIce::~DryIce() { + currentDryIce = nullptr; if (s) { s->stop(); s = NULL; @@ -38,12 +43,10 @@ namespace IceTray { DryIceClient::DryIceClient() { - ic = Ice::initialize(); } DryIceClient::~DryIceClient() { - ic->destroy(); } } diff --git a/icetray/dryice/dryice.h b/icetray/dryice/dryice.h index f81a48c..33a3989 100644 --- a/icetray/dryice/dryice.h +++ b/icetray/dryice/dryice.h @@ -13,8 +13,12 @@ namespace IceTray { virtual ~DryIce(); void operator=(const DryIce &) = delete; + std::string getEndpoint() const; protected: + friend class DryIceClient; + static DryIce * currentDryIce; + Ice::CommunicatorPtr ic; IceBox::ServicePtr s; }; @@ -24,7 +28,11 @@ namespace IceTray { DryIceClient(); virtual ~DryIceClient(); - Ice::CommunicatorPtr ic; + template<typename Prx> + Prx getProxy(const std::string & objectName) const + { + return Prx::checkedCast(DryIce::currentDryIce->ic->stringToProxy(objectName)); + } }; } |