diff --git a/native/cpp/CommonCpp/NativeModules/AuxUserStoreOperations.h b/native/cpp/CommonCpp/NativeModules/AuxUserStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/AuxUserStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/AuxUserStoreOperations.h @@ -1,17 +1,13 @@ #pragma once #include "../DatabaseManagers/entities/AuxUserInfo.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class AuxUserStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~AuxUserStoreOperationBase(){}; -}; -class RemoveAuxUserInfosOperation : public AuxUserStoreOperationBase { +class RemoveAuxUserInfosOperation : public DBOperationBase { public: RemoveAuxUserInfosOperation(std::vector ids) : ids{ids} { } @@ -24,7 +20,7 @@ std::vector ids; }; -class ReplaceAuxUserInfoOperation : public AuxUserStoreOperationBase { +class ReplaceAuxUserInfoOperation : public DBOperationBase { public: ReplaceAuxUserInfoOperation(AuxUserInfo &&auxUserInfo) : auxUserInfo{std::move(auxUserInfo)} { @@ -38,7 +34,7 @@ AuxUserInfo auxUserInfo; }; -class RemoveAllAuxUserInfosOperation : public AuxUserStoreOperationBase { +class RemoveAllAuxUserInfosOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllAuxUserInfos(); diff --git a/native/cpp/CommonCpp/NativeModules/CommunityStoreOperations.h b/native/cpp/CommonCpp/NativeModules/CommunityStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/CommunityStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/CommunityStoreOperations.h @@ -1,17 +1,13 @@ #pragma once #include "../DatabaseManagers/entities/CommunityInfo.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class CommunityStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~CommunityStoreOperationBase(){}; -}; -class RemoveCommunitiesOperation : public CommunityStoreOperationBase { +class RemoveCommunitiesOperation : public DBOperationBase { public: RemoveCommunitiesOperation(std::vector ids) : ids{ids} { } @@ -24,7 +20,7 @@ std::vector ids; }; -class ReplaceCommunityOperation : public CommunityStoreOperationBase { +class ReplaceCommunityOperation : public DBOperationBase { public: ReplaceCommunityOperation(CommunityInfo &&community) : community{std::move(community)} { @@ -38,7 +34,7 @@ CommunityInfo community; }; -class RemoveAllCommunitiesOperation : public CommunityStoreOperationBase { +class RemoveAllCommunitiesOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllCommunities(); diff --git a/native/cpp/CommonCpp/NativeModules/DBOperationBase.h b/native/cpp/CommonCpp/NativeModules/DBOperationBase.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/NativeModules/DBOperationBase.h @@ -0,0 +1,11 @@ +#pragma once + +namespace comm { + +class DBOperationBase { +public: + virtual void execute() = 0; + virtual ~DBOperationBase(){}; +}; + +} // namespace comm diff --git a/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h @@ -1,5 +1,6 @@ #pragma once +#include "DBOperationBase.h" #include "DatabaseManager.h" #include @@ -7,13 +8,7 @@ namespace jsi = facebook::jsi; -class DraftStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~DraftStoreOperationBase(){}; -}; - -class UpdateDraftOperation : public DraftStoreOperationBase { +class UpdateDraftOperation : public DBOperationBase { public: UpdateDraftOperation(jsi::Runtime &rt, const jsi::Object &payload) : key{payload.getProperty(rt, "key").asString(rt).utf8(rt)}, @@ -28,7 +23,7 @@ std::string text; }; -class MoveDraftOperation : public DraftStoreOperationBase { +class MoveDraftOperation : public DBOperationBase { public: MoveDraftOperation(jsi::Runtime &rt, const jsi::Object &payload) : oldKey{payload.getProperty(rt, "oldKey").asString(rt).utf8(rt)}, @@ -43,14 +38,14 @@ std::string newKey; }; -class RemoveAllDraftsOperation : public DraftStoreOperationBase { +class RemoveAllDraftsOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllDrafts(); } }; -class RemoveDraftsOperation : public DraftStoreOperationBase { +class RemoveDraftsOperation : public DBOperationBase { public: RemoveDraftsOperation(jsi::Runtime &rt, const jsi::Object &payload) : idsToRemove{} { diff --git a/native/cpp/CommonCpp/NativeModules/IntegrityStoreOperations.h b/native/cpp/CommonCpp/NativeModules/IntegrityStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/IntegrityStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/IntegrityStoreOperations.h @@ -1,18 +1,13 @@ #pragma once #include "../DatabaseManagers/entities/IntegrityThreadHash.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class IntegrityStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~IntegrityStoreOperationBase(){}; -}; -class RemoveIntegrityThreadHashesOperation - : public IntegrityStoreOperationBase { +class RemoveIntegrityThreadHashesOperation : public DBOperationBase { public: RemoveIntegrityThreadHashesOperation(std::vector ids) : ids{ids} { @@ -26,8 +21,7 @@ std::vector ids; }; -class ReplaceIntegrityThreadHashesOperation - : public IntegrityStoreOperationBase { +class ReplaceIntegrityThreadHashesOperation : public DBOperationBase { public: ReplaceIntegrityThreadHashesOperation( std::vector &&threadHashes) @@ -43,8 +37,7 @@ std::vector threadHashes; }; -class RemoveAllIntegrityThreadHashesOperation - : public IntegrityStoreOperationBase { +class RemoveAllIntegrityThreadHashesOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllIntegrityThreadHashes(); diff --git a/native/cpp/CommonCpp/NativeModules/KeyserverStoreOperations.h b/native/cpp/CommonCpp/NativeModules/KeyserverStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/KeyserverStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/KeyserverStoreOperations.h @@ -1,17 +1,13 @@ #pragma once #include "../DatabaseManagers/entities/KeyserverInfo.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class KeyserverStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~KeyserverStoreOperationBase(){}; -}; -class RemoveKeyserversOperation : public KeyserverStoreOperationBase { +class RemoveKeyserversOperation : public DBOperationBase { public: RemoveKeyserversOperation(std::vector ids) : ids{ids} { } @@ -24,7 +20,7 @@ std::vector ids; }; -class ReplaceKeyserverOperation : public KeyserverStoreOperationBase { +class ReplaceKeyserverOperation : public DBOperationBase { public: ReplaceKeyserverOperation(KeyserverInfo &&keyserver) : keyserver{std::move(keyserver)} { @@ -38,7 +34,7 @@ KeyserverInfo keyserver; }; -class RemoveAllKeyserversOperation : public KeyserverStoreOperationBase { +class RemoveAllKeyserversOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllKeyservers(); diff --git a/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h b/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h @@ -2,17 +2,13 @@ #include "../DatabaseManagers/entities/Media.h" #include "../DatabaseManagers/entities/Message.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class MessageStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~MessageStoreOperationBase(){}; -}; -class RemoveMessagesOperation : public MessageStoreOperationBase { +class RemoveMessagesOperation : public DBOperationBase { public: RemoveMessagesOperation(jsi::Runtime &rt, const jsi::Object &payload) : msg_ids_to_remove{} { @@ -33,7 +29,7 @@ std::vector msg_ids_to_remove; }; -class RemoveMessagesForThreadsOperation : public MessageStoreOperationBase { +class RemoveMessagesForThreadsOperation : public DBOperationBase { public: RemoveMessagesForThreadsOperation( jsi::Runtime &rt, @@ -57,7 +53,7 @@ std::vector thread_ids; }; -class ReplaceMessageOperation : public MessageStoreOperationBase { +class ReplaceMessageOperation : public DBOperationBase { public: ReplaceMessageOperation(jsi::Runtime &rt, const jsi::Object &payload) : media_vector{} { @@ -133,7 +129,7 @@ std::vector> media_vector; }; -class RekeyMessageOperation : public MessageStoreOperationBase { +class RekeyMessageOperation : public DBOperationBase { public: RekeyMessageOperation(jsi::Runtime &rt, const jsi::Object &payload) { this->from = payload.getProperty(rt, "from").asString(rt).utf8(rt); @@ -151,7 +147,7 @@ std::string to; }; -class RemoveAllMessagesOperation : public MessageStoreOperationBase { +class RemoveAllMessagesOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllMessages(); @@ -159,7 +155,7 @@ } }; -class ReplaceMessageThreadsOperation : public MessageStoreOperationBase { +class ReplaceMessageThreadsOperation : public DBOperationBase { public: ReplaceMessageThreadsOperation(jsi::Runtime &rt, const jsi::Object &payload) : msg_threads{} { @@ -185,14 +181,14 @@ std::vector msg_threads; }; -class RemoveAllMessageStoreThreadsOperation : public MessageStoreOperationBase { +class RemoveAllMessageStoreThreadsOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllMessageStoreThreads(); } }; -class RemoveMessageStoreThreadsOperation : public MessageStoreOperationBase { +class RemoveMessageStoreThreadsOperation : public DBOperationBase { public: RemoveMessageStoreThreadsOperation( jsi::Runtime &rt, diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.h @@ -8,8 +8,7 @@ namespace comm { -class AuxUserStore - : public BaseDataStore { +class AuxUserStore : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -18,7 +17,7 @@ public: AuxUserStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp @@ -30,10 +30,10 @@ return jsiAuxUserInfos; } -std::vector> -AuxUserStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> auxUserStoreOps; +std::vector> AuxUserStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> auxUserStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.h @@ -8,8 +8,7 @@ namespace comm { -class CommunityStore - : public BaseDataStore { +class CommunityStore : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -18,7 +17,7 @@ public: CommunityStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp @@ -29,10 +29,10 @@ return jsiCommunities; } -std::vector> -CommunityStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> communityStoreOps; +std::vector> CommunityStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> communityStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.h @@ -8,7 +8,7 @@ namespace comm { -class DraftStore : public BaseDataStore { +class DraftStore : public BaseDataStore { private: static OperationType UPDATE_DRAFT_OPERATION; static OperationType MOVE_DRAFT_OPERATION; @@ -18,7 +18,7 @@ public: DraftStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/DraftStore.cpp @@ -36,10 +36,10 @@ return jsiDrafts; } -std::vector> -DraftStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> draftStoreOps; +std::vector> DraftStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> draftStoreOps; for (auto idx = 0; idx < operations.size(rt); idx++) { auto op = operations.getValueAtIndex(rt, idx).asObject(rt); auto op_type = op.getProperty(rt, "type").asString(rt).utf8(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.h @@ -9,7 +9,7 @@ namespace comm { class IntegrityStore - : public BaseDataStore { + : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -18,7 +18,7 @@ public: IntegrityStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp @@ -38,10 +38,10 @@ return jsiIntegrityThreadHashes; } -std::vector> -IntegrityStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> integrityStoreOps; +std::vector> IntegrityStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> integrityStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.h @@ -8,8 +8,7 @@ namespace comm { -class KeyserverStore - : public BaseDataStore { +class KeyserverStore : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -18,7 +17,7 @@ public: KeyserverStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp @@ -31,10 +31,10 @@ return jsiKeyservers; } -std::vector> -KeyserverStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> keyserverStoreOps; +std::vector> KeyserverStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> keyserverStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h @@ -11,8 +11,7 @@ using MessageEntity = std::pair>; -class MessageStore - : public BaseDataStore { +class MessageStore : public BaseDataStore { private: static OperationType REKEY_OPERATION; static OperationType REMOVE_OPERATION; @@ -27,7 +26,7 @@ public: MessageStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp @@ -73,11 +73,11 @@ return jsiMessages; } -std::vector> -MessageStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { +std::vector> MessageStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { - std::vector> messageStoreOps; + std::vector> messageStoreOps; for (auto idx = 0; idx < operations.size(rt); idx++) { auto op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.h @@ -8,7 +8,7 @@ namespace comm { -class ReportStore : public BaseDataStore { +class ReportStore : public BaseDataStore { private: static OperationType REPLACE_REPORT_OPERATION; static OperationType REMOVE_REPORTS_OPERATION; @@ -17,7 +17,7 @@ public: ReportStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ReportStore.cpp @@ -30,10 +30,10 @@ return jsiReports; } -std::vector> -ReportStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> reportStoreOps; +std::vector> ReportStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> reportStoreOps; for (auto idx = 0; idx < operations.size(rt); idx++) { auto op = operations.getValueAtIndex(rt, idx).asObject(rt); auto op_type = op.getProperty(rt, "type").asString(rt).utf8(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.h @@ -8,9 +8,8 @@ namespace comm { -class SyncedMetadataStore : public BaseDataStore< - SyncedMetadataStoreOperationBase, - SyncedMetadataEntry> { +class SyncedMetadataStore + : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -19,9 +18,9 @@ public: SyncedMetadataStore(std::shared_ptr jsInvoker); - std::vector> - createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const override; + std::vector> createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const override; jsi::Array parseDBDataStore( jsi::Runtime &rt, diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/SyncedMetadataStore.cpp @@ -33,12 +33,11 @@ return jsiSyncedMetadata; } -std::vector> +std::vector> SyncedMetadataStore::createOperations( jsi::Runtime &rt, const jsi::Array &operations) const { - std::vector> - syncedMetadataStoreOps; + std::vector> syncedMetadataStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.h @@ -8,9 +8,8 @@ namespace comm { -class ThreadActivityStore : public BaseDataStore< - ThreadActivityStoreOperationBase, - ThreadActivityEntry> { +class ThreadActivityStore + : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -19,9 +18,9 @@ public: ThreadActivityStore(std::shared_ptr jsInvoker); - std::vector> - createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const override; + std::vector> createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const override; jsi::Array parseDBDataStore( jsi::Runtime &rt, diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp @@ -39,12 +39,11 @@ return jsiThreadActivitiyEntries; } -std::vector> +std::vector> ThreadActivityStore::createOperations( jsi::Runtime &rt, const jsi::Array &operations) const { - std::vector> - threadActivityStoreOps; + std::vector> threadActivityStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.h @@ -8,7 +8,7 @@ namespace comm { -class ThreadStore : public BaseDataStore { +class ThreadStore : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -17,7 +17,7 @@ public: ThreadStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp @@ -77,10 +77,10 @@ return jsiThreads; } -std::vector> -ThreadStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> threadStoreOps; +std::vector> ThreadStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> threadStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.h @@ -8,7 +8,7 @@ namespace comm { -class UserStore : public BaseDataStore { +class UserStore : public BaseDataStore { private: static OperationType REMOVE_OPERATION; static OperationType REMOVE_ALL_OPERATION; @@ -17,7 +17,7 @@ public: UserStore(std::shared_ptr jsInvoker); - std::vector> createOperations( + std::vector> createOperations( jsi::Runtime &rt, const jsi::Array &operations) const override; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp @@ -28,10 +28,10 @@ return jsiUsers; } -std::vector> -UserStore::createOperations(jsi::Runtime &rt, const jsi::Array &operations) - const { - std::vector> userStoreOps; +std::vector> UserStore::createOperations( + jsi::Runtime &rt, + const jsi::Array &operations) const { + std::vector> userStoreOps; for (size_t idx = 0; idx < operations.size(rt); idx++) { jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt); diff --git a/native/cpp/CommonCpp/NativeModules/ReportStoreOperations.h b/native/cpp/CommonCpp/NativeModules/ReportStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/ReportStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/ReportStoreOperations.h @@ -2,17 +2,13 @@ #include "../DatabaseManagers/entities/Media.h" #include "../DatabaseManagers/entities/Report.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class ReportStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~ReportStoreOperationBase(){}; -}; -class RemoveReportsOperation : public ReportStoreOperationBase { +class RemoveReportsOperation : public DBOperationBase { public: RemoveReportsOperation(jsi::Runtime &rt, const jsi::Object &payload) : ids_to_remove{} { @@ -31,7 +27,7 @@ std::vector ids_to_remove; }; -class ReplaceReportOperation : public ReportStoreOperationBase { +class ReplaceReportOperation : public DBOperationBase { public: ReplaceReportOperation(jsi::Runtime &rt, const jsi::Object &payload) { auto report_id = payload.getProperty(rt, "id").asString(rt).utf8(rt); @@ -47,7 +43,7 @@ std::unique_ptr report; }; -class RemoveAllReportsOperation : public ReportStoreOperationBase { +class RemoveAllReportsOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllReports(); diff --git a/native/cpp/CommonCpp/NativeModules/SyncedMetadataStoreOperations.h b/native/cpp/CommonCpp/NativeModules/SyncedMetadataStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/SyncedMetadataStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/SyncedMetadataStoreOperations.h @@ -1,18 +1,13 @@ #pragma once #include "../DatabaseManagers/entities/SyncedMetadataEntry.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class SyncedMetadataStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~SyncedMetadataStoreOperationBase(){}; -}; - -class RemoveSyncedMetadataOperation : public SyncedMetadataStoreOperationBase { +class RemoveSyncedMetadataOperation : public DBOperationBase { public: RemoveSyncedMetadataOperation(std::vector names) : names{names} { } @@ -25,7 +20,7 @@ std::vector names; }; -class ReplaceSyncedMetadataOperation : public SyncedMetadataStoreOperationBase { +class ReplaceSyncedMetadataOperation : public DBOperationBase { public: ReplaceSyncedMetadataOperation(SyncedMetadataEntry &&syncedMetadataEntry) : syncedMetadataEntry{std::move(syncedMetadataEntry)} { @@ -40,8 +35,7 @@ SyncedMetadataEntry syncedMetadataEntry; }; -class RemoveAllSyncedMetadataOperation - : public SyncedMetadataStoreOperationBase { +class RemoveAllSyncedMetadataOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllSyncedMetadata(); diff --git a/native/cpp/CommonCpp/NativeModules/ThreadActivityStoreOperations.h b/native/cpp/CommonCpp/NativeModules/ThreadActivityStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/ThreadActivityStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/ThreadActivityStoreOperations.h @@ -1,18 +1,13 @@ #pragma once #include "../DatabaseManagers/entities/ThreadActivityEntry.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class ThreadActivityStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~ThreadActivityStoreOperationBase(){}; -}; -class RemoveThreadActivityEntriesOperation - : public ThreadActivityStoreOperationBase { +class RemoveThreadActivityEntriesOperation : public DBOperationBase { public: RemoveThreadActivityEntriesOperation(std::vector ids) : ids{ids} { @@ -26,8 +21,7 @@ std::vector ids; }; -class ReplaceThreadActivityEntryOperation - : public ThreadActivityStoreOperationBase { +class ReplaceThreadActivityEntryOperation : public DBOperationBase { public: ReplaceThreadActivityEntryOperation(ThreadActivityEntry &&threadActivityEntry) : threadActivityEntry{std::move(threadActivityEntry)} { @@ -42,8 +36,7 @@ ThreadActivityEntry threadActivityEntry; }; -class RemoveAllThreadActivityEntriesOperation - : public ThreadActivityStoreOperationBase { +class RemoveAllThreadActivityEntriesOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllThreadActivityEntries(); diff --git a/native/cpp/CommonCpp/NativeModules/ThreadStoreOperations.h b/native/cpp/CommonCpp/NativeModules/ThreadStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/ThreadStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/ThreadStoreOperations.h @@ -2,17 +2,13 @@ #include "../DatabaseManagers/entities/Media.h" #include "../DatabaseManagers/entities/Thread.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class ThreadStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~ThreadStoreOperationBase(){}; -}; -class RemoveThreadsOperation : public ThreadStoreOperationBase { +class RemoveThreadsOperation : public DBOperationBase { public: RemoveThreadsOperation(std::vector ids) : ids{ids} { } @@ -25,7 +21,7 @@ std::vector ids; }; -class ReplaceThreadOperation : public ThreadStoreOperationBase { +class ReplaceThreadOperation : public DBOperationBase { public: ReplaceThreadOperation(Thread &&thread) : thread{std::move(thread)} { } @@ -38,7 +34,7 @@ Thread thread; }; -class RemoveAllThreadsOperation : public ThreadStoreOperationBase { +class RemoveAllThreadsOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllThreads(); diff --git a/native/cpp/CommonCpp/NativeModules/UserStoreOperations.h b/native/cpp/CommonCpp/NativeModules/UserStoreOperations.h --- a/native/cpp/CommonCpp/NativeModules/UserStoreOperations.h +++ b/native/cpp/CommonCpp/NativeModules/UserStoreOperations.h @@ -1,17 +1,13 @@ #pragma once #include "../DatabaseManagers/entities/UserInfo.h" +#include "DBOperationBase.h" #include "DatabaseManager.h" #include namespace comm { -class UserStoreOperationBase { -public: - virtual void execute() = 0; - virtual ~UserStoreOperationBase(){}; -}; -class RemoveUsersOperation : public UserStoreOperationBase { +class RemoveUsersOperation : public DBOperationBase { public: RemoveUsersOperation(std::vector ids) : ids{ids} { } @@ -24,7 +20,7 @@ std::vector ids; }; -class ReplaceUserOperation : public UserStoreOperationBase { +class ReplaceUserOperation : public DBOperationBase { public: ReplaceUserOperation(UserInfo &&user) : user{std::move(user)} { } @@ -37,7 +33,7 @@ UserInfo user; }; -class RemoveAllUsersOperation : public UserStoreOperationBase { +class RemoveAllUsersOperation : public DBOperationBase { public: virtual void execute() override { DatabaseManager::getQueryExecutor().removeAllUsers();