diff options
Diffstat (limited to 'icetray/dryice')
-rw-r--r-- | icetray/dryice/Jamfile.jam | 22 | ||||
-rw-r--r-- | icetray/dryice/dryice.cpp | 49 | ||||
-rw-r--r-- | icetray/dryice/dryice.h | 32 | ||||
-rw-r--r-- | icetray/dryice/mockPool.cpp | 21 | ||||
-rw-r--r-- | icetray/dryice/mockPool.h | 20 |
5 files changed, 144 insertions, 0 deletions
diff --git a/icetray/dryice/Jamfile.jam b/icetray/dryice/Jamfile.jam new file mode 100644 index 0000000..3f8751b --- /dev/null +++ b/icetray/dryice/Jamfile.jam @@ -0,0 +1,22 @@ +import package ; + +lib dryice : + dryice.cpp + mockPool.cpp + : + <library>..//adhocutil + <library>../icetray//icetray + <library>..//Ice + <library>..//IceUtil + <library>..//IceBox + <library>..//pthread + <library>..//boost_system + <library>..//boost_thread + <library>..//dl + <cflags>-fvisibility=hidden + : : + <include>. + ; + +package.install install-dryice : <install-source-root>. : : dryice : [ glob *.h : mockPool.h ] ; + diff --git a/icetray/dryice/dryice.cpp b/icetray/dryice/dryice.cpp new file mode 100644 index 0000000..50f85cb --- /dev/null +++ b/icetray/dryice/dryice.cpp @@ -0,0 +1,49 @@ +#include "dryice.h" +#include <boost/assert.hpp> +#include <dlfcn.h> +#include <factory.h> +#include <Ice/Initialize.h> + +namespace IceTray { + typedef IceBox::Service *(* SetupFunction)(Ice::CommunicatorPtr); + + DryIce::DryIce(const Ice::StringSeq & cmdline) + { + void * i = dlsym(NULL, "createIceTrayService"); + BOOST_VERIFY(i); + auto sf = (SetupFunction)i; + BOOST_VERIFY(sf); + Ice::StringSeq args; + Ice::InitializationData id; + id.properties = Ice::createProperties(); + id.properties->setProperty("DryIce.Endpoints", "tcp -p 9002"); + id.properties->setProperty("DryIce.PoolProvider", "MockPool"); + id.properties->parseCommandLineOptions("", cmdline); + ic = Ice::initialize(args, id); + s = sf(nullptr); + s->start("DryIce", ic, {}); + } + + DryIce::~DryIce() + { + if (s) { + s->stop(); + s = NULL; + } + if (ic) { + ic->destroy(); + ic = NULL; + } + } + + DryIceClient::DryIceClient() + { + ic = Ice::initialize(); + } + + DryIceClient::~DryIceClient() + { + ic->destroy(); + } +} + diff --git a/icetray/dryice/dryice.h b/icetray/dryice/dryice.h new file mode 100644 index 0000000..f81a48c --- /dev/null +++ b/icetray/dryice/dryice.h @@ -0,0 +1,32 @@ +#ifndef ICETRAY_TESTSETUP_H +#define ICETRAY_TESTSETUP_H + +#include <Ice/Communicator.h> +#include <IceBox/IceBox.h> +#include <visibility.h> + +namespace IceTray { + class DLL_PUBLIC DryIce { + public: + DryIce(const Ice::StringSeq & = Ice::StringSeq()); + DryIce(const DryIce &) = delete; + virtual ~DryIce(); + + void operator=(const DryIce &) = delete; + + protected: + Ice::CommunicatorPtr ic; + IceBox::ServicePtr s; + }; + + class DLL_PUBLIC DryIceClient { + public: + DryIceClient(); + virtual ~DryIceClient(); + + Ice::CommunicatorPtr ic; + }; +} + +#endif + diff --git a/icetray/dryice/mockPool.cpp b/icetray/dryice/mockPool.cpp new file mode 100644 index 0000000..43e7c0c --- /dev/null +++ b/icetray/dryice/mockPool.cpp @@ -0,0 +1,21 @@ +#include "mockPool.h" +#include "icetrayService.h" +#include <factory.impl.h> + +namespace IceTray { + MockPool::MockPool(const std::string & name, const std::string &, Ice::PropertiesPtr p) : + DatabasePool( + p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10), + p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2)), + name(name) + { + } + + DB::Connection * MockPool::createResource() const + { + return DB::MockDatabase::openConnectionTo(name); + } + + FACTORY(MockPool, PoolProvider); +}; + diff --git a/icetray/dryice/mockPool.h b/icetray/dryice/mockPool.h new file mode 100644 index 0000000..8936cb2 --- /dev/null +++ b/icetray/dryice/mockPool.h @@ -0,0 +1,20 @@ +#ifndef ICETRAY_MOCKPOOL_H +#define ICETRAY_MOCKPOOL_H + +#include "database.h" +#include <mockDatabase.h> +#include <Ice/Properties.h> + +namespace IceTray { + class MockPool : public DatabasePool { + public: + MockPool(const std::string & name, const std::string &, Ice::PropertiesPtr p); + + DB::Connection * createResource() const override; + + const std::string name; + }; +} + +#endif + |