summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icetray/icetray/icetrayService.cpp22
-rw-r--r--icetray/icetray/icetrayService.h7
2 files changed, 29 insertions, 0 deletions
diff --git a/icetray/icetray/icetrayService.cpp b/icetray/icetray/icetrayService.cpp
index aff6a8a..7f66cd1 100644
--- a/icetray/icetray/icetrayService.cpp
+++ b/icetray/icetray/icetrayService.cpp
@@ -2,8 +2,30 @@
#include <visibility.h>
#include <factory.impl.h>
#include "icetrayService.h"
+#include <boost/assert.hpp>
namespace IceTray {
+ Service * Service::current = nullptr;
+
+ Service::Service()
+ {
+ BOOST_ASSERT(!current);
+ current = this;
+ }
+
+ Service::~Service()
+ {
+ BOOST_ASSERT(current);
+ current = nullptr;
+ }
+
+ Service *
+ Service::getCurrent()
+ {
+ BOOST_ASSERT(current);
+ return current;
+ }
+
void Service::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq & args)
{
adp = ic->createObjectAdapter(name);
diff --git a/icetray/icetray/icetrayService.h b/icetray/icetray/icetrayService.h
index c59028a..69ab487 100644
--- a/icetray/icetray/icetrayService.h
+++ b/icetray/icetray/icetrayService.h
@@ -9,6 +9,9 @@
namespace IceTray {
class DLL_PUBLIC Service : public IceBox::Service, public AdHoc::AbstractPluginImplementation {
public:
+ Service();
+ virtual ~Service();
+
virtual void addObjects(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &) = 0;
void start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq & args) override;
@@ -17,7 +20,11 @@ namespace IceTray {
DatabasePoolPtr getConnectionPool(const Ice::CommunicatorPtr & ic, const std::string & type, const std::string & prefix);
+ static Service * getCurrent();
Ice::ObjectAdapterPtr adp;
+
+ private:
+ static Service * current;
};
typedef IceInternal::Handle<Service> ServicePtr;