summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icetray/dryice/dryice.cpp8
-rw-r--r--icetray/dryice/dryice.h84
-rw-r--r--icetray/dryice/mockMailServer.cpp4
-rw-r--r--icetray/dryice/mockMailServer.h13
-rw-r--r--icetray/dryice/mockPool.cpp12
-rw-r--r--icetray/dryice/mockPool.h13
-rw-r--r--icetray/icetray/abstractCachingDatabaseClient.cpp10
-rw-r--r--icetray/icetray/abstractCachingDatabaseClient.h74
-rw-r--r--icetray/icetray/abstractDatabaseClient.cpp9
-rw-r--r--icetray/icetray/abstractDatabaseClient.h87
-rw-r--r--icetray/icetray/defaultPool.cpp4
-rw-r--r--icetray/icetray/defaultPool.h7
-rw-r--r--icetray/icetray/icecube.cpp1
-rw-r--r--icetray/icetray/icecube.h89
-rw-r--r--icetray/icetray/icetrayService.cpp30
-rw-r--r--icetray/icetray/icetrayService.h73
-rw-r--r--icetray/icetray/logWriterConsole.cpp15
-rw-r--r--icetray/icetray/logWriterConsole.h12
-rw-r--r--icetray/icetray/logWriterSyslog.cpp16
-rw-r--r--icetray/icetray/logWriterSyslog.h11
-rw-r--r--icetray/icetray/logger.cpp34
-rw-r--r--icetray/icetray/logger.h165
-rw-r--r--icetray/icetray/mailServer.cpp9
-rw-r--r--icetray/icetray/mailServer.h15
-rw-r--r--icetray/icetray/mimeImpl.cpp40
-rw-r--r--icetray/icetray/mimeImpl.h45
-rw-r--r--icetray/icetray/options.cpp8
-rw-r--r--icetray/icetray/options.h72
-rw-r--r--icetray/icetray/sqlSource.cpp1
-rw-r--r--icetray/icetray/sqlSource.h17
-rw-r--r--icetray/icetray/staticSqlSource.cpp8
-rw-r--r--icetray/icetray/staticSqlSource.h17
-rw-r--r--icetray/icetray/stream_support.h13
-rw-r--r--icetray/icetray/string_view_support.h25
-rw-r--r--icetray/tool/icetrayDoc.cpp11
-rw-r--r--icetray/tool/icetraySql.cpp29
-rw-r--r--icetray/unittests/testDefaultPool.cpp11
-rw-r--r--icetray/unittests/testIceBoxInterface.cpp5
-rw-r--r--icetray/unittests/testIceTray.cpp44
-rw-r--r--icetray/unittests/testIceTrayLogger.cpp155
-rw-r--r--icetray/unittests/testIceTrayMail.cpp144
-rw-r--r--icetray/unittests/testIceTrayOptions.cpp23
-rw-r--r--icetray/unittests/testIceTrayReplace.cpp46
-rw-r--r--icetray/unittests/testIceTrayServiceI.cpp44
-rw-r--r--icetray/unittests/testIceTrayServiceI.h28
-rw-r--r--icetray/unittests/testOptions.cpp27
-rw-r--r--icetray/unittests/testOptions.h13
-rw-r--r--icetray/unittests/testService.cpp4
-rw-r--r--icetray/unittests/testService.h6
49 files changed, 774 insertions, 857 deletions
diff --git a/icetray/dryice/dryice.cpp b/icetray/dryice/dryice.cpp
index 90ec225..28c7893 100644
--- a/icetray/dryice/dryice.cpp
+++ b/icetray/dryice/dryice.cpp
@@ -1,8 +1,8 @@
#include "dryice.h"
-#include <boost/assert.hpp>
-#include <factory.h>
#include <Ice/Initialize.h>
#include <Ice/ObjectAdapter.h>
+#include <boost/assert.hpp>
+#include <factory.h>
namespace IceTray {
DryIce * DryIce::currentDryIce = nullptr;
@@ -45,8 +45,7 @@ namespace IceTray {
s->adp->add(replacement, id);
}
- DryIceClient::DryIceClient() :
- adapter(DryIce::currentDryIce->ic->createObjectAdapter("DryIceClient"))
+ DryIceClient::DryIceClient() : adapter(DryIce::currentDryIce->ic->createObjectAdapter("DryIceClient"))
{
adapter->activate();
}
@@ -73,4 +72,3 @@ namespace IceTray {
return adapter;
}
}
-
diff --git a/icetray/dryice/dryice.h b/icetray/dryice/dryice.h
index cf26281..fb3a310 100644
--- a/icetray/dryice/dryice.h
+++ b/icetray/dryice/dryice.h
@@ -1,58 +1,58 @@
#ifndef ICETRAY_TESTSETUP_H
#define ICETRAY_TESTSETUP_H
+#include "icecube.h"
+#include "icetrayService.h"
#include <Ice/Communicator.h>
#include <IceBox/IceBox.h>
#include <visibility.h>
-#include "icetrayService.h"
-#include "icecube.h"
namespace IceTray {
class DLL_PUBLIC DryIce : private Cube {
- public:
- DryIce(const Ice::StringSeq & = Ice::StringSeq());
- DryIce(const DryIce &) = delete;
- virtual ~DryIce();
-
- void operator=(const DryIce &) = delete;
- std::string getEndpoint() const;
-
- protected:
- friend class DryIceClient;
- static DryIce * currentDryIce;
-
- void replace(const std::string &, const Ice::ObjectPtr &);
-
- template<typename T, typename I, typename ... Args>
- static auto replace(Args && ... args)
- {
- pm()->remove<CubePlugIn>(typeid(T).name());
- return add<T, I>(std::forward<Args>(args)...);
- }
-
-
- Ice::CommunicatorPtr ic;
- IceTray::ServicePtr s;
+ public:
+ DryIce(const Ice::StringSeq & = Ice::StringSeq());
+ DryIce(const DryIce &) = delete;
+ virtual ~DryIce();
+
+ void operator=(const DryIce &) = delete;
+ std::string getEndpoint() const;
+
+ protected:
+ friend class DryIceClient;
+ static DryIce * currentDryIce;
+
+ void replace(const std::string &, const Ice::ObjectPtr &);
+
+ template<typename T, typename I, typename... Args>
+ static auto
+ replace(Args &&... args)
+ {
+ pm()->remove<CubePlugIn>(typeid(T).name());
+ return add<T, I>(std::forward<Args>(args)...);
+ }
+
+ Ice::CommunicatorPtr ic;
+ IceTray::ServicePtr s;
};
class DLL_PUBLIC DryIceClient {
- public:
- DryIceClient();
- virtual ~DryIceClient();
-
- template<typename Prx>
- std::shared_ptr<Prx> getProxy(const std::string & objectName) const
- {
- return Ice::checkedCast<Prx>(DryIce::currentDryIce->ic->stringToProxy(objectName));
- }
-
- ServicePtr getService() const;
- Ice::ObjectAdapterPtr getAdapter() const;
-
- private:
- Ice::ObjectAdapterPtr adapter;
+ public:
+ DryIceClient();
+ virtual ~DryIceClient();
+
+ template<typename Prx>
+ std::shared_ptr<Prx>
+ getProxy(const std::string & objectName) const
+ {
+ return Ice::checkedCast<Prx>(DryIce::currentDryIce->ic->stringToProxy(objectName));
+ }
+
+ ServicePtr getService() const;
+ Ice::ObjectAdapterPtr getAdapter() const;
+
+ private:
+ Ice::ObjectAdapterPtr adapter;
};
}
#endif
-
diff --git a/icetray/dryice/mockMailServer.cpp b/icetray/dryice/mockMailServer.cpp
index e93befb..d4e2128 100644
--- a/icetray/dryice/mockMailServer.cpp
+++ b/icetray/dryice/mockMailServer.cpp
@@ -1,7 +1,8 @@
#include "mockMailServer.h"
namespace IceTray::Mail {
- void MockMailServerImpl::sendEmail(const EmailPtr & e)
+ void
+ MockMailServerImpl::sendEmail(const EmailPtr & e)
{
sentEmails.push_back(e);
}
@@ -12,4 +13,3 @@ namespace IceTray::Mail {
return sentEmails;
}
}
-
diff --git a/icetray/dryice/mockMailServer.h b/icetray/dryice/mockMailServer.h
index 76906b9..3061d9c 100644
--- a/icetray/dryice/mockMailServer.h
+++ b/icetray/dryice/mockMailServer.h
@@ -1,21 +1,20 @@
#ifndef ICETRAY_MOCKMAILSERVER_H
#define ICETRAY_MOCKMAILSERVER_H
-#include <mockMail.h>
#include <mailServer.h>
+#include <mockMail.h>
namespace IceTray {
namespace Mail {
class DLL_PUBLIC MockMailServerImpl : public MockMailServer, BasicMailServer {
- public:
- void sendEmail(const EmailPtr & msg) override;
- Emails getSentEmails() override;
+ public:
+ void sendEmail(const EmailPtr & msg) override;
+ Emails getSentEmails() override;
- private:
- Emails sentEmails;
+ private:
+ Emails sentEmails;
};
}
}
#endif
-
diff --git a/icetray/dryice/mockPool.cpp b/icetray/dryice/mockPool.cpp
index 2a477aa..a244953 100644
--- a/icetray/dryice/mockPool.cpp
+++ b/icetray/dryice/mockPool.cpp
@@ -4,23 +4,21 @@
namespace IceTray {
MockPool::MockPool(const std::string & name, const std::string &, const Ice::PropertiesPtr & p) :
- MockPool(name,
- p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10),
- p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2))
+ MockPool(name, p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10),
+ p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2))
{
}
MockPool::MockPool(std::string name, int size, int keep) :
- DB::BasicConnectionPool(size, keep),
- name(std::move(name))
+ DB::BasicConnectionPool(size, keep), name(std::move(name))
{
}
- DB::ConnectionPtr MockPool::createResource() const
+ DB::ConnectionPtr
+ MockPool::createResource() const
{
return DB::MockDatabase::openConnectionTo(name);
}
FACTORY(MockPool, PoolProvider);
};
-
diff --git a/icetray/dryice/mockPool.h b/icetray/dryice/mockPool.h
index f77d449..4a4e70a 100644
--- a/icetray/dryice/mockPool.h
+++ b/icetray/dryice/mockPool.h
@@ -1,21 +1,20 @@
#ifndef ICETRAY_MOCKPOOL_H
#define ICETRAY_MOCKPOOL_H
+#include <Ice/Properties.h>
#include <connectionPool.h>
#include <mockDatabase.h>
-#include <Ice/Properties.h>
namespace IceTray {
class DLL_PUBLIC MockPool : public DB::BasicConnectionPool {
- public:
- MockPool(const std::string & name, const std::string &, const Ice::PropertiesPtr & p);
- MockPool(std::string name, int size, int keep);
+ public:
+ MockPool(const std::string & name, const std::string &, const Ice::PropertiesPtr & p);
+ MockPool(std::string name, int size, int keep);
- DB::ConnectionPtr createResource() const override;
+ DB::ConnectionPtr createResource() const override;
- const std::string name;
+ const std::string name;
};
}
#endif
-
diff --git a/icetray/icetray/abstractCachingDatabaseClient.cpp b/icetray/icetray/abstractCachingDatabaseClient.cpp
index 7934596..e3c293c 100644
--- a/icetray/icetray/abstractCachingDatabaseClient.cpp
+++ b/icetray/icetray/abstractCachingDatabaseClient.cpp
@@ -1,8 +1,13 @@
#include "abstractCachingDatabaseClient.h"
#include <cache.impl.h>
-template DLL_PUBLIC void AdHoc::Cache<IceTray::AbstractCachingDatabaseClient::CacheItem, IceTray::AbstractCachingDatabaseClient::CacheKey>::add(const IceTray::AbstractCachingDatabaseClient::CacheKey &, const IceTray::AbstractCachingDatabaseClient::CacheItem &, time_t);
-template DLL_PUBLIC IceTray::AbstractCachingDatabaseClient::Cache::Value AdHoc::Cache<IceTray::AbstractCachingDatabaseClient::CacheItem, IceTray::AbstractCachingDatabaseClient::CacheKey>::get(const IceTray::AbstractCachingDatabaseClient::CacheKey &) const;
+template DLL_PUBLIC void
+AdHoc::Cache<IceTray::AbstractCachingDatabaseClient::CacheItem, IceTray::AbstractCachingDatabaseClient::CacheKey>::add(
+ const IceTray::AbstractCachingDatabaseClient::CacheKey &,
+ const IceTray::AbstractCachingDatabaseClient::CacheItem &, time_t);
+template DLL_PUBLIC IceTray::AbstractCachingDatabaseClient::Cache::Value
+AdHoc::Cache<IceTray::AbstractCachingDatabaseClient::CacheItem, IceTray::AbstractCachingDatabaseClient::CacheKey>::get(
+ const IceTray::AbstractCachingDatabaseClient::CacheKey &) const;
namespace IceTray {
AbstractCachingDatabaseClient::AbstractCachingDatabaseClient(const DB::ConnectionPoolPtr & d) :
@@ -15,4 +20,3 @@ namespace IceTray {
{
}
}
-
diff --git a/icetray/icetray/abstractCachingDatabaseClient.h b/icetray/icetray/abstractCachingDatabaseClient.h
index d20a980..78205b8 100644
--- a/icetray/icetray/abstractCachingDatabaseClient.h
+++ b/icetray/icetray/abstractCachingDatabaseClient.h
@@ -2,51 +2,49 @@
#define ICETRAY_ABSTRACTCACHINGDATABASECLIENT_H
#include "abstractDatabaseClient.h"
-#include <cache.h>
#include <any>
+#include <cache.h>
#include <memory>
namespace IceTray {
class DLL_PUBLIC AbstractCachingDatabaseClient : public AbstractDatabaseClient {
- private:
- typedef std::vector<std::size_t> CacheKey;
- typedef std::any CacheItem;
-
- protected:
- AbstractCachingDatabaseClient(const DB::ConnectionPoolPtr & d);
-
- template<typename Domain, typename ... Params>
- inline
- Domain
- fetchCache(const SqlSource & sql, time_t cacheTime, const Params & ... params)
- {
- CacheKey key;
- key.reserve(sizeof...(Params) + 2);
- key.push_back(*sql.getCommandOptions()->hash);
- key.push_back(typeid(Domain).hash_code());
- keyPushParams(key, params...);
- if (auto cached = cache.get(key)) {
- return std::any_cast<Domain>(*cached);
- }
- auto d(fetch<Domain, Params...>(sql, params...));
- cache.add(key, CacheItem(d), time(NULL) + cacheTime);
- return d;
- }
-
- private:
- template<typename Param, typename ... Params>
- static void inline keyPushParams(CacheKey & k, const Param & p, const Params & ... params)
- {
- k.push_back(std::hash<Param>()(p));
- keyPushParams(k, params...);
+ private:
+ typedef std::vector<std::size_t> CacheKey;
+ typedef std::any CacheItem;
+
+ protected:
+ AbstractCachingDatabaseClient(const DB::ConnectionPoolPtr & d);
+
+ template<typename Domain, typename... Params>
+ inline Domain
+ fetchCache(const SqlSource & sql, time_t cacheTime, const Params &... params)
+ {
+ CacheKey key;
+ key.reserve(sizeof...(Params) + 2);
+ key.push_back(*sql.getCommandOptions()->hash);
+ key.push_back(typeid(Domain).hash_code());
+ keyPushParams(key, params...);
+ if (auto cached = cache.get(key)) {
+ return std::any_cast<Domain>(*cached);
}
-
- static void keyPushParams(CacheKey &);
-
- typedef AdHoc::Cache<CacheItem, CacheKey> Cache;
- Cache cache;
+ auto d(fetch<Domain, Params...>(sql, params...));
+ cache.add(key, CacheItem(d), time(NULL) + cacheTime);
+ return d;
+ }
+
+ private:
+ template<typename Param, typename... Params>
+ static void inline keyPushParams(CacheKey & k, const Param & p, const Params &... params)
+ {
+ k.push_back(std::hash<Param>()(p));
+ keyPushParams(k, params...);
+ }
+
+ static void keyPushParams(CacheKey &);
+
+ typedef AdHoc::Cache<CacheItem, CacheKey> Cache;
+ Cache cache;
};
}
#endif
-
diff --git a/icetray/icetray/abstractDatabaseClient.cpp b/icetray/icetray/abstractDatabaseClient.cpp
index 1c4f566..e84e958 100644
--- a/icetray/icetray/abstractDatabaseClient.cpp
+++ b/icetray/icetray/abstractDatabaseClient.cpp
@@ -3,17 +3,14 @@
#include "IceUtil/Optional.h"
namespace IceTray {
- AbstractDatabaseClient::AbstractDatabaseClient(DB::ConnectionPoolPtr d) :
- db(std::move(d))
- {
- }
+ AbstractDatabaseClient::AbstractDatabaseClient(DB::ConnectionPoolPtr d) : db(std::move(d)) { }
}
namespace DB {
template<>
- void Command::bindParam(unsigned int offset, const Ice::ByteSeq & p)
+ void
+ Command::bindParam(unsigned int offset, const Ice::ByteSeq & p)
{
this->bindParamBLOB(offset, p);
}
}
-
diff --git a/icetray/icetray/abstractDatabaseClient.h b/icetray/icetray/abstractDatabaseClient.h
index 311805c..4dc611f 100644
--- a/icetray/icetray/abstractDatabaseClient.h
+++ b/icetray/icetray/abstractDatabaseClient.h
@@ -1,70 +1,65 @@
#ifndef ICETRAY_ABSTRACTDATABASECLIENT_H
#define ICETRAY_ABSTRACTDATABASECLIENT_H
-#include <connectionPool.h>
#include "sqlSource.h"
+#include <Ice/BuiltinSequences.h>
+#include <connectionPool.h>
#include <db/sqlSelectDeserializer.h>
#include <slicer/slicer.h>
#include <visibility.h>
-#include <Ice/BuiltinSequences.h>
namespace IceTray {
class DLL_PUBLIC AbstractDatabaseClient {
- protected:
- AbstractDatabaseClient(DB::ConnectionPoolPtr d);
+ protected:
+ AbstractDatabaseClient(DB::ConnectionPoolPtr d);
- template<typename Domain, typename ... Params>
- inline
- Domain
- fetch(const SqlSource & sql, const Params & ... params)
- {
- return fetch<Domain, Params...>(IceUtil::None, sql, params...);
- }
+ template<typename Domain, typename... Params>
+ inline Domain
+ fetch(const SqlSource & sql, const Params &... params)
+ {
+ return fetch<Domain, Params...>(IceUtil::None, sql, params...);
+ }
- template<typename Domain, typename ... Params>
- inline
- Domain
- fetch(DB::Connection * c, const SqlSource & sql, const Params & ... params)
- {
- return fetch<Domain, Params...>(c, IceUtil::None, sql, params...);
- }
+ template<typename Domain, typename... Params>
+ inline Domain
+ fetch(DB::Connection * c, const SqlSource & sql, const Params &... params)
+ {
+ return fetch<Domain, Params...>(c, IceUtil::None, sql, params...);
+ }
- template<typename Domain, typename ... Params>
- inline
- Domain
- fetch(const IceUtil::Optional<std::string> & typeIdCol, const SqlSource & sql, const Params & ... params)
- {
- auto c = db->get();
- return fetch<Domain, Params...>(c.get(), typeIdCol, sql, params...);
- }
+ template<typename Domain, typename... Params>
+ inline Domain
+ fetch(const IceUtil::Optional<std::string> & typeIdCol, const SqlSource & sql, const Params &... params)
+ {
+ auto c = db->get();
+ return fetch<Domain, Params...>(c.get(), typeIdCol, sql, params...);
+ }
- template<typename Domain, typename ... Params>
- inline
- Domain
- fetch(DB::Connection * c, const IceUtil::Optional<std::string> & typeIdCol, const SqlSource & sql, const Params & ... params)
- {
- auto s = sql.select(c);
- bind(0, s.get(), params...);
- return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, Domain>(s.get(), typeIdCol);
- }
+ template<typename Domain, typename... Params>
+ inline Domain
+ fetch(DB::Connection * c, const IceUtil::Optional<std::string> & typeIdCol, const SqlSource & sql,
+ const Params &... params)
+ {
+ auto s = sql.select(c);
+ bind(0, s.get(), params...);
+ return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, Domain>(s.get(), typeIdCol);
+ }
- template<typename Param, typename ... Params>
- static void inline bind(unsigned int offset, DB::Command * cmd, const Param & p, const Params & ... params)
- {
- cmd->bindParam(offset, p);
- bind(offset + 1, cmd, params...);
- }
+ template<typename Param, typename... Params>
+ static void inline bind(unsigned int offset, DB::Command * cmd, const Param & p, const Params &... params)
+ {
+ cmd->bindParam(offset, p);
+ bind(offset + 1, cmd, params...);
+ }
- static void inline bind(int, DB::Command *) { }
+ static void inline bind(int, DB::Command *) { }
- const DB::ConnectionPoolPtr db;
+ const DB::ConnectionPoolPtr db;
};
}
namespace DB {
- template<>
- void Command::bindParam(unsigned int offset, const Ice::ByteSeq & p);
+ template<> void Command::bindParam(unsigned int offset, const Ice::ByteSeq & p);
}
#endif
-
diff --git a/icetray/icetray/defaultPool.cpp b/icetray/icetray/defaultPool.cpp
index 608734f..f99ed2e 100644
--- a/icetray/icetray/defaultPool.cpp
+++ b/icetray/icetray/defaultPool.cpp
@@ -3,8 +3,7 @@
namespace IceTray {
DefaultPool::DefaultPool(const std::string & name, const std::string & type, const Ice::PropertiesPtr & p) :
- DB::ConnectionPool(
- p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10),
+ DB::ConnectionPool(p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10),
p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2),
p->getPropertyWithDefault(name + ".Database.Type", type),
p->getProperty(name + ".Database.ConnectionString"))
@@ -13,4 +12,3 @@ namespace IceTray {
FACTORY(DefaultPool, PoolProvider);
}
-
diff --git a/icetray/icetray/defaultPool.h b/icetray/icetray/defaultPool.h
index 4295536..2caa71c 100644
--- a/icetray/icetray/defaultPool.h
+++ b/icetray/icetray/defaultPool.h
@@ -1,15 +1,14 @@
#ifndef ICETRAY_DEFAULTPOOL_H
#define ICETRAY_DEFAULTPOOL_H
-#include <connectionPool.h>
#include <Ice/Properties.h>
+#include <connectionPool.h>
namespace IceTray {
class DefaultPool : public DB::ConnectionPool {
- public:
- DefaultPool(const std::string & name, const std::string & type, const Ice::PropertiesPtr & p);
+ public:
+ DefaultPool(const std::string & name, const std::string & type, const Ice::PropertiesPtr & p);
};
}
#endif
-
diff --git a/icetray/icetray/icecube.cpp b/icetray/icetray/icecube.cpp
index 2908c16..e8b500c 100644
--- a/icetray/icetray/icecube.cpp
+++ b/icetray/icetray/icecube.cpp
@@ -2,4 +2,3 @@
#include <plugins.impl.h>
INSTANTIATEPLUGINOF(IceTray::CubePlugIn);
-
diff --git a/icetray/icetray/icecube.h b/icetray/icetray/icecube.h
index 13c0545..4ddc543 100644
--- a/icetray/icetray/icecube.h
+++ b/icetray/icetray/icecube.h
@@ -1,62 +1,69 @@
#ifndef ICETRAY_ICECUBE_H
#define ICETRAY_ICECUBE_H
-#include <plugins.h>
-#include <Ice/ObjectAdapter.h>
-#include <Ice/Initialize.h>
#include "icetrayService.h"
+#include <Ice/Initialize.h>
+#include <Ice/ObjectAdapter.h>
+#include <plugins.h>
namespace IceTray {
- class CubePlugIn : public AdHoc::AbstractPluginImplementation { };
+ class CubePlugIn : public AdHoc::AbstractPluginImplementation {
+ };
- template<typename I>
- class CubePlugInOf : public CubePlugIn, public I {
+ template<typename I> class CubePlugInOf : public CubePlugIn, public I {
using I::I;
};
class CubeObject : public CubePlugIn {
- public:
- explicit inline CubeObject(Ice::ObjectPrxPtr o) : obj(std::move(o)) { }
- Ice::ObjectPrxPtr obj;
+ public:
+ explicit inline CubeObject(Ice::ObjectPrxPtr o) : obj(std::move(o)) { }
+ Ice::ObjectPrxPtr obj;
};
class Cube {
- protected:
- static inline auto pm() { return &Service::getCurrent()->servicePlugins; }
-
- public:
- template<typename T, typename I, typename ... Args>
- static auto addObject(const Ice::ObjectAdapterPtr & adp, const std::string & name, Args && ... args)
- {
- static_assert(std::is_convertible<I *, T *>::value);
- static_assert(std::is_convertible<I *, Ice::Object *>::value);
- auto prx = adp->add(std::make_shared<I>(std::forward<Args>(args)...), Ice::stringToIdentity(name));
- return pm()->add<CubePlugIn>(std::make_shared<CubeObject>(prx),
- typeid(typename T::ProxyType).name(), __FILE__, __LINE__);
- }
+ protected:
+ static inline auto
+ pm()
+ {
+ return &Service::getCurrent()->servicePlugins;
+ }
- template<typename T, typename I, typename ... Args>
- static auto add(Args && ... args)
- {
- static_assert(std::is_convertible<CubePlugInOf<I> *, T *>::value);
- return pm()->add<CubePlugIn>(std::make_shared<CubePlugInOf<I>>(std::forward<Args>(args)...), typeid(T).name(), __FILE__, __LINE__);
- }
+ public:
+ template<typename T, typename I, typename... Args>
+ static auto
+ addObject(const Ice::ObjectAdapterPtr & adp, const std::string & name, Args &&... args)
+ {
+ static_assert(std::is_convertible<I *, T *>::value);
+ static_assert(std::is_convertible<I *, Ice::Object *>::value);
+ auto prx = adp->add(std::make_shared<I>(std::forward<Args>(args)...), Ice::stringToIdentity(name));
+ return pm()->add<CubePlugIn>(
+ std::make_shared<CubeObject>(prx), typeid(typename T::ProxyType).name(), __FILE__, __LINE__);
+ }
- template<typename T>
- static auto get()
- {
- if constexpr (std::is_convertible<T *, Ice::Object *>::value) {
- using Prx = typename T::ProxyType;
- auto c = pm()->getImplementation<CubePlugIn>(typeid(Prx).name());
- return Ice::uncheckedCast<Prx>(std::dynamic_pointer_cast<CubeObject>(c)->obj);
- }
- else {
- auto c = pm()->getImplementation<CubePlugIn>(typeid(T).name());
- return std::dynamic_pointer_cast<T>(c);
- }
+ template<typename T, typename I, typename... Args>
+ static auto
+ add(Args &&... args)
+ {
+ static_assert(std::is_convertible<CubePlugInOf<I> *, T *>::value);
+ return pm()->add<CubePlugIn>(std::make_shared<CubePlugInOf<I>>(std::forward<Args>(args)...),
+ typeid(T).name(), __FILE__, __LINE__);
+ }
+
+ template<typename T>
+ static auto
+ get()
+ {
+ if constexpr (std::is_convertible<T *, Ice::Object *>::value) {
+ using Prx = typename T::ProxyType;
+ auto c = pm()->getImplementation<CubePlugIn>(typeid(Prx).name());
+ return Ice::uncheckedCast<Prx>(std::dynamic_pointer_cast<CubeObject>(c)->obj);
+ }
+ else {
+ auto c = pm()->getImplementation<CubePlugIn>(typeid(T).name());
+ return std::dynamic_pointer_cast<T>(c);
}
+ }
};
}
#endif
-
diff --git a/icetray/icetray/icetrayService.cpp b/icetray/icetray/icetrayService.cpp
index b0770eb..0005be0 100644
--- a/icetray/icetray/icetrayService.cpp
+++ b/icetray/icetray/icetrayService.cpp
@@ -1,8 +1,8 @@
-#include <Ice/Ice.h>
-#include <visibility.h>
-#include <factory.impl.h>
#include "icetrayService.h"
+#include <Ice/Ice.h>
#include <boost/assert.hpp>
+#include <factory.impl.h>
+#include <visibility.h>
namespace IceTray {
Service * Service::current = nullptr;
@@ -38,7 +38,8 @@ namespace IceTray {
return serviceFactories.begin()->get()->implementation()->create();
}
- void Service::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq & args)
+ void
+ Service::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq & args)
{
adp = ic->createObjectAdapter(name);
configureLoggers(adp, ic->getProperties());
@@ -82,23 +83,20 @@ namespace IceTray {
Service::getConnectionPool(const Ice::CommunicatorPtr & ic, const std::string & type, const std::string & name)
{
auto p = ic->getProperties();
- return PoolProvider::createNew(
- p->getPropertyWithDefault("DryIce.PoolProvider", "DefaultPool"),
- name, type, p);
+ return PoolProvider::createNew(p->getPropertyWithDefault("DryIce.PoolProvider", "DefaultPool"), name, type, p);
}
}
extern "C" {
- DLL_PUBLIC
- IceBox::Service *
- // Public ICE Box API signature
- // NOLINTNEXTLINE(performance-unnecessary-value-param)
- createIceTrayService(Ice::CommunicatorPtr ic)
- {
- return IceTray::Service::create(ic);
- }
+DLL_PUBLIC
+IceBox::Service *
+// Public ICE Box API signature
+// NOLINTNEXTLINE(performance-unnecessary-value-param)
+createIceTrayService(Ice::CommunicatorPtr ic)
+{
+ return IceTray::Service::create(ic);
+}
}
INSTANTIATEPLUGINOF(IceTray::ServiceFactory);
INSTANTIATEFACTORY(DB::BasicConnectionPool, const std::string &, const std::string &, const Ice::PropertiesPtr &);
-
diff --git a/icetray/icetray/icetrayService.h b/icetray/icetray/icetrayService.h
index 6c48a71..39e2fda 100644
--- a/icetray/icetray/icetrayService.h
+++ b/icetray/icetray/icetrayService.h
@@ -1,41 +1,44 @@
#ifndef ICETRAY_SERVICE_H
#define ICETRAY_SERVICE_H
+#include "logger.h"
+#include "options.h"
#include <IceBox/IceBox.h>
+#include <connectionPool.h>
#include <factory.h>
#include <visibility.h>
-#include <connectionPool.h>
-#include "logger.h"
-#include "options.h"
namespace IceTray {
class DLL_PUBLIC Service : public IceBox::Service, public AdHoc::AbstractPluginImplementation {
- public:
- Service();
- virtual ~Service();
+ public:
+ Service();
+ virtual ~Service();
- virtual void addObjects(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &) = 0;
+ 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;
+ void start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq & args) override;
- void stop() override;
+ void stop() override;
- DB::ConnectionPoolPtr getConnectionPool(const Ice::CommunicatorPtr & ic, const std::string & type, const std::string & prefix);
+ DB::ConnectionPoolPtr getConnectionPool(
+ const Ice::CommunicatorPtr & ic, const std::string & type, const std::string & prefix);
- static Service * getCurrent();
- static Service * create(const Ice::CommunicatorPtr &);
+ static Service * getCurrent();
+ static Service * create(const Ice::CommunicatorPtr &);
- private:
- void configureLoggers(const Ice::ObjectAdapterPtr &, const Ice::PropertiesPtr &);
- void shutdownLoggers();
+ private:
+ void configureLoggers(const Ice::ObjectAdapterPtr &, const Ice::PropertiesPtr &);
+ void shutdownLoggers();
- friend class DryIce;
- friend class Cube;
- Ice::ObjectAdapterPtr adp;
- static Service * current;
- std::set<Logging::LogWriterPrxPtr> logWriters;
- OptionsCollation optionsCollation;
- AdHoc::PluginManager servicePlugins;
+ friend class DryIce;
+ friend class Cube;
+ Ice::ObjectAdapterPtr adp;
+ static Service * current;
+ std::set<Logging::LogWriterPrxPtr> logWriters;
+ OptionsCollation optionsCollation;
+ AdHoc::PluginManager servicePlugins;
};
typedef std::shared_ptr<Service> ServicePtr;
@@ -43,24 +46,24 @@ namespace IceTray {
// Custom factory required because IceBox interface requires a naked pointer.
// See: https://doc.zeroc.com/display/Ice37/Developing+IceBox+Services#DevelopingIceBoxServices-C++ServiceEntryPoint
class ServiceFactory : public AdHoc::AbstractPluginImplementation {
- public:
- virtual Service * create() const = 0;
+ public:
+ virtual Service * create() const = 0;
- template<typename Impl>
- class For;
+ template<typename Impl> class For;
};
- template<typename Impl>
- class ServiceFactory::For : public ServiceFactory {
- public:
- Service * create() const
- {
- return new Impl();
- }
+ template<typename Impl> class ServiceFactory::For : public ServiceFactory {
+ public:
+ Service *
+ create() const
+ {
+ return new Impl();
+ }
};
- typedef AdHoc::Factory<DB::BasicConnectionPool, const std::string &, const std::string &, const Ice::PropertiesPtr &> PoolProvider;
+ typedef AdHoc::Factory<DB::BasicConnectionPool, const std::string &, const std::string &,
+ const Ice::PropertiesPtr &>
+ PoolProvider;
}
#endif
-
diff --git a/icetray/icetray/logWriterConsole.cpp b/icetray/icetray/logWriterConsole.cpp
index 5894e47..65f9694 100644
--- a/icetray/icetray/logWriterConsole.cpp
+++ b/icetray/icetray/logWriterConsole.cpp
@@ -1,5 +1,5 @@
-#include <logWriter.h>
#include "logWriterConsole.h"
+#include <logWriter.h>
#include <slicer/modelPartsTypes.h>
// NOLINTNEXTLINE(modernize-concat-nested-namespaces)
@@ -13,20 +13,19 @@ namespace IceTray {
}
void
- ConsoleLogWriter::message(LogLevel priority, Domain domain, const std::string_view message, const Ice::Current &)
+ ConsoleLogWriter::message(
+ LogLevel priority, Domain domain, const std::string_view message, const Ice::Current &)
{
- writeStream(priority < LogLevel::WARNING ? std::cerr : std::cout,
- width, priority, domain, message);
+ writeStream(priority < LogLevel::WARNING ? std::cerr : std::cout, width, priority, domain, message);
(priority < LogLevel::WARNING ? std::cerr : std::cout).flush();
}
std::ostream &
- ConsoleLogWriter::writeStream(std::ostream & s, int width, LogLevel priority, const Domain & domain, const std::string_view & message)
+ ConsoleLogWriter::writeStream(
+ std::ostream & s, int width, LogLevel priority, const Domain & domain, const std::string_view & message)
{
- return LogMsg::write(s,
- Slicer::ModelPartForEnum<LogLevel>::lookup(priority), width, domain, message);
+ return LogMsg::write(s, Slicer::ModelPartForEnum<LogLevel>::lookup(priority), width, domain, message);
}
FACTORY(ConsoleLogWriter, LogWriterFactory);
}
}
-
diff --git a/icetray/icetray/logWriterConsole.h b/icetray/icetray/logWriterConsole.h
index 0136235..21189ea 100644
--- a/icetray/icetray/logWriterConsole.h
+++ b/icetray/icetray/logWriterConsole.h
@@ -6,17 +6,17 @@
namespace IceTray {
namespace Logging {
class ConsoleLogWriter : public AbstractLogWriter {
- public:
- ConsoleLogWriter(const Ice::PropertiesPtr & p);
+ public:
+ ConsoleLogWriter(const Ice::PropertiesPtr & p);
- void message(LogLevel priority, Domain domain, std::string_view message, const Ice::Current &) override;
+ void message(LogLevel priority, Domain domain, std::string_view message, const Ice::Current &) override;
- static DLL_PUBLIC std::ostream & writeStream(std::ostream &, int width, LogLevel priority, const Domain & domain, const std::string_view & message);
+ static DLL_PUBLIC std::ostream & writeStream(std::ostream &, int width, LogLevel priority,
+ const Domain & domain, const std::string_view & message);
- const int width;
+ const int width;
};
}
}
#endif
-
diff --git a/icetray/icetray/logWriterSyslog.cpp b/icetray/icetray/logWriterSyslog.cpp
index d78da5b..f47b4c5 100644
--- a/icetray/icetray/logWriterSyslog.cpp
+++ b/icetray/icetray/logWriterSyslog.cpp
@@ -1,5 +1,5 @@
-#include <logWriter.h>
#include "logWriterSyslog.h"
+#include <logWriter.h>
#include <syslog.h>
// NOLINTNEXTLINE(modernize-concat-nested-namespaces)
@@ -9,14 +9,13 @@ namespace IceTray {
SyslogLogWriter::SyslogLogWriter(const Ice::PropertiesPtr & p) :
AbstractLogWriter("logging.syslog", p),
width(p ? p->getPropertyAsIntWithDefault("logging.syslog.width", -1) : -1)
- {
- if (p) {
- openlog(
- p->getPropertyWithDefault("logging.syslog.ident", "icetray").c_str(),
- p->getPropertyAsIntWithDefault("logging.syslog.option", 0),
- p->getPropertyAsIntWithDefault("logging.syslog.facility", LOG_DAEMON));
- }
+ {
+ if (p) {
+ openlog(p->getPropertyWithDefault("logging.syslog.ident", "icetray").c_str(),
+ p->getPropertyAsIntWithDefault("logging.syslog.option", 0),
+ p->getPropertyAsIntWithDefault("logging.syslog.facility", LOG_DAEMON));
}
+ }
SyslogLogWriter::~SyslogLogWriter()
{
@@ -32,4 +31,3 @@ namespace IceTray {
FACTORY(SyslogLogWriter, LogWriterFactory);
}
}
-
diff --git a/icetray/icetray/logWriterSyslog.h b/icetray/icetray/logWriterSyslog.h
index fdce2ec..88488bd 100644
--- a/icetray/icetray/logWriterSyslog.h
+++ b/icetray/icetray/logWriterSyslog.h
@@ -6,16 +6,15 @@
namespace IceTray {
namespace Logging {
class SyslogLogWriter : public AbstractLogWriter {
- public:
- SyslogLogWriter(const Ice::PropertiesPtr & p);
- ~SyslogLogWriter();
+ public:
+ SyslogLogWriter(const Ice::PropertiesPtr & p);
+ ~SyslogLogWriter();
- void message(LogLevel priority, Domain domain, std::string_view message, const Ice::Current &) override;
+ void message(LogLevel priority, Domain domain, std::string_view message, const Ice::Current &) override;
- const int width;
+ const int width;
};
}
}
#endif
-
diff --git a/icetray/icetray/logger.cpp b/icetray/icetray/logger.cpp
index 0944947..6a54991 100644
--- a/icetray/icetray/logger.cpp
+++ b/icetray/icetray/logger.cpp
@@ -1,12 +1,12 @@
#include "logger.h"
-#include <factory.impl.h>
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/algorithm/string/split.hpp>
#include <buffer.h>
+#include <factory.impl.h>
+#include <globalStatic.impl.h>
#include <lockHelpers.h>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/algorithm/string/classification.hpp>
#include <slicer/modelPartsTypes.h>
-#include <globalStatic.impl.h>
INSTANTIATEFACTORY(IceTray::Logging::LogWriter, const Ice::PropertiesPtr &);
@@ -15,10 +15,7 @@ template class ::AdHoc::GlobalStatic<::IceTray::Logging::LogManager>;
// NOLINTNEXTLINE(modernize-concat-nested-namespaces)
namespace IceTray {
namespace Logging {
- LoggerBase::LoggerBase(Domain domain) :
- domain(std::move(domain))
- {
- }
+ LoggerBase::LoggerBase(Domain domain) : domain(std::move(domain)) { }
LoggerBase::~LoggerBase() = default;
@@ -102,9 +99,8 @@ namespace IceTray {
LoggerPtr
LogManager::getLogger(const std::type_info & type)
{
- std::unique_ptr<char, void(*)(void*)> res {
- abi::__cxa_demangle(type.name(), nullptr, nullptr, nullptr), std::free
- };
+ std::unique_ptr<char, void (*)(void *)> res {
+ abi::__cxa_demangle(type.name(), nullptr, nullptr, nullptr), std::free};
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
return getLogger(res.get());
}
@@ -170,13 +166,13 @@ namespace IceTray {
AbstractLogWriter::AbstractLogWriter(LogLevel level)
{
- logDomains.insert({ { }, level });
+ logDomains.insert({{}, level});
}
AbstractLogWriter::AbstractLogWriter(const std::string & prefix, const Ice::PropertiesPtr & p)
{
if (!p || prefix.empty()) {
- logDomains.insert({ { }, LogLevel::WARNING });
+ logDomains.insert({{}, LogLevel::WARNING});
return;
}
auto domainsPrefix = prefix + ".domains.";
@@ -184,12 +180,12 @@ namespace IceTray {
for (const auto & d : map) {
auto level = Slicer::ModelPartForEnum<LogLevel>::lookup(d.second);
auto domain = d.first.substr(domainsPrefix.length());
- logDomains.insert({ splitDomain(domain), level });
+ logDomains.insert({splitDomain(domain), level});
}
auto defaultLevel = p->getProperty(prefix + ".default");
if (!defaultLevel.empty()) {
auto level = Slicer::ModelPartForEnum<LogLevel>::lookup(defaultLevel);
- logDomains.insert({ {}, level });
+ logDomains.insert({{}, level});
}
}
@@ -225,7 +221,8 @@ namespace IceTray {
}
Ice::StringSeq domainTokens;
- boost::algorithm::split(domainTokens, domain, boost::algorithm::is_any_of(".:"), boost::algorithm::token_compress_on);
+ boost::algorithm::split(
+ domainTokens, domain, boost::algorithm::is_any_of(".:"), boost::algorithm::token_compress_on);
return domainTokens;
}
@@ -270,8 +267,7 @@ namespace IceTray {
di++;
}
}
- }
+ }
}
}
}
-
diff --git a/icetray/icetray/logger.h b/icetray/icetray/logger.h
index 2cdfcb1..2f4ba44 100644
--- a/icetray/icetray/logger.h
+++ b/icetray/icetray/logger.h
@@ -1,16 +1,16 @@
#ifndef ICETRAY_LOGGING_H
#define ICETRAY_LOGGING_H
+#include <Ice/Properties.h>
+#include <boost/format/format_fwd.hpp>
+#include <buffer.h>
+#include <compileTimeFormatter.h>
#include <factory.h>
-#include <visibility.h>
+#include <globalStatic.h>
#include <logWriter.h>
-#include <boost/format/format_fwd.hpp>
#include <map>
-#include <buffer.h>
#include <shared_mutex>
-#include <Ice/Properties.h>
-#include <globalStatic.h>
-#include <compileTimeFormatter.h>
+#include <visibility.h>
namespace IceTray {
namespace Logging {
@@ -22,92 +22,101 @@ namespace IceTray {
typedef std::set<LoggerBase *> Loggers;
class DLL_PUBLIC LoggerBase {
- public:
- LoggerBase(Domain domain);
- virtual ~LoggerBase() = 0;
+ public:
+ LoggerBase(Domain domain);
+ virtual ~LoggerBase() = 0;
- const Domain & getDomain() const;
+ const Domain & getDomain() const;
- protected:
- friend class LogManager;
- mutable std::shared_mutex _lock;
- LogLevelWriters logs;
- const Domain domain;
+ protected:
+ friend class LogManager;
+ mutable std::shared_mutex _lock;
+ LogLevelWriters logs;
+ const Domain domain;
};
class DLL_PUBLIC Logger : public LoggerBase {
- public:
- Logger(const Domain & domain);
-
- void message(LogLevel priority, const std::string & msg) const;
- void messagef(LogLevel priority, const char * msgfmt, ...) const __attribute__ ((format (printf, 3, 4)));
- template <typename fmt, typename... Args>
- void messagectf(LogLevel priority, const Args & ... args) const {
- const auto fl = firstFor(priority);
- if (fl != logs.end()) {
- message(fl, priority, fmt::get(args...));
- }
- }
- template <typename... Args>
- void messagebf(LogLevel priority, const std::string & msgfmt, const Args & ... args) const {
- const auto fl = firstFor(priority);
- if (fl != logs.end()) {
- auto fmt = AdHoc::Buffer::getFormat(msgfmt);
- messagebf(fl, priority, fmt, args...);
- }
+ public:
+ Logger(const Domain & domain);
+
+ void message(LogLevel priority, const std::string & msg) const;
+ void messagef(LogLevel priority, const char * msgfmt, ...) const __attribute__((format(printf, 3, 4)));
+ template<typename fmt, typename... Args>
+ void
+ messagectf(LogLevel priority, const Args &... args) const
+ {
+ const auto fl = firstFor(priority);
+ if (fl != logs.end()) {
+ message(fl, priority, fmt::get(args...));
}
-
- private:
- void message(LogLevelWriters::const_iterator fl, LogLevel priority, const std::string & msg) const;
- void vmessagef(LogLevelWriters::const_iterator fl, LogLevel priority, const char * msgfmt, va_list) const;
- template <typename Arg, typename... OtherArgs>
- void messagebf(LogLevelWriters::const_iterator fl, LogLevel priority, boost::format & f, const Arg & arg, const OtherArgs & ... otherargs) const {
- f % arg;
- messagebf(fl, priority, f, otherargs...);
+ }
+ template<typename... Args>
+ void
+ messagebf(LogLevel priority, const std::string & msgfmt, const Args &... args) const
+ {
+ const auto fl = firstFor(priority);
+ if (fl != logs.end()) {
+ auto fmt = AdHoc::Buffer::getFormat(msgfmt);
+ messagebf(fl, priority, fmt, args...);
}
- void messagebf(LogLevelWriters::const_iterator fl, LogLevel priority, const boost::format & f) const;
-
- LogLevelWriters::const_iterator firstFor(LogLevel priority) const;
+ }
+
+ private:
+ void message(LogLevelWriters::const_iterator fl, LogLevel priority, const std::string & msg) const;
+ void vmessagef(LogLevelWriters::const_iterator fl, LogLevel priority, const char * msgfmt, va_list) const;
+ template<typename Arg, typename... OtherArgs>
+ void
+ messagebf(LogLevelWriters::const_iterator fl, LogLevel priority, boost::format & f, const Arg & arg,
+ const OtherArgs &... otherargs) const
+ {
+ f % arg;
+ messagebf(fl, priority, f, otherargs...);
+ }
+ void messagebf(LogLevelWriters::const_iterator fl, LogLevel priority, const boost::format & f) const;
+
+ LogLevelWriters::const_iterator firstFor(LogLevel priority) const;
};
typedef std::shared_ptr<Logger> LoggerPtr;
class DLL_PUBLIC LogManager {
- public:
- template<typename T>
- LoggerPtr getLogger() {
- return getLogger(typeid(T));
- }
- LoggerPtr getLogger(const std::type_info &);
- LoggerPtr getLogger(const std::string &);
- LogLevelWriters getLogsForDomain(const Domain &) const;
- void addWriter(const LogWriterPrxPtr & writer);
- void removeWriter(const LogWriterPrxPtr & writer);
-
- static LogManager * getDefault();
-
- private:
- void updateLoggerWriters() const;
- mutable std::shared_mutex _lock;
- Loggers loggers;
- LogWriters logWriters;
+ public:
+ template<typename T>
+ LoggerPtr
+ getLogger()
+ {
+ return getLogger(typeid(T));
+ }
+ LoggerPtr getLogger(const std::type_info &);
+ LoggerPtr getLogger(const std::string &);
+ LogLevelWriters getLogsForDomain(const Domain &) const;
+ void addWriter(const LogWriterPrxPtr & writer);
+ void removeWriter(const LogWriterPrxPtr & writer);
+
+ static LogManager * getDefault();
+
+ private:
+ void updateLoggerWriters() const;
+ mutable std::shared_mutex _lock;
+ Loggers loggers;
+ LogWriters logWriters;
};
class DLL_PUBLIC AbstractLogWriter : public LogWriter {
- public:
- IceUtil::Optional<LogLevel> lowestLevel(const Ice::Current &) override;
- IceUtil::Optional<LogLevel> level(Domain, const Ice::Current &) override;
+ public:
+ IceUtil::Optional<LogLevel> lowestLevel(const Ice::Current &) override;
+ IceUtil::Optional<LogLevel> level(Domain, const Ice::Current &) override;
- protected:
- explicit AbstractLogWriter() = default;
- explicit AbstractLogWriter(LogLevel level);
- explicit AbstractLogWriter(const std::string & prefix, const Ice::PropertiesPtr & p);
+ protected:
+ explicit AbstractLogWriter() = default;
+ explicit AbstractLogWriter(LogLevel level);
+ explicit AbstractLogWriter(const std::string & prefix, const Ice::PropertiesPtr & p);
- typedef std::map<Domain, LogLevel> LogDomains;
- LogDomains logDomains;
+ typedef std::map<Domain, LogLevel> LogDomains;
+ LogDomains logDomains;
- public:
- static Domain splitDomain(const std::string &);
- static void writeDomain(std::ostream &, ssize_t, const Domain &);
+ public:
+ static Domain splitDomain(const std::string &);
+ static void writeDomain(std::ostream &, ssize_t, const Domain &);
};
typedef AdHoc::Factory<LogWriter, const Ice::PropertiesPtr &> LogWriterFactory;
@@ -120,8 +129,9 @@ namespace LOG = ::IceTray::Logging;
namespace AdHoc {
StreamWriterT('D') {
- template<typename ... Pn>
- static void write(stream & s, ssize_t width, const IceTray::Logging::Domain & domain, const Pn & ... pn)
+ template<typename... Pn>
+ static void
+ write(stream & s, ssize_t width, const IceTray::Logging::Domain & domain, const Pn &... pn)
{
IceTray::Logging::AbstractLogWriter::writeDomain(s, width, domain);
StreamWriter::next(s, pn...);
@@ -130,4 +140,3 @@ namespace AdHoc {
}
#endif
-
diff --git a/icetray/icetray/mailServer.cpp b/icetray/icetray/mailServer.cpp
index 743023a..2e5b628 100644
--- a/icetray/icetray/mailServer.cpp
+++ b/icetray/icetray/mailServer.cpp
@@ -3,10 +3,7 @@
#include <memstream.h>
namespace IceTray::Mail {
- LibesmtpMailServer::LibesmtpMailServer(std::string s) :
- server(std::move(s))
- {
- }
+ LibesmtpMailServer::LibesmtpMailServer(std::string s) : server(std::move(s)) { }
void
LibesmtpMailServer::sendEmail(const EmailPtr & msg)
@@ -34,14 +31,12 @@ namespace IceTray::Mail {
BasicMailServer::writeEmailContent(const EmailPtr & msg, FILE * ms)
{
fputs("MIME-Version: 1.0\r\n", ms);
- msg->content->write({ ms }, 0);
+ msg->content->write({ms}, 0);
}
-
void
SendEmailFailed::ice_print(std::ostream & buf) const
{
buf << "Failed to send email: " << message;
}
}
-
diff --git a/icetray/icetray/mailServer.h b/icetray/icetray/mailServer.h
index 03d7ca6..e389323 100644
--- a/icetray/icetray/mailServer.h
+++ b/icetray/icetray/mailServer.h
@@ -8,21 +8,20 @@
namespace IceTray {
namespace Mail {
class DLL_PUBLIC BasicMailServer {
- public:
- static void writeEmailContent(const EmailPtr & msg, FILE * ms);
+ public:
+ static void writeEmailContent(const EmailPtr & msg, FILE * ms);
};
class DLL_PUBLIC LibesmtpMailServer : public MailServer, BasicMailServer {
- public:
- LibesmtpMailServer(std::string server);
+ public:
+ LibesmtpMailServer(std::string server);
- void sendEmail(const EmailPtr & msg) override;
+ void sendEmail(const EmailPtr & msg) override;
- private:
- const std::string server;
+ private:
+ const std::string server;
};
}
}
#endif
-
diff --git a/icetray/icetray/mimeImpl.cpp b/icetray/icetray/mimeImpl.cpp
index ce58673..ebe2292 100644
--- a/icetray/icetray/mimeImpl.cpp
+++ b/icetray/icetray/mimeImpl.cpp
@@ -3,8 +3,7 @@
namespace IceTray::Mime {
static const char * const DIVIDER = "//divider//";
- static const std::string_view mime_base64 =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ static const std::string_view mime_base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
void
PartHelper::writeHeaders(const Headers & headers, const StreamPtr & ms)
@@ -18,8 +17,7 @@ namespace IceTray::Mime {
}
TextPart::TextPart(const Headers & h, const std::string & m, std::string p) :
- BasicSinglePart(h, m),
- payload(std::move(p))
+ BasicSinglePart(h, m), payload(std::move(p))
{
}
@@ -28,8 +26,7 @@ namespace IceTray::Mime {
{
writeHeaders(headers, ms);
fputs("Content-Transfer-Encoding: quoted-printable\r\n", ms);
- fprintf(ms, "Content-Type: %s; charset=\"utf-8\"\r\n\r\n",
- mimetype.c_str());
+ fprintf(ms, "Content-Type: %s; charset=\"utf-8\"\r\n\r\n", mimetype.c_str());
quotedPrintable(payload, ms);
fputs("\r\n", ms);
}
@@ -49,8 +46,7 @@ namespace IceTray::Mime {
};
for (const auto & ch : input) {
const auto & nextCh = *(&ch + 1);
- if (ch == '\r') {
- }
+ if (ch == '\r') { }
else if (ch == '\n') {
fputs("\r\n", ms);
line = 0;
@@ -81,8 +77,7 @@ namespace IceTray::Mime {
}
BinaryViewPart::BinaryViewPart(const Headers & h, const std::string & m, const byte_range & p) :
- BasicSinglePart(h, m),
- payload(p)
+ BasicSinglePart(h, m), payload(p)
{
}
@@ -91,15 +86,13 @@ namespace IceTray::Mime {
{
writeHeaders(headers, ms);
fputs("Content-Transfer-Encoding: base64\r\n", ms);
- fprintf(ms, "Content-Type: %s\r\n\r\n",
- mimetype.c_str());
+ fprintf(ms, "Content-Type: %s\r\n\r\n", mimetype.c_str());
base64(payload, ms);
fputs("\r\n", ms);
}
void
- BinaryViewPart::base64(const std::basic_string_view<uint8_t> & input, FILE * ms,
- const size_t maxWidth)
+ BinaryViewPart::base64(const std::basic_string_view<uint8_t> & input, FILE * ms, const size_t maxWidth)
{
auto mime_encode_base64_block = [](auto & dest, const auto & src) {
if (src.length() >= 1) {
@@ -119,7 +112,7 @@ namespace IceTray::Mime {
}
}
};
-
+
size_t l = 0;
for (size_t i = 0; i < input.length(); i += 3) {
if (maxWidth > 0 && l + 4 > maxWidth) {
@@ -127,32 +120,26 @@ namespace IceTray::Mime {
l = 0;
}
- std::array<char, 4> bytes { '=', '=', '=', '=' };
+ std::array<char, 4> bytes {'=', '=', '=', '='};
mime_encode_base64_block(bytes, input.substr(i, 3));
- fwrite(bytes.data(), bytes.size(),1, ms);
+ fwrite(bytes.data(), bytes.size(), 1, ms);
l += 4;
}
fputs("\r\n", ms);
}
BinaryCopyPart::BinaryCopyPart(const Headers & h, const std::string & m, bytes v) :
- BinaryViewPart(h, m, { v.data(), v.size() }),
- payload(std::move(v))
+ BinaryViewPart(h, m, {v.data(), v.size()}), payload(std::move(v))
{
}
-
- MultiPart::MultiPart(const Headers & h, const std::string & st, const Parts & p) :
- BasicMultiPart(h, st, p)
- {
- }
+ MultiPart::MultiPart(const Headers & h, const std::string & st, const Parts & p) : BasicMultiPart(h, st, p) { }
void
MultiPart::write(const StreamPtr & ms, Ice::Int depth) const
{
writeHeaders(headers, ms);
- fprintf(ms, "Content-Type: multipart/%s; boundary=\"%s%d\"\r\n\r\n",
- subtype.c_str(), DIVIDER, depth);
+ fprintf(ms, "Content-Type: multipart/%s; boundary=\"%s%d\"\r\n\r\n", subtype.c_str(), DIVIDER, depth);
for (const auto & p : parts) {
fprintf(ms, "--%s%d\r\n", DIVIDER, depth);
p->write(ms, depth + 1);
@@ -161,4 +148,3 @@ namespace IceTray::Mime {
}
}
-
diff --git a/icetray/icetray/mimeImpl.h b/icetray/icetray/mimeImpl.h
index 760fd06..c87dea0 100644
--- a/icetray/icetray/mimeImpl.h
+++ b/icetray/icetray/mimeImpl.h
@@ -6,53 +6,50 @@
namespace IceTray::Mime {
class DLL_PUBLIC PartHelper {
- protected:
- static void writeHeaders(const Headers & headers, const StreamPtr & ms);
+ protected:
+ static void writeHeaders(const Headers & headers, const StreamPtr & ms);
};
class DLL_PUBLIC TextPart : public BasicSinglePart, PartHelper {
- public:
- TextPart(const Headers &, const std::string &, std::string);
+ public:
+ TextPart(const Headers &, const std::string &, std::string);
- void write(const StreamPtr & ms, Ice::Int depth) const override;
+ void write(const StreamPtr & ms, Ice::Int depth) const override;
- static void quotedPrintable(const std::string_view & input, FILE * ms,
- const size_t maxWidth = 74);
+ static void quotedPrintable(const std::string_view & input, FILE * ms, const size_t maxWidth = 74);
- const std::string payload;
+ const std::string payload;
};
class DLL_PUBLIC BinaryViewPart : public BasicSinglePart, PartHelper {
- public:
- using byte = uint8_t;
- using byte_range = std::basic_string_view<byte>;
+ public:
+ using byte = uint8_t;
+ using byte_range = std::basic_string_view<byte>;
- BinaryViewPart(const Headers &, const std::string &, const byte_range &);
+ BinaryViewPart(const Headers &, const std::string &, const byte_range &);
- void write(const StreamPtr & ms, Ice::Int depth) const override;
+ void write(const StreamPtr & ms, Ice::Int depth) const override;
- static void base64(const byte_range & input, FILE * ms,
- const size_t maxWidth = 76);
+ static void base64(const byte_range & input, FILE * ms, const size_t maxWidth = 76);
- const byte_range payload;
+ const byte_range payload;
};
class DLL_PUBLIC BinaryCopyPart : public BinaryViewPart {
- public:
- using bytes = std::vector<byte>;
+ public:
+ using bytes = std::vector<byte>;
- BinaryCopyPart(const Headers &, const std::string &, bytes);
+ BinaryCopyPart(const Headers &, const std::string &, bytes);
- const bytes payload;
+ const bytes payload;
};
class DLL_PUBLIC MultiPart : public BasicMultiPart, PartHelper {
- public:
- MultiPart(const Headers &, const std::string &, const Parts &);
+ public:
+ MultiPart(const Headers &, const std::string &, const Parts &);
- void write(const StreamPtr & ms, Ice::Int depth) const override;
+ void write(const StreamPtr & ms, Ice::Int depth) const override;
};
}
#endif
-
diff --git a/icetray/icetray/options.cpp b/icetray/icetray/options.cpp
index 8423707..0eb9887 100644
--- a/icetray/icetray/options.cpp
+++ b/icetray/icetray/options.cpp
@@ -7,10 +7,7 @@ INSTANTIATEPLUGINOF(IceTray::Options);
namespace po = boost::program_options;
namespace IceTray {
- Options::Options(std::string name) :
- optionsName(std::move(name))
- {
- }
+ Options::Options(std::string name) : optionsName(std::move(name)) { }
OptionsDescPtr
Options::getOptions()
@@ -53,7 +50,7 @@ namespace IceTray {
continue;
}
// If it was process as an empty list but wasn't empty, treat as the empty string.
- opt.value = { "" };
+ opt.value = {""};
}
opt.string_key = optDesc->long_name();
opt.unregistered = false;
@@ -72,4 +69,3 @@ namespace IceTray {
return s;
}
}
-
diff --git a/icetray/icetray/options.h b/icetray/icetray/options.h
index 0813735..037c4e2 100644
--- a/icetray/icetray/options.h
+++ b/icetray/icetray/options.h
@@ -1,63 +1,65 @@
#ifndef ICETRAY_OPTIONS_H
#define ICETRAY_OPTIONS_H
+#include <Ice/Properties.h>
+#include <boost/program_options.hpp>
#include <factory.h>
#include <visibility.h>
-#include <boost/program_options.hpp>
-#include <Ice/Properties.h>
namespace IceTray {
typedef std::shared_ptr<boost::program_options::options_description> OptionsDescPtr;
class DLL_PUBLIC Options : public AdHoc::AbstractPluginImplementation {
- public:
- Options(std::string name);
-
- private:
- friend class OptionsCollation;
- virtual void options(boost::program_options::options_description_easy_init && optDesc) = 0;
- OptionsDescPtr getOptions();
- const std::string optionsName;
+ public:
+ Options(std::string name);
+
+ private:
+ friend class OptionsCollation;
+ virtual void options(boost::program_options::options_description_easy_init && optDesc) = 0;
+ OptionsDescPtr getOptions();
+ const std::string optionsName;
};
typedef AdHoc::Factory<Options> OptionsFactory;
typedef AdHoc::PluginOf<Options> OptionsPlugin;
- template <typename T>
- class DLL_PUBLIC OptionsResolver {
- public:
- OptionsResolver() :
- opts(dynamic_cast<T&>(*AdHoc::PluginManager::getDefault()->get<Options>(typeid(T).name())->implementation()))
- {
- }
+ template<typename T> class DLL_PUBLIC OptionsResolver {
+ public:
+ OptionsResolver() :
+ opts(dynamic_cast<T &>(
+ *AdHoc::PluginManager::getDefault()->get<Options>(typeid(T).name())->implementation()))
+ {
+ }
- const T * operator->() const { return &opts; }
+ const T *
+ operator->() const
+ {
+ return &opts;
+ }
- private:
- const T & opts;
+ private:
+ const T & opts;
};
class DLL_PUBLIC OptionsCollation {
- public:
- OptionsCollation();
- ~OptionsCollation();
+ public:
+ OptionsCollation();
+ ~OptionsCollation();
- void apply(const Ice::PropertiesPtr & p);
- std::ostream & write(std::ostream &) const;
+ void apply(const Ice::PropertiesPtr & p);
+ std::ostream & write(std::ostream &) const;
- private:
- boost::program_options::options_description all;
+ private:
+ boost::program_options::options_description all;
};
}
-#define ICETRAY_OPTIONS_FUNC \
- options(boost::program_options::options_description_easy_init && optDesc)
+#define ICETRAY_OPTIONS_FUNC options(boost::program_options::options_description_easy_init && optDesc)
#define ICETRAY_OPTIONS_BODY(OptsDef) \
- { optDesc OptsDef ; }
-#define ICETRAY_OPTIONS_DECLARE \
- void ICETRAY_OPTIONS_FUNC;
-#define ICETRAY_OPTIONS_INLINE(OptsDef) \
- void ICETRAY_OPTIONS_FUNC ICETRAY_OPTIONS_BODY(OptsDef)
+ { \
+ optDesc OptsDef; \
+ }
+#define ICETRAY_OPTIONS_DECLARE void ICETRAY_OPTIONS_FUNC;
+#define ICETRAY_OPTIONS_INLINE(OptsDef) void ICETRAY_OPTIONS_FUNC ICETRAY_OPTIONS_BODY(OptsDef)
#define ICETRAY_OPTIONS(Class, OptsDef) \
FACTORY(Class, IceTray::OptionsFactory); \
void Class::ICETRAY_OPTIONS_FUNC ICETRAY_OPTIONS_BODY(OptsDef)
#endif
-
diff --git a/icetray/icetray/sqlSource.cpp b/icetray/icetray/sqlSource.cpp
index fee8799..7d3c619 100644
--- a/icetray/icetray/sqlSource.cpp
+++ b/icetray/icetray/sqlSource.cpp
@@ -15,4 +15,3 @@ namespace IceTray {
return db->select(getSql(), getCommandOptions());
}
}
-
diff --git a/icetray/icetray/sqlSource.h b/icetray/icetray/sqlSource.h
index 0f21dcf..5efb9e1 100644
--- a/icetray/icetray/sqlSource.h
+++ b/icetray/icetray/sqlSource.h
@@ -1,23 +1,22 @@
#ifndef ICETRAY_SQLSOURCE_H
#define ICETRAY_SQLSOURCE_H
+#include <command_fwd.h>
+#include <connection_fwd.h>
#include <string>
#include <visibility.h>
-#include <connection_fwd.h>
-#include <command_fwd.h>
namespace IceTray {
class DLL_PUBLIC SqlSource {
- public:
- virtual ~SqlSource() = default;
+ public:
+ virtual ~SqlSource() = default;
- virtual const std::string & getSql() const = 0;
- virtual DB::CommandOptionsCPtr getCommandOptions() const = 0;
+ virtual const std::string & getSql() const = 0;
+ virtual DB::CommandOptionsCPtr getCommandOptions() const = 0;
- DB::ModifyCommandPtr modify(DB::Connection * db) const;
- DB::SelectCommandPtr select(DB::Connection * db) const;
+ DB::ModifyCommandPtr modify(DB::Connection * db) const;
+ DB::SelectCommandPtr select(DB::Connection * db) const;
};
}
#endif
-
diff --git a/icetray/icetray/staticSqlSource.cpp b/icetray/icetray/staticSqlSource.cpp
index b658ff9..ab94b1e 100644
--- a/icetray/icetray/staticSqlSource.cpp
+++ b/icetray/icetray/staticSqlSource.cpp
@@ -3,16 +3,13 @@
namespace IceTray {
StaticSqlSource::StaticSqlSource(std::string s) :
- sql(std::move(s)),
- opts(new DB::CommandOptions(std::hash<std::string>()(sql)))
+ sql(std::move(s)), opts(new DB::CommandOptions(std::hash<std::string>()(sql)))
{
}
StaticSqlSource::StaticSqlSource(std::string s, const std::string & optsName, const DB::CommandOptionsMap & map) :
- sql(std::move(s)),
- opts(DB::CommandOptionsFactory::createNew(optsName, std::hash<std::string>()(sql), map))
+ sql(std::move(s)), opts(DB::CommandOptionsFactory::createNew(optsName, std::hash<std::string>()(sql), map))
{
-
}
const std::string &
@@ -27,4 +24,3 @@ namespace IceTray {
return opts;
}
}
-
diff --git a/icetray/icetray/staticSqlSource.h b/icetray/icetray/staticSqlSource.h
index 489ea2f..c598012 100644
--- a/icetray/icetray/staticSqlSource.h
+++ b/icetray/icetray/staticSqlSource.h
@@ -5,18 +5,17 @@
namespace IceTray {
class DLL_PUBLIC StaticSqlSource : public SqlSource {
- public:
- StaticSqlSource(std::string sql);
- StaticSqlSource(std::string sql, const std::string & optsName, const DB::CommandOptionsMap &);
+ public:
+ StaticSqlSource(std::string sql);
+ StaticSqlSource(std::string sql, const std::string & optsName, const DB::CommandOptionsMap &);
- const std::string & getSql() const override;
- DB::CommandOptionsCPtr getCommandOptions() const override;
+ const std::string & getSql() const override;
+ DB::CommandOptionsCPtr getCommandOptions() const override;
- protected:
- const std::string sql;
- const DB::CommandOptionsCPtr opts;
+ protected:
+ const std::string sql;
+ const DB::CommandOptionsCPtr opts;
};
}
#endif
-
diff --git a/icetray/icetray/stream_support.h b/icetray/icetray/stream_support.h
index 4e01e7d..8367588 100644
--- a/icetray/icetray/stream_support.h
+++ b/icetray/icetray/stream_support.h
@@ -4,14 +4,15 @@
#include <cstdio>
#include <memory>
-namespace IceTray
-{
+namespace IceTray {
class StreamPtr {
- public:
- operator FILE * () const { return f; }
- FILE * const f;
+ public:
+ operator FILE *() const
+ {
+ return f;
+ }
+ FILE * const f;
};
}
#endif
-
diff --git a/icetray/icetray/string_view_support.h b/icetray/icetray/string_view_support.h
index ef9fb94..71bfcae 100644
--- a/icetray/icetray/string_view_support.h
+++ b/icetray/icetray/string_view_support.h
@@ -1,32 +1,30 @@
#ifndef ICETRAY_STRING_VIEW_SUPPORT_H
#define ICETRAY_STRING_VIEW_SUPPORT_H
-#include <string_view>
#include <Ice/OutputStream.h>
#include <Ice/StreamHelpers.h>
+#include <string_view>
-namespace Ice
-{
- template<>
- struct StreamableTraits<std::string_view>
- {
+namespace Ice {
+ template<> struct StreamableTraits<std::string_view> {
static const StreamHelperCategory helper = StreamHelperCategoryBuiltin;
static const int minWireSize = 1;
static const bool fixedLength = false;
};
- template<>
- struct StreamHelper<std::string_view, StreamHelperCategoryBuiltin> {
- template<class S> static inline void
- write(S * stream, const std::string_view& v)
+ template<> struct StreamHelper<std::string_view, StreamHelperCategoryBuiltin> {
+ template<class S>
+ static inline void
+ write(S * stream, const std::string_view & v)
{
stream->write(v.data(), v.size());
}
- template<class S> static inline void
- read(S * stream, std::string_view& v)
+ template<class S>
+ static inline void
+ read(S * stream, std::string_view & v)
{
- const char* vdata = 0;
+ const char * vdata = 0;
size_t vsize = 0;
stream->read(vdata, vsize);
@@ -42,4 +40,3 @@ namespace Ice
}
#endif
-
diff --git a/icetray/tool/icetrayDoc.cpp b/icetray/tool/icetrayDoc.cpp
index 4fdda17..69495ba 100644
--- a/icetray/tool/icetrayDoc.cpp
+++ b/icetray/tool/icetrayDoc.cpp
@@ -1,7 +1,7 @@
-#include <iostream>
#include <boost/program_options.hpp>
-#include <dlfcn.h>
#include <compileTimeFormatter.h>
+#include <dlfcn.h>
+#include <iostream>
#include <options.h>
namespace po = boost::program_options;
@@ -21,10 +21,8 @@ main(int argc, char ** argv)
po::options_description opts("IceTray library documentation");
std::vector<std::string> libs;
- opts.add_options()
- ("help,h", "Show this help message")
- ("lib", po::value(&libs)->required(), "Library filename (see dlopen(3))")
- ;
+ opts.add_options()("help,h", "Show this help message")(
+ "lib", po::value(&libs)->required(), "Library filename (see dlopen(3))");
po::positional_options_description p;
p.add("lib", -1);
@@ -55,4 +53,3 @@ main(int argc, char ** argv)
return 0;
}
-
diff --git a/icetray/tool/icetraySql.cpp b/icetray/tool/icetraySql.cpp
index bc87f58..b8cd48a 100644
--- a/icetray/tool/icetraySql.cpp
+++ b/icetray/tool/icetraySql.cpp
@@ -1,11 +1,11 @@
-#include <iostream>
-#include <fstream>
-#include <boost/program_options.hpp>
-#include <filesystem>
-#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/predicate.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/program_options.hpp>
#include <compileTimeFormatter.h>
+#include <filesystem>
+#include <fstream>
+#include <iostream>
namespace po = boost::program_options;
namespace fs = std::filesystem;
@@ -41,16 +41,14 @@ main(int argc, char ** argv)
fs::path sql, cpp, h, base;
std::string sqlns, connector;
- opts.add_options()
- ("help,h", "Show this help message")
- ("sql", po::value(&sql)->required(), "Path of SQL script")
- ("cpp", po::value(&cpp)->required(), "Path of C++ file to write")
- ("h", po::value(&h)->required(), "Path of header file to write")
- // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall)
- ("basedir,d", po::value(&base)->default_value(fs::current_path()), "Base directory of SQL scripts (namespaces are created relative to here)")
- ("namespace", po::value(&sqlns), "Namespace to create SqlSource in")
- ("connector,c", po::value(&connector), "Specifiy a default connector name")
- ;
+ opts.add_options()("help,h", "Show this help message")("sql", po::value(&sql)->required(), "Path of SQL script")(
+ "cpp", po::value(&cpp)->required(), "Path of C++ file to write")(
+ "h", po::value(&h)->required(), "Path of header file to write")
+ // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall)
+ ("basedir,d", po::value(&base)->default_value(fs::current_path()),
+ "Base directory of SQL scripts (namespaces are created relative to here)")(
+ "namespace", po::value(&sqlns), "Namespace to create SqlSource in")(
+ "connector,c", po::value(&connector), "Specifiy a default connector name");
po::positional_options_description p;
p.add("sql", 1);
@@ -121,4 +119,3 @@ main(int argc, char ** argv)
return 0;
}
-
diff --git a/icetray/unittests/testDefaultPool.cpp b/icetray/unittests/testDefaultPool.cpp
index d7dd28c..4b9f7a7 100644
--- a/icetray/unittests/testDefaultPool.cpp
+++ b/icetray/unittests/testDefaultPool.cpp
@@ -1,15 +1,15 @@
#define BOOST_TEST_MODULE TestIceTray
#include <boost/test/unit_test.hpp>
-#include <factory.h>
-#include <factory.impl.h>
+#include <Ice/Initialize.h>
+#include <Ice/Properties.h>
#include <connectionPool.h>
#include <error.h>
+#include <factory.h>
+#include <factory.impl.h>
#include <icetrayService.h>
-#include <Ice/Initialize.h>
-#include <Ice/Properties.h>
-BOOST_AUTO_TEST_CASE( defaultPool )
+BOOST_AUTO_TEST_CASE(defaultPool)
{
auto p = Ice::createProperties();
p->setProperty("testcase.Database.ConnectionString", "user=template1 user=postgres");
@@ -21,4 +21,3 @@ BOOST_AUTO_TEST_CASE( defaultPool )
c->ping();
}
}
-
diff --git a/icetray/unittests/testIceBoxInterface.cpp b/icetray/unittests/testIceBoxInterface.cpp
index ef9e2bc..a004331 100644
--- a/icetray/unittests/testIceBoxInterface.cpp
+++ b/icetray/unittests/testIceBoxInterface.cpp
@@ -4,9 +4,9 @@
#include <dlfcn.h>
#include <icetrayService.h>
-BOOST_AUTO_TEST_CASE( IceBoxInterface )
+BOOST_AUTO_TEST_CASE(IceBoxInterface)
{
- using SetupFunction = IceTray::Service *(*)(Ice::CommunicatorPtr);
+ using SetupFunction = IceTray::Service * (*)(Ice::CommunicatorPtr);
void * i = dlsym(nullptr, "createIceTrayService");
BOOST_REQUIRE(i);
@@ -17,4 +17,3 @@ BOOST_AUTO_TEST_CASE( IceBoxInterface )
BOOST_REQUIRE_EQUAL(service, IceTray::Service::getCurrent());
delete service;
}
-
diff --git a/icetray/unittests/testIceTray.cpp b/icetray/unittests/testIceTray.cpp
index 307d0d7..25e8212 100644
--- a/icetray/unittests/testIceTray.cpp
+++ b/icetray/unittests/testIceTray.cpp
@@ -1,40 +1,35 @@
#define BOOST_TEST_MODULE TestIceTray
#include <boost/test/unit_test.hpp>
-#include <dryice.h>
-#include <Ice/Communicator.h>
#include "testIceTrayServiceI.h"
+#include <Ice/Communicator.h>
+#include <dryice.h>
+#include <mockDatabase.h>
#include <staticSqlSource.h>
#include <testIceTrayServiceTestSql.sql.h>
-#include <mockDatabase.h>
-#include <pq-mock.h>
#include <definedDirs.h>
+#include <pq-mock.h>
class Service : public IceTray::DryIce, DB::PluginMock<PQ::Mock> {
- public:
- Service() :
- DB::PluginMock<PQ::Mock>("icetraydb", {
- rootDir / "testIceTrayService.sql"
- }, "user=postgres dbname=postgres")
- {
- }
+public:
+ Service() :
+ DB::PluginMock<PQ::Mock>("icetraydb", {rootDir / "testIceTrayService.sql"}, "user=postgres dbname=postgres")
+ {
+ }
};
-BOOST_GLOBAL_FIXTURE( Service );
+BOOST_GLOBAL_FIXTURE(Service);
class Client : public IceTray::DryIceClient {
- public:
- Client() :
- p(getProxy<TestIceTray::TestIceTrayServicePrx>("test"))
- {
- }
- TestIceTray::TestIceTrayServicePrxPtr p;
+public:
+ Client() : p(getProxy<TestIceTray::TestIceTrayServicePrx>("test")) { }
+ TestIceTray::TestIceTrayServicePrxPtr p;
};
-BOOST_FIXTURE_TEST_SUITE( client, Client );
+BOOST_FIXTURE_TEST_SUITE(client, Client);
-BOOST_AUTO_TEST_CASE( services )
+BOOST_AUTO_TEST_CASE(services)
{
BOOST_REQUIRE(p);
BOOST_REQUIRE(IceTray::Service::getCurrent());
@@ -43,7 +38,7 @@ BOOST_AUTO_TEST_CASE( services )
p->method2(1, "test");
}
-BOOST_AUTO_TEST_CASE( cube_services_proxy )
+BOOST_AUTO_TEST_CASE(cube_services_proxy)
{
auto prx = IceTray::Cube::get<TestIceTray::TestIceTrayService>();
BOOST_REQUIRE(prx);
@@ -52,7 +47,7 @@ BOOST_AUTO_TEST_CASE( cube_services_proxy )
prx->method2(1, "test");
}
-BOOST_AUTO_TEST_CASE( cube_services_local )
+BOOST_AUTO_TEST_CASE(cube_services_local)
{
auto ptr = IceTray::Cube::get<TestIceTray::TestCube>();
BOOST_REQUIRE(ptr);
@@ -60,7 +55,7 @@ BOOST_AUTO_TEST_CASE( cube_services_local )
ptr->method2(1, "test");
}
-BOOST_AUTO_TEST_CASE( getIceComponents )
+BOOST_AUTO_TEST_CASE(getIceComponents)
{
BOOST_REQUIRE(getService());
BOOST_REQUIRE(getAdapter());
@@ -68,10 +63,9 @@ BOOST_AUTO_TEST_CASE( getIceComponents )
BOOST_AUTO_TEST_SUITE_END();
-BOOST_AUTO_TEST_CASE( sqlModify )
+BOOST_AUTO_TEST_CASE(sqlModify)
{
auto db = DB::MockDatabase::openConnectionTo("icetraydb");
BOOST_REQUIRE(db);
BOOST_REQUIRE(TestIceTray::sql::testIceTrayServiceTestSql.modify(db.get()));
}
-
diff --git a/icetray/unittests/testIceTrayLogger.cpp b/icetray/unittests/testIceTrayLogger.cpp
index 73142a4..f667ede 100644
--- a/icetray/unittests/testIceTrayLogger.cpp
+++ b/icetray/unittests/testIceTrayLogger.cpp
@@ -1,17 +1,17 @@
#define BOOST_TEST_MODULE TestIceTrayLogger
#include <boost/test/unit_test.hpp>
-#include <logger.h>
-#include <icetrayService.h>
-#include <Ice/Initialize.h>
+#include "testService.h"
#include <Ice/Communicator.h>
+#include <Ice/Initialize.h>
#include <Ice/ObjectAdapter.h>
-#include <compileTimeFormatter.h>
#include <boost/format.hpp>
-#include <slicer/common.h>
+#include <compileTimeFormatter.h>
+#include <icetrayService.h>
#include <logWriterConsole.h>
+#include <logger.h>
+#include <slicer/common.h>
#include <slicer/modelPartsTypes.h>
-#include "testService.h"
using namespace IceTray::Logging;
@@ -22,45 +22,41 @@ struct LogEntry {
};
class TestLogWriter : public AbstractLogWriter {
- public:
- template <typename ... T>
- explicit TestLogWriter(const T & ... t) :
- AbstractLogWriter(t...)
- {
- }
+public:
+ template<typename... T> explicit TestLogWriter(const T &... t) : AbstractLogWriter(t...) { }
- explicit TestLogWriter(const Ice::PropertiesPtr & p) :
- AbstractLogWriter("TestLogWriter", p)
- {
- }
+ explicit TestLogWriter(const Ice::PropertiesPtr & p) : AbstractLogWriter("TestLogWriter", p) { }
- void message(LogLevel priority, Domain domain, const std::string_view message, const Ice::Current &) override
- {
- msgs.push_back({priority, domain, std::string(message)});
- }
+ void
+ message(LogLevel priority, Domain domain, const std::string_view message, const Ice::Current &) override
+ {
+ msgs.push_back({priority, domain, std::string(message)});
+ }
- std::vector<LogEntry> msgs;
+ std::vector<LogEntry> msgs;
};
FACTORY(TestLogWriter, LogWriterFactory);
namespace std {
ostream &
- operator<<(ostream & s, const Domain & domain) {
+ operator<<(ostream & s, const Domain & domain)
+ {
for (const auto & d : domain) {
s << "::" << d;
}
return s;
}
ostream &
- operator<<(ostream & s, const LogLevel & ll) {
+ operator<<(ostream & s, const LogLevel & ll)
+ {
s << Slicer::ModelPartForEnum<LogLevel>::lookup(ll);
return s;
}
}
class StaticLogTest {
- public:
- static IceTray::Logging::LoggerPtr staticLog;
+public:
+ static IceTray::Logging::LoggerPtr staticLog;
};
IceTray::Logging::LoggerPtr staticLog = LOGMANAGER()->getLogger<IceTray::Service>();
@@ -69,7 +65,7 @@ Domain test = {"test"};
Domain testDomain = {"test", "domain"};
Domain testDebug = {"test", "debug"};
-BOOST_AUTO_TEST_CASE( staticLogInit )
+BOOST_AUTO_TEST_CASE(staticLogInit)
{
BOOST_REQUIRE(staticLog);
Domain expected = {"IceTray", "Service"};
@@ -78,50 +74,52 @@ BOOST_AUTO_TEST_CASE( staticLogInit )
// NOLINTNEXTLINE(hicpp-special-member-functions)
class TestLogImpl {
- public:
- TestLogImpl() :
- ic(Ice::initialize()),
- adp(ic->createObjectAdapterWithEndpoints("test", "default"))
- {
- adp->activate();
- log = manager.getLogger("test.domain");
- }
+public:
+ TestLogImpl() : ic(Ice::initialize()), adp(ic->createObjectAdapterWithEndpoints("test", "default"))
+ {
+ adp->activate();
+ log = manager.getLogger("test.domain");
+ }
- ~TestLogImpl()
- {
- adp->deactivate();
- adp->destroy();
- ic->destroy();
- }
+ ~TestLogImpl()
+ {
+ adp->deactivate();
+ adp->destroy();
+ ic->destroy();
+ }
- LogWriterPrxPtr add(const LogWriterPtr & w)
- {
- return Ice::uncheckedCast<LogWriterPrx>(adp->addWithUUID(w));
- }
+ LogWriterPrxPtr
+ add(const LogWriterPtr & w)
+ {
+ return Ice::uncheckedCast<LogWriterPrx>(adp->addWithUUID(w));
+ }
- protected:
- LoggerPtr log;
- LogManager manager;
- Ice::CommunicatorPtr ic;
+protected:
+ LoggerPtr log;
+ LogManager manager;
+ Ice::CommunicatorPtr ic;
- private:
- Ice::ObjectAdapterPtr adp;
+private:
+ Ice::ObjectAdapterPtr adp;
};
BOOST_FIXTURE_TEST_SUITE(li, TestLogImpl);
-BOOST_AUTO_TEST_CASE(no_writers) {
+BOOST_AUTO_TEST_CASE(no_writers)
+{
log->message(LogLevel::EMERG, "");
log->message(LogLevel::DEBUG, "");
}
-BOOST_AUTO_TEST_CASE(ostreamDomain) {
+BOOST_AUTO_TEST_CASE(ostreamDomain)
+{
std::stringstream str;
str << testDomain;
BOOST_REQUIRE_EQUAL("::test::domain", str.str());
}
-BOOST_AUTO_TEST_CASE(priority_filtering) {
+BOOST_AUTO_TEST_CASE(priority_filtering)
+{
auto w = std::make_shared<TestLogWriter>(LogLevel::WARNING);
auto e = std::make_shared<TestLogWriter>(LogLevel::ERR);
auto wp = add(w);
@@ -169,7 +167,7 @@ BOOST_AUTO_TEST_CASE(priority_filtering) {
BOOST_REQUIRE_EQUAL(5, e->msgs.size());
}
-BOOST_AUTO_TEST_CASE( no_domains )
+BOOST_AUTO_TEST_CASE(no_domains)
{
auto d = std::make_shared<TestLogWriter>();
manager.addWriter(add(d));
@@ -219,7 +217,7 @@ BOOST_AUTO_TEST_CASE(formatter_adhoc_compiletime)
BOOST_REQUIRE_EQUAL(testDomain, d->msgs.front().domain);
}
-BOOST_AUTO_TEST_CASE( domains_none )
+BOOST_AUTO_TEST_CASE(domains_none)
{
// No domains
auto l = add(std::make_shared<TestLogWriter>());
@@ -228,7 +226,7 @@ BOOST_AUTO_TEST_CASE( domains_none )
BOOST_REQUIRE(!l->lowestLevel());
}
-BOOST_AUTO_TEST_CASE( domains_single )
+BOOST_AUTO_TEST_CASE(domains_single)
{
// A single catch-all domain at the given level
auto l = add(std::make_shared<TestLogWriter>(LogLevel::ERR));
@@ -238,7 +236,7 @@ BOOST_AUTO_TEST_CASE( domains_single )
BOOST_REQUIRE_EQUAL(LogLevel::ERR, *l->lowestLevel());
}
-BOOST_AUTO_TEST_CASE( domains_fromNullProperties )
+BOOST_AUTO_TEST_CASE(domains_fromNullProperties)
{
// A single catch-all domain at the default level (WARNING)
auto l = add(std::make_shared<TestLogWriter>("", Ice::PropertiesPtr()));
@@ -248,7 +246,7 @@ BOOST_AUTO_TEST_CASE( domains_fromNullProperties )
BOOST_REQUIRE_EQUAL(LogLevel::WARNING, *l->lowestLevel());
}
-BOOST_AUTO_TEST_CASE( domains_fromProperties )
+BOOST_AUTO_TEST_CASE(domains_fromProperties)
{
// Domains configured according to properties
Ice::PropertiesPtr p = ic->getProperties();
@@ -265,7 +263,7 @@ BOOST_AUTO_TEST_CASE( domains_fromProperties )
BOOST_REQUIRE_EQUAL(LogLevel::DEBUG, *l->lowestLevel());
}
-BOOST_AUTO_TEST_CASE( domains_fromProperties_noDefault )
+BOOST_AUTO_TEST_CASE(domains_fromProperties_noDefault)
{
// Domains configured according to properties
Ice::PropertiesPtr p = ic->getProperties();
@@ -278,7 +276,7 @@ BOOST_AUTO_TEST_CASE( domains_fromProperties_noDefault )
BOOST_REQUIRE_EQUAL(LogLevel::DEBUG, *l->lowestLevel());
}
-BOOST_AUTO_TEST_CASE( domains_fromProperties_onlyDefault )
+BOOST_AUTO_TEST_CASE(domains_fromProperties_onlyDefault)
{
// Domains configured according to properties
Ice::PropertiesPtr p = ic->getProperties();
@@ -292,20 +290,18 @@ BOOST_AUTO_TEST_CASE( domains_fromProperties_onlyDefault )
BOOST_REQUIRE_EQUAL(LogLevel::INFO, *l->lowestLevel());
}
-BOOST_AUTO_TEST_CASE( domains_fromProperties_badLevel )
+BOOST_AUTO_TEST_CASE(domains_fromProperties_badLevel)
{
Ice::PropertiesPtr p = ic->getProperties();
p->setProperty("TestLogWriter.domains.test.domain", "BAD");
- BOOST_REQUIRE_THROW({
- TestLogWriter tlw("TestLogWriter", p);
- }, Slicer::InvalidEnumerationSymbol);
+ BOOST_REQUIRE_THROW({ TestLogWriter tlw("TestLogWriter", p); }, Slicer::InvalidEnumerationSymbol);
}
BOOST_AUTO_TEST_SUITE_END();
-BOOST_FIXTURE_TEST_SUITE( ts, TestService );
+BOOST_FIXTURE_TEST_SUITE(ts, TestService);
-BOOST_AUTO_TEST_CASE( getLogger )
+BOOST_AUTO_TEST_CASE(getLogger)
{
auto ic = Ice::initialize();
ic->getProperties()->setProperty("test.Endpoints", "default");
@@ -318,7 +314,7 @@ BOOST_AUTO_TEST_CASE( getLogger )
ic->destroy();
}
-BOOST_AUTO_TEST_CASE( getLoggerForType )
+BOOST_AUTO_TEST_CASE(getLoggerForType)
{
auto logger = LOGMANAGER()->getLogger<IceTray::Service>();
BOOST_REQUIRE(logger);
@@ -328,66 +324,63 @@ BOOST_AUTO_TEST_CASE( getLoggerForType )
BOOST_AUTO_TEST_SUITE_END();
-BOOST_AUTO_TEST_CASE( syslog )
+BOOST_AUTO_TEST_CASE(syslog)
{
- IceTray::Logging::LogWriterPtr lwp =
- IceTray::Logging::LogWriterFactory::createNew("SyslogLogWriter", nullptr);
+ IceTray::Logging::LogWriterPtr lwp = IceTray::Logging::LogWriterFactory::createNew("SyslogLogWriter", nullptr);
lwp->message(LogLevel::DEBUG, testDomain, "some message", {});
}
-BOOST_AUTO_TEST_CASE( console )
+BOOST_AUTO_TEST_CASE(console)
{
- IceTray::Logging::LogWriterPtr lwp =
- IceTray::Logging::LogWriterFactory::createNew("ConsoleLogWriter", nullptr);
+ IceTray::Logging::LogWriterPtr lwp = IceTray::Logging::LogWriterFactory::createNew("ConsoleLogWriter", nullptr);
lwp->message(LogLevel::DEBUG, testDomain, "some message", {});
}
-BOOST_AUTO_TEST_CASE( consoleNoWidth )
+BOOST_AUTO_TEST_CASE(consoleNoWidth)
{
std::stringstream str;
ConsoleLogWriter::writeStream(str, -1, LogLevel::DEBUG, testDomain, "message");
BOOST_REQUIRE_EQUAL("DEBUG: test.domain: message\n", str.str());
}
-BOOST_AUTO_TEST_CASE( consoleWidthJustRight )
+BOOST_AUTO_TEST_CASE(consoleWidthJustRight)
{
std::stringstream str;
ConsoleLogWriter::writeStream(str, 11, LogLevel::DEBUG, testDomain, "message");
BOOST_REQUIRE_EQUAL("DEBUG: test.domain: message\n", str.str());
}
-BOOST_AUTO_TEST_CASE( consoleWidthSmall )
+BOOST_AUTO_TEST_CASE(consoleWidthSmall)
{
std::stringstream str;
ConsoleLogWriter::writeStream(str, 10, LogLevel::DEBUG, testDomain, "message");
BOOST_REQUIRE_EQUAL("DEBUG: t.domain: message\n", str.str());
}
-BOOST_AUTO_TEST_CASE( consoleWidthTiny )
+BOOST_AUTO_TEST_CASE(consoleWidthTiny)
{
std::stringstream str;
ConsoleLogWriter::writeStream(str, 8, LogLevel::DEBUG, testDomain, "message");
BOOST_REQUIRE_EQUAL("DEBUG: t.domain: message\n", str.str());
}
-BOOST_AUTO_TEST_CASE( consoleWidthTooTiny )
+BOOST_AUTO_TEST_CASE(consoleWidthTooTiny)
{
std::stringstream str;
ConsoleLogWriter::writeStream(str, 7, LogLevel::DEBUG, testDomain, "message");
BOOST_REQUIRE_EQUAL("DEBUG: t.d: message\n", str.str());
}
-BOOST_AUTO_TEST_CASE( consoleWidthOverflow )
+BOOST_AUTO_TEST_CASE(consoleWidthOverflow)
{
std::stringstream str;
ConsoleLogWriter::writeStream(str, 1, LogLevel::DEBUG, testDomain, "message");
BOOST_REQUIRE_EQUAL("DEBUG: t.d: message\n", str.str());
}
-BOOST_AUTO_TEST_CASE( consoleNoDomain )
+BOOST_AUTO_TEST_CASE(consoleNoDomain)
{
std::stringstream str;
ConsoleLogWriter::writeStream(str, 0, LogLevel::DEBUG, {}, "message");
BOOST_REQUIRE_EQUAL("DEBUG: : message\n", str.str());
}
-
diff --git a/icetray/unittests/testIceTrayMail.cpp b/icetray/unittests/testIceTrayMail.cpp
index 24f240c..aea3b66 100644
--- a/icetray/unittests/testIceTrayMail.cpp
+++ b/icetray/unittests/testIceTrayMail.cpp
@@ -1,13 +1,13 @@
#define BOOST_TEST_MODULE TestIceTrayMail
-#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
+#include <boost/test/unit_test.hpp>
-#include <memstream.h>
+#include <definedDirs.h>
+#include <fileUtils.h>
#include <mailServer.h>
-#include <mockMailServer.h>
+#include <memstream.h>
#include <mimeImpl.h>
-#include <fileUtils.h>
-#include <definedDirs.h>
+#include <mockMailServer.h>
using namespace std::string_literals;
using namespace IceTray::Mime;
@@ -15,42 +15,43 @@ using namespace IceTray::Mail;
using QPTD = std::tuple<std::string_view, std::string_view>;
using B64TD = std::tuple<size_t, std::string_view>;
-BOOST_DATA_TEST_CASE(quotedPrintable, boost::unit_test::data::make<QPTD>({
- { "", "" },
- { "Simple string", "Simple string" },
- { " \t Leading whitespace", " \t Leading whitespace" },
- { "Trailing whitespace \t \n", "Trailing whitespace \t=20\r\n" },
- { "High byte values £ © ±", "High byte values =C2=A3 =\r\n=C2=A9 =C2=B1" },
- { "<html lang=\"en\">", "<html lang=3D\"en\">" }
-}), input, expected)
+BOOST_DATA_TEST_CASE(quotedPrintable,
+ boost::unit_test::data::make<QPTD>(
+ {{"", ""}, {"Simple string", "Simple string"}, {" \t Leading whitespace", " \t Leading whitespace"},
+ {"Trailing whitespace \t \n", "Trailing whitespace \t=20\r\n"},
+ {"High byte values £ © ±", "High byte values =C2=A3 =\r\n=C2=A9 =C2=B1"},
+ {"<html lang=\"en\">", "<html lang=3D\"en\">"}}),
+ input, expected)
{
AdHoc::MemStream ms;
TextPart::quotedPrintable(input, ms, 25);
BOOST_CHECK_EQUAL(expected, ms.sv());
}
-BOOST_DATA_TEST_CASE(base64, boost::unit_test::data::make<B64TD>({
- { 0, "\r\n" },
- { 1, "iQ==\r\n" },
- { 2, "iVA=\r\n" },
- { 3, "iVBO\r\n" },
- { 4, "iVBORw==\r\n" },
- { 5, "iVBORw0=\r\n" },
- { 90,
- "iVBORw0KGgoAAAANSUhEUgAA\r\n"
- "AAsAAAALCAYAAACprHcmAAAA\r\n"
- "BmJLR0QA/wD/AP+gvaeTAAAA\r\n"
- "J0lEQVQYlWP8////fwbiwGom\r\n"
- "IhUyMDAwMIwqpo9iFgYGhtVE\r\n" },
- { 113,
- "iVBORw0KGgoAAAANSUhEUgAA\r\n"
- "AAsAAAALCAYAAACprHcmAAAA\r\n"
- "BmJLR0QA/wD/AP+gvaeTAAAA\r\n"
- "J0lEQVQYlWP8////fwbiwGom\r\n"
- "IhUyMDAwMIwqpo9iFgYGhtVE\r\n"
- "qj0BAAvPBjJ63HJVAAAAAElF\r\n"
- "TkSuQmA=\r\n" },
-}), input, expected)
+BOOST_DATA_TEST_CASE(base64,
+ boost::unit_test::data::make<B64TD>({
+ {0, "\r\n"},
+ {1, "iQ==\r\n"},
+ {2, "iVA=\r\n"},
+ {3, "iVBO\r\n"},
+ {4, "iVBORw==\r\n"},
+ {5, "iVBORw0=\r\n"},
+ {90,
+ "iVBORw0KGgoAAAANSUhEUgAA\r\n"
+ "AAsAAAALCAYAAACprHcmAAAA\r\n"
+ "BmJLR0QA/wD/AP+gvaeTAAAA\r\n"
+ "J0lEQVQYlWP8////fwbiwGom\r\n"
+ "IhUyMDAwMIwqpo9iFgYGhtVE\r\n"},
+ {113,
+ "iVBORw0KGgoAAAANSUhEUgAA\r\n"
+ "AAsAAAALCAYAAACprHcmAAAA\r\n"
+ "BmJLR0QA/wD/AP+gvaeTAAAA\r\n"
+ "J0lEQVQYlWP8////fwbiwGom\r\n"
+ "IhUyMDAwMIwqpo9iFgYGhtVE\r\n"
+ "qj0BAAvPBjJ63HJVAAAAAElF\r\n"
+ "TkSuQmA=\r\n"},
+ }),
+ input, expected)
{
AdHoc::MemStream ms;
AdHoc::FileUtils::MemMap png(rootDir / "fixtures" / "mail" / "blank.png");
@@ -97,33 +98,26 @@ struct TestBase {
const std::string text_content = "Simple text £\r\n";
const std::string html_content = "<html lang=\"en\">\r\n"
-"<head>\r\n"
-"<title>£</title>\r\n"
-"</head>\r\n"
-"<html>\r\n";
+ "<head>\r\n"
+ "<title>£</title>\r\n"
+ "</head>\r\n"
+ "<html>\r\n";
BOOST_FIXTURE_TEST_SUITE(base, TestBase);
BOOST_AUTO_TEST_CASE(single_part)
{
- e->content = std::make_shared<TextPart>(Headers {
- { "X-Source", "single_part" }
- }, "text/plain", text_content);
+ e->content = std::make_shared<TextPart>(Headers {{"X-Source", "single_part"}}, "text/plain", text_content);
BasicMailServer::writeEmailContent(e, ms);
BOOST_CHECK_EQUAL(ms, AdHoc::FileUtils::MemMap(fixtures / "simple.eml").sv());
}
BOOST_AUTO_TEST_CASE(multipart_alt)
{
- auto text = std::make_shared<TextPart>(Headers {
- { "X-Source", "multipart_plain" }
- }, "text/plain", text_content);
- auto html = std::make_shared<TextPart>(Headers {
- { "X-Source", "multipart_html" }
- }, "text/html", html_content);
- e->content = std::make_shared<MultiPart>(Headers {
- { "X-Source", "multipart_top" }
- }, "alternative", Parts { text, html });
+ auto text = std::make_shared<TextPart>(Headers {{"X-Source", "multipart_plain"}}, "text/plain", text_content);
+ auto html = std::make_shared<TextPart>(Headers {{"X-Source", "multipart_html"}}, "text/html", html_content);
+ e->content
+ = std::make_shared<MultiPart>(Headers {{"X-Source", "multipart_top"}}, "alternative", Parts {text, html});
BasicMailServer::writeEmailContent(e, ms);
BOOST_CHECK_EQUAL(ms, AdHoc::FileUtils::MemMap(fixtures / "multipart-alt.eml").sv());
}
@@ -131,33 +125,23 @@ BOOST_AUTO_TEST_CASE(multipart_alt)
BOOST_AUTO_TEST_CASE(multipart_alt_imgs)
{
AdHoc::FileUtils::MemMap png(fixtures / "blank.png");
- auto text = std::make_shared<TextPart>(Headers {
- { "X-Source", "multipart_plain" }
- }, "text/plain", text_content);
- auto img1 = std::make_shared<BinaryViewPart>(Headers {
- { "X-Source", "multipart_html_img1" }
- }, "image/png", png.sv<uint8_t>());
- auto img2 = std::make_shared<BinaryCopyPart>(Headers {
- { "X-Source", "multipart_html_img2" }
- }, "image/png", std::vector<uint8_t>{ png.sv<uint8_t>().begin(), png.sv<uint8_t>().end() });
- auto html = std::make_shared<TextPart>(Headers {
- { "X-Source", "multipart_html_main" }
- }, "text/html", html_content);
- auto htmlrel = std::make_shared<MultiPart>(Headers {
- { "X-Source", "multipart_html" }
- }, "related", Parts { html, img1, img2 });
- e->content = std::make_shared<MultiPart>(Headers {
- { "X-Source", "multipart_top" }
- }, "alternative", Parts { text, htmlrel });
+ auto text = std::make_shared<TextPart>(Headers {{"X-Source", "multipart_plain"}}, "text/plain", text_content);
+ auto img1 = std::make_shared<BinaryViewPart>(
+ Headers {{"X-Source", "multipart_html_img1"}}, "image/png", png.sv<uint8_t>());
+ auto img2 = std::make_shared<BinaryCopyPart>(Headers {{"X-Source", "multipart_html_img2"}}, "image/png",
+ std::vector<uint8_t> {png.sv<uint8_t>().begin(), png.sv<uint8_t>().end()});
+ auto html = std::make_shared<TextPart>(Headers {{"X-Source", "multipart_html_main"}}, "text/html", html_content);
+ auto htmlrel = std::make_shared<MultiPart>(
+ Headers {{"X-Source", "multipart_html"}}, "related", Parts {html, img1, img2});
+ e->content = std::make_shared<MultiPart>(
+ Headers {{"X-Source", "multipart_top"}}, "alternative", Parts {text, htmlrel});
BasicMailServer::writeEmailContent(e, ms);
BOOST_CHECK_EQUAL(ms, AdHoc::FileUtils::MemMap(fixtures / "multipart-alt-imgs.eml").sv());
}
BOOST_AUTO_TEST_CASE(mock_mail_server)
{
- e->content = std::make_shared<TextPart>(Headers {
- { "X-Source", "single_part" }
- }, "text/plain", text_content);
+ e->content = std::make_shared<TextPart>(Headers {{"X-Source", "single_part"}}, "text/plain", text_content);
MockMailServerImpl mms;
mms.sendEmail(e);
auto sent = mms.getSentEmails();
@@ -168,9 +152,7 @@ BOOST_AUTO_TEST_CASE(mock_mail_server)
BOOST_AUTO_TEST_CASE(send_real_mail_fail)
{
e->subject = __PRETTY_FUNCTION__;
- e->content = std::make_shared<TextPart>(Headers {
- { "X-Source", "single_part" }
- }, "text/plain", __PRETTY_FUNCTION__);
+ e->content = std::make_shared<TextPart>(Headers {{"X-Source", "single_part"}}, "text/plain", __PRETTY_FUNCTION__);
LibesmtpMailServer ms("localhost:1");
BOOST_REQUIRE_THROW(ms.sendEmail(e), SendEmailFailed);
try {
@@ -187,18 +169,16 @@ BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE(send_real_mail
#ifndef COVERAGE
- , * boost::unit_test::disabled()
+ ,
+ *boost::unit_test::disabled()
#endif
- )
+)
{
- auto e = std::make_shared<Email>();
+ auto e = std::make_shared<Email>();
e->from = {__FUNCTION__, "dan@randomdan.homeip.net"};
e->to = {"Dan", "dan@randomdan.homeip.net"};
e->subject = __PRETTY_FUNCTION__;
- e->content = std::make_shared<TextPart>(Headers {
- { "X-Source", "single_part" }
- }, "text/plain", __PRETTY_FUNCTION__);
+ e->content = std::make_shared<TextPart>(Headers {{"X-Source", "single_part"}}, "text/plain", __PRETTY_FUNCTION__);
LibesmtpMailServer ms("smtp.random.lan:25");
ms.sendEmail(e);
}
-
diff --git a/icetray/unittests/testIceTrayOptions.cpp b/icetray/unittests/testIceTrayOptions.cpp
index 3101052..81a98a0 100644
--- a/icetray/unittests/testIceTrayOptions.cpp
+++ b/icetray/unittests/testIceTrayOptions.cpp
@@ -1,25 +1,25 @@
#define BOOST_TEST_MODULE TestIceTrayLogger
#include <boost/test/unit_test.hpp>
+#include "dryice.h"
+#include "icetrayService.h"
#include "testOptions.h"
#include <Ice/Communicator.h>
-#include <Ice/ObjectAdapter.h>
#include <Ice/Initialize.h>
-#include "icetrayService.h"
-#include "dryice.h"
+#include <Ice/ObjectAdapter.h>
//
// TestService is pulled in from libtestService.so
//
class DI : public IceTray::DryIce {
- public:
- explicit DI(const Ice::StringSeq & opts) : IceTray::DryIce(opts) { }
+public:
+ explicit DI(const Ice::StringSeq & opts) : IceTray::DryIce(opts) { }
};
-BOOST_AUTO_TEST_CASE( testOptions )
+BOOST_AUTO_TEST_CASE(testOptions)
{
- DI di({ "--testInt=3", "--vec=1,2,4,8" });
+ DI di({"--testInt=3", "--vec=1,2,4,8"});
IceTray::OptionsResolver<TestOptions> myOpts;
BOOST_REQUIRE_EQUAL(3, myOpts->testInt);
BOOST_REQUIRE_EQUAL("some string", myOpts->testString);
@@ -30,17 +30,16 @@ BOOST_AUTO_TEST_CASE( testOptions )
BOOST_REQUIRE_EQUAL(8, myOpts->testVec[3]);
}
-BOOST_AUTO_TEST_CASE( overrideDefaultWithQuotesString )
+BOOST_AUTO_TEST_CASE(overrideDefaultWithQuotesString)
{
- DI di({ R"C(--testString="some \"Quotes\" string")C" });
+ DI di({R"C(--testString="some \"Quotes\" string")C"});
IceTray::OptionsResolver<TestOptions> myOpts;
BOOST_REQUIRE_EQUAL("some \"Quotes\" string", myOpts->testString);
}
-BOOST_AUTO_TEST_CASE( overrideDefaultWithEmptyString )
+BOOST_AUTO_TEST_CASE(overrideDefaultWithEmptyString)
{
- DI di({ R"C(--testString="")C" });
+ DI di({R"C(--testString="")C"});
IceTray::OptionsResolver<TestOptions> myOpts;
BOOST_REQUIRE(myOpts->testString.empty());
}
-
diff --git a/icetray/unittests/testIceTrayReplace.cpp b/icetray/unittests/testIceTrayReplace.cpp
index ac176b4..724700e 100644
--- a/icetray/unittests/testIceTrayReplace.cpp
+++ b/icetray/unittests/testIceTrayReplace.cpp
@@ -1,44 +1,47 @@
#define BOOST_TEST_MODULE TestIceTray
#include <boost/test/unit_test.hpp>
-#include <dryice.h>
-#include <Ice/Communicator.h>
#include "testIceTrayServiceI.h"
+#include <Ice/Communicator.h>
+#include <dryice.h>
-#include <pq-mock.h>
#include <definedDirs.h>
+#include <pq-mock.h>
namespace TestIceTray {
class DummyTestIceTrayServiceI : public TestIceTrayService {
- public:
- void method1(const Ice::Current &) override { }
- void method2(Ice::Int, std::string, const Ice::Current &) override { }
+ public:
+ void
+ method1(const Ice::Current &) override
+ {
+ }
+ void
+ method2(Ice::Int, std::string, const Ice::Current &) override
+ {
+ }
};
}
class Service : public IceTray::DryIce {
- public:
- Service()
- {
- replace("test", std::make_shared<TestIceTray::DummyTestIceTrayServiceI>());
- replace<TestIceTray::TestCube, TestIceTray::TestCubeI>();
- }
+public:
+ Service()
+ {
+ replace("test", std::make_shared<TestIceTray::DummyTestIceTrayServiceI>());
+ replace<TestIceTray::TestCube, TestIceTray::TestCubeI>();
+ }
};
-BOOST_GLOBAL_FIXTURE( Service );
+BOOST_GLOBAL_FIXTURE(Service);
class Client : public IceTray::DryIceClient {
- public:
- Client() :
- p(getProxy<TestIceTray::TestIceTrayServicePrx>("test"))
- {
- }
- TestIceTray::TestIceTrayServicePrxPtr p;
+public:
+ Client() : p(getProxy<TestIceTray::TestIceTrayServicePrx>("test")) { }
+ TestIceTray::TestIceTrayServicePrxPtr p;
};
-BOOST_FIXTURE_TEST_SUITE( client, Client );
+BOOST_FIXTURE_TEST_SUITE(client, Client);
-BOOST_AUTO_TEST_CASE( services )
+BOOST_AUTO_TEST_CASE(services)
{
BOOST_REQUIRE(p);
p->ice_ping();
@@ -47,4 +50,3 @@ BOOST_AUTO_TEST_CASE( services )
}
BOOST_AUTO_TEST_SUITE_END();
-
diff --git a/icetray/unittests/testIceTrayServiceI.cpp b/icetray/unittests/testIceTrayServiceI.cpp
index 33cdde4..af6994c 100644
--- a/icetray/unittests/testIceTrayServiceI.cpp
+++ b/icetray/unittests/testIceTrayServiceI.cpp
@@ -1,16 +1,17 @@
#include "testIceTrayServiceI.h"
-#include <factory.h>
-#include <Ice/ObjectAdapter.h>
+#include "icecube.h"
#include <Ice/Communicator.h>
#include <Ice/Initialize.h>
+#include <Ice/ObjectAdapter.h>
#include <boost/assert.hpp>
-#include <testIceTrayServiceTestSql.sql.h>
-#include <subdir/some.sql.h>
-#include <subdir/a/more.sql.h>
#include <boost/test/test_tools.hpp>
-#include "icecube.h"
+#include <factory.h>
+#include <subdir/a/more.sql.h>
+#include <subdir/some.sql.h>
+#include <testIceTrayServiceTestSql.sql.h>
-class Foo { };
+class Foo {
+};
namespace DB {
template<>
@@ -31,11 +32,15 @@ namespace TestIceTray {
TestIceTrayServiceI::fetchTest(const Type & value)
{
BOOST_REQUIRE_EQUAL(0, (fetch<int, int, Type>(sql::testIceTrayServiceTestSql, 1, value)));
- BOOST_REQUIRE_EQUAL(0, (fetch<int, std::optional<Type>, std::optional<Type>>(sql::testIceTrayServiceTestSql, {}, value)));
- BOOST_REQUIRE_EQUAL(0, (fetch<int, Ice::optional<Type>, Ice::optional<Type>>(sql::testIceTrayServiceTestSql, IceUtil::None, value)));
+ BOOST_REQUIRE_EQUAL(
+ 0, (fetch<int, std::optional<Type>, std::optional<Type>>(sql::testIceTrayServiceTestSql, {}, value)));
+ BOOST_REQUIRE_EQUAL(0,
+ (fetch<int, Ice::optional<Type>, Ice::optional<Type>>(
+ sql::testIceTrayServiceTestSql, IceUtil::None, value)));
}
- void TestIceTrayServiceI::method1(const Ice::Current &)
+ void
+ TestIceTrayServiceI::method1(const Ice::Current &)
{
fetch<int>(sql::subdir::some);
fetch<int>(sql::subdir::a::more);
@@ -62,26 +67,31 @@ namespace TestIceTray {
fetch<int>(dbc.get(), sql::testIceTrayServiceTestSql, 1, 1);
}
- void TestIceTrayServiceI::method2(Ice::Int id, std::string name, const Ice::Current &)
+ void
+ TestIceTrayServiceI::method2(Ice::Int id, std::string name, const Ice::Current &)
{
- BOOST_VERIFY((fetchCache<int>(sql::testIceTrayServiceTestSql, 10, id, name)) == (fetchCache<int>(sql::testIceTrayServiceTestSql, 10, id, name)));
+ BOOST_VERIFY((fetchCache<int>(sql::testIceTrayServiceTestSql, 10, id, name))
+ == (fetchCache<int>(sql::testIceTrayServiceTestSql, 10, id, name)));
}
- void TestCubeI::method1()
+ void
+ TestCubeI::method1()
{
}
- void TestCubeI::method2(Ice::Int, const std::string &)
+ void
+ TestCubeI::method2(Ice::Int, const std::string &)
{
}
- void TestService::addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adp)
+ void
+ TestService::addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &,
+ const Ice::ObjectAdapterPtr & adp)
{
IceTray::Cube::addObject<TestIceTray::TestIceTrayService, TestIceTray::TestIceTrayServiceI>(
- adp, "test", getConnectionPool(ic, "postgresql", "icetraydb"));
+ adp, "test", getConnectionPool(ic, "postgresql", "icetraydb"));
IceTray::Cube::add<TestIceTray::TestCube, TestIceTray::TestCubeI>();
}
NAMEDFACTORY("default", TestService, IceTray::ServiceFactory);
}
-
diff --git a/icetray/unittests/testIceTrayServiceI.h b/icetray/unittests/testIceTrayServiceI.h
index ef2f3a6..8dae0f3 100644
--- a/icetray/unittests/testIceTrayServiceI.h
+++ b/icetray/unittests/testIceTrayServiceI.h
@@ -1,33 +1,33 @@
#ifndef TEST_ICETRAY_SERVICE_IMPL_H
#define TEST_ICETRAY_SERVICE_IMPL_H
-#include <testIceTrayService.h>
-#include <icetrayService.h>
#include <abstractCachingDatabaseClient.h>
+#include <icetrayService.h>
+#include <testIceTrayService.h>
namespace TestIceTray {
class TestIceTrayServiceI : IceTray::AbstractCachingDatabaseClient, public TestIceTrayService {
- public:
- TestIceTrayServiceI(const DB::ConnectionPoolPtr & db);
+ public:
+ TestIceTrayServiceI(const DB::ConnectionPoolPtr & db);
- void method1(const Ice::Current &) override;
- void method2(Ice::Int id, std::string name, const Ice::Current &) override;
+ void method1(const Ice::Current &) override;
+ void method2(Ice::Int id, std::string name, const Ice::Current &) override;
- private:
- template<typename Type> void fetchTest(const Type & value);
+ private:
+ template<typename Type> void fetchTest(const Type & value);
};
class TestService : public IceTray::Service {
- public:
- void addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &) override;
+ public:
+ void addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &,
+ const Ice::ObjectAdapterPtr &) override;
};
class TestCubeI : public TestCube {
- public:
- void method1() override;
- void method2(Ice::Int id, const std::string & name) override;
+ public:
+ void method1() override;
+ void method2(Ice::Int id, const std::string & name) override;
};
}
#endif
-
diff --git a/icetray/unittests/testOptions.cpp b/icetray/unittests/testOptions.cpp
index f11aef0..e077d44 100644
--- a/icetray/unittests/testOptions.cpp
+++ b/icetray/unittests/testOptions.cpp
@@ -1,29 +1,18 @@
#include "testOptions.h"
-TestOptions::TestOptions() :
- IceTray::Options("Test options"),
- testInt(0)
-{
-}
+TestOptions::TestOptions() : IceTray::Options("Test options"), testInt(0) { }
ICETRAY_OPTIONS(TestOptions,
- ("testInt", boost::program_options::value(&testInt), "testInt")
- ("testString", boost::program_options::value(&testString)->default_value("some string"), "testString")
- ("vec", boost::program_options::value(&testVec), "vector")
-);
+ ("testInt", boost::program_options::value(&testInt), "testInt")("testString",
+ boost::program_options::value(&testString)->default_value("some string"),
+ "testString")("vec", boost::program_options::value(&testVec), "vector"));
class TestOptionsInline : public IceTray::Options {
- public:
- TestOptionsInline() :
- IceTray::Options("Test options inline")
- {
- }
+public:
+ TestOptionsInline() : IceTray::Options("Test options inline") { }
- ICETRAY_OPTIONS_INLINE(
- ("testIntInline", boost::program_options::value(&testInt), "testInt")
- );
+ ICETRAY_OPTIONS_INLINE(("testIntInline", boost::program_options::value(&testInt), "testInt"));
- int testInt { 0 };
+ int testInt {0};
};
FACTORY(TestOptionsInline, IceTray::OptionsFactory);
-
diff --git a/icetray/unittests/testOptions.h b/icetray/unittests/testOptions.h
index 06adb19..7f6e640 100644
--- a/icetray/unittests/testOptions.h
+++ b/icetray/unittests/testOptions.h
@@ -4,15 +4,14 @@
#include <options.h>
class DLL_PUBLIC TestOptions : public IceTray::Options {
- public:
- TestOptions();
+public:
+ TestOptions();
- ICETRAY_OPTIONS_DECLARE;
+ ICETRAY_OPTIONS_DECLARE;
- int testInt;
- std::string testString;
- std::vector<int> testVec;
+ int testInt;
+ std::string testString;
+ std::vector<int> testVec;
};
#endif
-
diff --git a/icetray/unittests/testService.cpp b/icetray/unittests/testService.cpp
index 8f678b0..a19e6a0 100644
--- a/icetray/unittests/testService.cpp
+++ b/icetray/unittests/testService.cpp
@@ -2,11 +2,11 @@
#include "testOptions.h"
void
-TestService::addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &)
+TestService::addObjects(
+ const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &)
{
// Verifies option resolution is available for addObjects.
IceTray::OptionsResolver<TestOptions> myOpts;
}
FACTORY(TestService, IceTray::ServiceFactory);
-
diff --git a/icetray/unittests/testService.h b/icetray/unittests/testService.h
index 7c5a0ae..930362b 100644
--- a/icetray/unittests/testService.h
+++ b/icetray/unittests/testService.h
@@ -1,7 +1,7 @@
#include <icetrayService.h>
class DLL_PUBLIC TestService : public IceTray::Service {
- public:
- void addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &) override;
+public:
+ void addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &,
+ const Ice::ObjectAdapterPtr &) override;
};
-