Page MenuHomePhabricator

D3524.id10726.diff
No OneTemporary

D3524.id10726.diff

diff --git a/services/tunnelbroker/src/Database/DatabaseEntitiesTools.h b/services/tunnelbroker/src/Database/DatabaseEntitiesTools.h
--- a/services/tunnelbroker/src/Database/DatabaseEntitiesTools.h
+++ b/services/tunnelbroker/src/Database/DatabaseEntitiesTools.h
@@ -13,19 +13,10 @@
namespace database {
template <typename T> std::shared_ptr<T> createItemByType() {
- throw std::runtime_error("invalid Item type");
+ static_assert(std::is_base_of<Item, T>::value, "T must inherit from Item");
+ return std::make_shared<T>();
}
-template <>
-std::shared_ptr<DeviceSessionItem> createItemByType<DeviceSessionItem>();
-
-template <>
-std::shared_ptr<SessionSignItem> createItemByType<SessionSignItem>();
-
-template <> std::shared_ptr<PublicKeyItem> createItemByType<PublicKeyItem>();
-
-template <> std::shared_ptr<MessageItem> createItemByType<MessageItem>();
-
} // namespace database
} // namespace network
} // namespace comm
diff --git a/services/tunnelbroker/src/Database/DatabaseEntitiesTools.cpp b/services/tunnelbroker/src/Database/DatabaseEntitiesTools.cpp
deleted file mode 100644
--- a/services/tunnelbroker/src/Database/DatabaseEntitiesTools.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "DatabaseEntitiesTools.h"
-
-namespace comm {
-namespace network {
-namespace database {
-
-template <>
-std::shared_ptr<DeviceSessionItem> createItemByType<DeviceSessionItem>() {
- return std::make_shared<DeviceSessionItem>();
-}
-
-template <>
-std::shared_ptr<SessionSignItem> createItemByType<SessionSignItem>() {
- return std::make_shared<SessionSignItem>();
-}
-
-template <> std::shared_ptr<PublicKeyItem> createItemByType<PublicKeyItem>() {
- return std::make_shared<PublicKeyItem>();
-}
-
-template <> std::shared_ptr<MessageItem> createItemByType<MessageItem>() {
- return std::make_shared<MessageItem>();
-}
-
-} // namespace database
-} // namespace network
-} // namespace comm

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 10:20 AM (19 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2522247
Default Alt Text
D3524.id10726.diff (1 KB)

Event Timeline