From 70ebe533358e83d5e7080957d29a683d87f4ba79 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Thu, 5 Sep 2024 14:42:37 +0100 Subject: [PATCH 01/12] Added unit test for account deserialisation --- .../Connector.xcodeproj/project.pbxproj | 4 +++ .../ConnectorTests/AccountTests.cpp | 33 +++++++++++++++++++ SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp | 15 +++++++++ 3 files changed, 52 insertions(+) create mode 100644 SpeckleConnector/ConnectorTests/AccountTests.cpp create mode 100644 SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp diff --git a/SpeckleConnector/Connector.xcodeproj/project.pbxproj b/SpeckleConnector/Connector.xcodeproj/project.pbxproj index f66fa1a..e427d29 100644 --- a/SpeckleConnector/Connector.xcodeproj/project.pbxproj +++ b/SpeckleConnector/Connector.xcodeproj/project.pbxproj @@ -43,6 +43,7 @@ 21B67CF12C78D38000FD64FC /* GoAway.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21B67CF02C78D38000FD64FC /* GoAway.cpp */; }; 21B67CF72C78D4DE00FD64FC /* GetComplexType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21B67CF52C78D4DD00FD64FC /* GetComplexType.cpp */; }; 21D0BD602C89BFEA0077E104 /* SendBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */; }; + 21D0BD672C89D7410077E104 /* AccountTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD642C89D7400077E104 /* AccountTests.cpp */; }; 21D1E9AD2BF14AF200957EAA /* BIMData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9152BF14AEC00957EAA /* BIMData.framework */; }; 21D1E9AE2BF14AF200957EAA /* TeamworkPortalServerClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */; }; 21D1E9AF2BF14AF200957EAA /* GDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9172BF14AEC00957EAA /* GDL.framework */; }; @@ -307,6 +308,7 @@ 21B67CF62C78D4DE00FD64FC /* GetComplexType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetComplexType.h; sourceTree = ""; }; 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SendBridge.cpp; sourceTree = ""; }; 21D0BD5C2C89BFEA0077E104 /* SendBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SendBridge.h; sourceTree = ""; }; + 21D0BD642C89D7400077E104 /* AccountTests.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = AccountTests.cpp; sourceTree = ""; }; 21D1E9152BF14AEC00957EAA /* BIMData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BIMData.framework; path = "../Archicad 27/Support/Frameworks/BIMData.framework"; sourceTree = ""; }; 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TeamworkPortalServerClient.framework; path = "../Archicad 27/Support/Frameworks/TeamworkPortalServerClient.framework"; sourceTree = ""; }; 21D1E9172BF14AEC00957EAA /* GDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GDL.framework; path = "../Archicad 27/Support/Frameworks/GDL.framework"; sourceTree = ""; }; @@ -874,6 +876,7 @@ 219F30412C769282009834E9 /* ConnectorTests */ = { isa = PBXGroup; children = ( + 21D0BD642C89D7400077E104 /* AccountTests.cpp */, 219F30402C769282009834E9 /* ConfigTests.cpp */, 219F30432C7693B6009834E9 /* Connector-AC27-Debug.xctestplan */, ); @@ -1325,6 +1328,7 @@ buildActionMask = 2147483647; files = ( 219F30422C769283009834E9 /* ConfigTests.cpp in Sources */, + 21D0BD672C89D7410077E104 /* AccountTests.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/SpeckleConnector/ConnectorTests/AccountTests.cpp b/SpeckleConnector/ConnectorTests/AccountTests.cpp new file mode 100644 index 0000000..cb224fc --- /dev/null +++ b/SpeckleConnector/ConnectorTests/AccountTests.cpp @@ -0,0 +1,33 @@ +#include "ActiveLibDoctest/TestingPlatforms.h" + +#include "Active/Serialise/JSON/JSONTransport.h" +#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Utility/BufferIn.h" +#include "Speckle/Record/Credentials/Account.h" + +using namespace active::serialise; +using namespace active::serialise::json; +using namespace active::serialise::json; +using namespace speckle::record::cred; +using namespace speckle::utility; + +namespace { + + const char* accountJSON = "{\"id\":\"194B6E32061EB588B31D8CBC167DAAD8\",\"token\":\"547e30bcd0f0e377fe422019f388295e37c583a99f\",\"refreshToken\":\"7d23031b44856e768b5951161c9bc8378f663eefce\",\"isDefault\":false,\"isOnline\":false,\"serverInfo\":{\"name\":\"My new Speckle Server\",\"company\":\"Unknown Company\",\"version\":\"2.20.2-branch.testing.138676-e8c8291\",\"adminContact\":\"n/a\",\"description\":\"This a community deployment of a Speckle Server.\",\"frontend2\":true,\"url\":\"https://testing.speckle.dev\",\"migration\":null},\"userInfo\":{\"id\":\"e66694013f\",\"name\":\"oguzhan@speckle.systems\",\"email\":\"oguzhan@speckle.systems\",\"company\":null,\"avatar\":null,\"streams\":{\"totalCount\":2},\"commits\":{\"totalCount\":5}}}"; + +} + + +TEST_SUITE(TESTQ(AccountTests)) TEST_SUITE_OPEN + + //Test to receive account serialised as JSON from SQLite dbase + TEST_CASE(TESTQ(testAccountReceive)) { + Account account; + try { + JSONTransport().receive(PackageWrap{account}, Identity{}, String{accountJSON}); + } catch(...) { + FAIL_CHECK(TEST_MESSAGE(Account deserialisation failed)); + } + } + +TEST_SUITE_CLOSE diff --git a/SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp b/SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp new file mode 100644 index 0000000..1267690 --- /dev/null +++ b/SpeckleLib/SpeckleLibDoctest/Guid32Tests.cpp @@ -0,0 +1,15 @@ +#include "ActiveLibDoctest/TestingPlatforms.h" + +#include "Speckle/Utility/Guid32.h" + +using namespace speckle::utility; + +TEST_SUITE(TESTQ(GuidTests)) TEST_SUITE_OPEN + + ///Tests for creating/modifying guids + TEST_CASE(TESTQ(testGuidContent)) { + Guid32 badGuid{String{"abcd"}}; + CHECK_MESSAGE(!badGuid, TEST_MESSAGE(Guid32 created from bad data)); + } + +TEST_SUITE_CLOSE From f22b19993a19cc2ed5f7506ee67953a5abca3093 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:50:53 +0100 Subject: [PATCH 02/12] Added GetIsDevMode (#3) --- SpeckleConnector/Connector.vcxproj | 2 + .../Browser/Bridge/Config/ConfigBridge.cpp | 2 + .../Browser/Bridge/Config/GetConfig.h | 1 - .../Browser/Bridge/Config/GetIsDevMode.cpp | 39 +++++++++++++++++++ .../Browser/Bridge/Config/GetIsDevMode.h | 32 +++++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.cpp create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.h diff --git a/SpeckleConnector/Connector.vcxproj b/SpeckleConnector/Connector.vcxproj index 11d3c20..017662c 100644 --- a/SpeckleConnector/Connector.vcxproj +++ b/SpeckleConnector/Connector.vcxproj @@ -106,6 +106,7 @@ + @@ -134,6 +135,7 @@ + diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/ConfigBridge.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/ConfigBridge.cpp index e18ea8a..a300929 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/ConfigBridge.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/ConfigBridge.cpp @@ -2,6 +2,7 @@ #include "Connector/Interface/Browser/Bridge/Config/GetConfig.h" #include "Connector/Interface/Browser/Bridge/Config/UpdateConfig.h" +#include "Connector/Interface/Browser/Bridge/Config/GetIsDevMode.h" using namespace connector::interfac::browser::bridge; @@ -12,4 +13,5 @@ ConfigBridge::ConfigBridge() : BrowserBridge{"configBinding"} { //Add bridge methods addMethod(); addMethod(); + addMethod(); } //ConfigBridge::ConfigBridge diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.h index 12af537..ff4eea7 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.h +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.h @@ -15,7 +15,6 @@ namespace connector::interfac::browser::bridge { /*! Constructor - @param bridge The parent bridge object (provides access to bridge methods) */ GetConfig(); diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.cpp new file mode 100644 index 0000000..ec8998f --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.cpp @@ -0,0 +1,39 @@ +#include "Connector/Interface/Browser/Bridge/Config/GetIsDevMode.h" + +#include "Active/Serialise/CargoHold.h" +#include "Active/Serialise/Item/Wrapper/ValueWrap.h" + +using namespace active::serialise; +using namespace connector::interfac::browser::bridge; +using namespace speckle::utility; + +namespace { + + ///Return type for retrieving the current configuration + using WrappedValue = CargoHold, bool>; + +} + +/*-------------------------------------------------------------------- + Default constructor + --------------------------------------------------------------------*/ +GetIsDevMode::GetIsDevMode() : BridgeMethod{"GetIsDevMode", [&]() { + return run(); +}} {} + + +/*-------------------------------------------------------------------- + Get the DEBUG mode + + return: true for DEBUG, false otherwise + --------------------------------------------------------------------*/ +std::unique_ptr GetIsDevMode::run() const { + +#if DEBUG + bool value = true; +#else + bool value = false; +#endif + + return std::make_unique(value); +} //GetIsDevMode::run diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.h new file mode 100644 index 0000000..c5bb44e --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetIsDevMode.h @@ -0,0 +1,32 @@ +#ifndef CONNECTOR_INTERFACE_BRIDGE_GET_IS_DEV_MODE +#define CONNECTOR_INTERFACE_BRIDGE_GET_IS_DEV_MODE + +#include "Speckle/Interface/Browser/Bridge/BridgeMethod.h" + +namespace connector::interfac::browser::bridge { + + /*! + JS Function class to retrieve IsDebugMode + */ + class GetIsDevMode : public speckle::interfac::browser::bridge::BridgeMethod { + public: + + // MARK: - Constructors + + /*! + Constructor + */ + GetIsDevMode(); + + // MARK: - Functions (const) + + /*! + Get the DEBUG mode + @return true for DEBUG, false otherwise + */ + std::unique_ptr run() const; + }; + +} + +#endif //CONNECTOR_INTERFACE_BRIDGE_GET_IS_DEV_MODE From 7aa4cc9a51acbe86f37a0e02cd30b212571a4310 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Fri, 6 Sep 2024 09:24:14 +0100 Subject: [PATCH 03/12] Updated Xcode project --- SpeckleConnector/Connector.xcodeproj/project.pbxproj | 6 ++++++ SpeckleConnector/ConnectorTests/AccountTests.cpp | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/SpeckleConnector/Connector.xcodeproj/project.pbxproj b/SpeckleConnector/Connector.xcodeproj/project.pbxproj index e427d29..c46fb68 100644 --- a/SpeckleConnector/Connector.xcodeproj/project.pbxproj +++ b/SpeckleConnector/Connector.xcodeproj/project.pbxproj @@ -44,6 +44,7 @@ 21B67CF72C78D4DE00FD64FC /* GetComplexType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21B67CF52C78D4DD00FD64FC /* GetComplexType.cpp */; }; 21D0BD602C89BFEA0077E104 /* SendBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */; }; 21D0BD672C89D7410077E104 /* AccountTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD642C89D7400077E104 /* AccountTests.cpp */; }; + 21D0BD6A2C8A0DB40077E104 /* GetIsDevMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD682C8A0DB40077E104 /* GetIsDevMode.cpp */; }; 21D1E9AD2BF14AF200957EAA /* BIMData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9152BF14AEC00957EAA /* BIMData.framework */; }; 21D1E9AE2BF14AF200957EAA /* TeamworkPortalServerClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */; }; 21D1E9AF2BF14AF200957EAA /* GDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9172BF14AEC00957EAA /* GDL.framework */; }; @@ -309,6 +310,8 @@ 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SendBridge.cpp; sourceTree = ""; }; 21D0BD5C2C89BFEA0077E104 /* SendBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SendBridge.h; sourceTree = ""; }; 21D0BD642C89D7400077E104 /* AccountTests.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = AccountTests.cpp; sourceTree = ""; }; + 21D0BD682C8A0DB40077E104 /* GetIsDevMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetIsDevMode.cpp; sourceTree = ""; }; + 21D0BD692C8A0DB40077E104 /* GetIsDevMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetIsDevMode.h; sourceTree = ""; }; 21D1E9152BF14AEC00957EAA /* BIMData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BIMData.framework; path = "../Archicad 27/Support/Frameworks/BIMData.framework"; sourceTree = ""; }; 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TeamworkPortalServerClient.framework; path = "../Archicad 27/Support/Frameworks/TeamworkPortalServerClient.framework"; sourceTree = ""; }; 21D1E9172BF14AEC00957EAA /* GDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GDL.framework; path = "../Archicad 27/Support/Frameworks/GDL.framework"; sourceTree = ""; }; @@ -1085,6 +1088,8 @@ 21F69FB52C762EF0008B6A06 /* ConfigBridge.h */, 21F69FB62C762EF0008B6A06 /* GetConfig.cpp */, 21F69FB72C762EF0008B6A06 /* GetConfig.h */, + 21D0BD682C8A0DB40077E104 /* GetIsDevMode.cpp */, + 21D0BD692C8A0DB40077E104 /* GetIsDevMode.h */, 21F69FBD2C7630B3008B6A06 /* UpdateConfig.cpp */, 21F69FBE2C7630B3008B6A06 /* UpdateConfig.h */, ); @@ -1304,6 +1309,7 @@ 21B67CC32C77649F00FD64FC /* GetDocumentState.cpp in Sources */, 21D0BD602C89BFEA0077E104 /* SendBridge.cpp in Sources */, 21B67CAC2C77329800FD64FC /* BaseBridge.cpp in Sources */, + 21D0BD6A2C8A0DB40077E104 /* GetIsDevMode.cpp in Sources */, 210CC8832C80E6A300610F58 /* TriggerEvent.cpp in Sources */, 21B67CEB2C78D27200FD64FC /* DocumentInfo.cpp in Sources */, 21B67CB92C774BFA00FD64FC /* GetConnectorVersion.cpp in Sources */, diff --git a/SpeckleConnector/ConnectorTests/AccountTests.cpp b/SpeckleConnector/ConnectorTests/AccountTests.cpp index cb224fc..849dc31 100644 --- a/SpeckleConnector/ConnectorTests/AccountTests.cpp +++ b/SpeckleConnector/ConnectorTests/AccountTests.cpp @@ -13,8 +13,7 @@ using namespace speckle::utility; namespace { - const char* accountJSON = "{\"id\":\"194B6E32061EB588B31D8CBC167DAAD8\",\"token\":\"547e30bcd0f0e377fe422019f388295e37c583a99f\",\"refreshToken\":\"7d23031b44856e768b5951161c9bc8378f663eefce\",\"isDefault\":false,\"isOnline\":false,\"serverInfo\":{\"name\":\"My new Speckle Server\",\"company\":\"Unknown Company\",\"version\":\"2.20.2-branch.testing.138676-e8c8291\",\"adminContact\":\"n/a\",\"description\":\"This a community deployment of a Speckle Server.\",\"frontend2\":true,\"url\":\"https://testing.speckle.dev\",\"migration\":null},\"userInfo\":{\"id\":\"e66694013f\",\"name\":\"oguzhan@speckle.systems\",\"email\":\"oguzhan@speckle.systems\",\"company\":null,\"avatar\":null,\"streams\":{\"totalCount\":2},\"commits\":{\"totalCount\":5}}}"; - + const char* accountJSON = "{\"id\":\"d4468f8d6f1e4c48a899518795326ea8\",\"token\":\"42986a57b3304baa8773f937aa0b7bcd42986a57b3\",\"refreshToken\":\"00b01c421de4404889f30947de1506d3440c476432\",\"isDefault\":false,\"isOnline\":false,\"serverInfo\":{\"name\":\"My new Speckle Server\",\"company\":\"Unknown Company\",\"version\":\"2.20.2-branch.testing.138676-e8c8291\",\"adminContact\":\"n/a\",\"description\":\"This a community deployment of a Speckle Server.\",\"frontend2\":true,\"url\":\"https://testing.speckle.dev\",\"migration\":null},\"userInfo\":{\"id\":\"00b01c421d\",\"name\":\"someone@speckle.systems\",\"email\":\"someone@speckle.systems\",\"company\":null,\"avatar\":null,\"streams\":{\"totalCount\":2},\"commits\":{\"totalCount\":5}}}"; } From 09bf8f9ffaa8f875635b147cfd4473ed5a018756 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Fri, 6 Sep 2024 18:55:13 +0100 Subject: [PATCH 04/12] Restructured objects to support optional (nullable) members --- .../Bridge/Config/Arg/ConnectorConfig.cpp | 2 +- .../Browser/Bridge/Config/GetConfig.cpp | 2 +- .../Browser/Bridge/Config/UpdateConfig.cpp | 2 +- .../Browser/Bridge/Test/GetComplexType.cpp | 2 +- .../ConnectorTests/AccountTests.cpp | 2 +- .../Speckle/Database/AccountDatabase.cpp | 2 +- .../Browser/Bridge/Functions/RunMethod.cpp | 2 +- .../Speckle/Interface/Browser/JSFunction.h | 2 +- .../Speckle/Record/Credentials/Account.cpp | 2 +- .../Speckle/Record/Credentials/ServerInfo.cpp | 41 +++++--- .../Speckle/Record/Credentials/ServerInfo.h | 99 +++++++++++++++---- .../Record/Credentials/ServerMigration.cpp | 15 +-- .../Record/Credentials/ServerMigration.h | 18 ++-- .../Speckle/Record/Credentials/UserInfo.cpp | 10 +- .../Speckle/Record/Credentials/UserInfo.h | 4 +- .../Serialise/JSBase/JSBaseTransport.cpp | 2 +- 16 files changed, 137 insertions(+), 70 deletions(-) diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/Arg/ConnectorConfig.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/Arg/ConnectorConfig.cpp index 65ffacb..a22a310 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/Arg/ConnectorConfig.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/Arg/ConnectorConfig.cpp @@ -1,7 +1,7 @@ #include "Connector/Interface/Browser/Bridge/Config/Arg/ConnectorConfig.h" #include "Active/Serialise/Item/Wrapper/ValueWrap.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.cpp index b3e17f1..c486370 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/GetConfig.cpp @@ -1,7 +1,7 @@ #include "Connector/Interface/Browser/Bridge/Config/GetConfig.h" #include "Active/Serialise/CargoHold.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Connector/Interface/Browser/Bridge/Config/Arg/ConnectorConfig.h" using namespace active::serialise; diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/UpdateConfig.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/UpdateConfig.cpp index f97ccf4..1977dc6 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/UpdateConfig.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Config/UpdateConfig.cpp @@ -1,7 +1,7 @@ #include "Connector/Interface/Browser/Bridge/Config/UpdateConfig.h" #include "Active/Serialise/CargoHold.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" using namespace active::serialise; using namespace connector::interfac::browser::bridge; diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Test/GetComplexType.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Test/GetComplexType.cpp index d082d4a..873bb6f 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Test/GetComplexType.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Test/GetComplexType.cpp @@ -2,7 +2,7 @@ #include "Active/Serialise/CargoHold.h" #include "Active/Serialise/Item/Wrapper/ValueWrap.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include diff --git a/SpeckleConnector/ConnectorTests/AccountTests.cpp b/SpeckleConnector/ConnectorTests/AccountTests.cpp index 849dc31..19d1108 100644 --- a/SpeckleConnector/ConnectorTests/AccountTests.cpp +++ b/SpeckleConnector/ConnectorTests/AccountTests.cpp @@ -1,7 +1,7 @@ #include "ActiveLibDoctest/TestingPlatforms.h" #include "Active/Serialise/JSON/JSONTransport.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Active/Utility/BufferIn.h" #include "Speckle/Record/Credentials/Account.h" diff --git a/SpeckleLib/Speckle/Database/AccountDatabase.cpp b/SpeckleLib/Speckle/Database/AccountDatabase.cpp index 94f0ac5..c6847c1 100644 --- a/SpeckleLib/Speckle/Database/AccountDatabase.cpp +++ b/SpeckleLib/Speckle/Database/AccountDatabase.cpp @@ -1,4 +1,4 @@ -#include "Active/Database/Storage/SQLiteEngine.h" +#include "Active/Database/Storage/SQLite/SQLiteEngine.h" #include "Active/Database/Storage/Storage.h" #include "Active/Serialise/JSON/JSONTransport.h" #include "Active/Setting/ValueSetting.h" diff --git a/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/RunMethod.cpp b/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/RunMethod.cpp index 9887230..17f3376 100644 --- a/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/RunMethod.cpp +++ b/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/RunMethod.cpp @@ -2,7 +2,7 @@ #include "Active/Serialise/CargoHold.h" #include "Active/Serialise/Null.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Speckle/Interface/Browser/Bridge/BrowserBridge.h" #include "Speckle/Interface/Browser/Bridge/Functions/ErrorReport.h" #include "Speckle/Utility/Exception.h" diff --git a/SpeckleLib/Speckle/Interface/Browser/JSFunction.h b/SpeckleLib/Speckle/Interface/Browser/JSFunction.h index ade0b6e..0044ebf 100644 --- a/SpeckleLib/Speckle/Interface/Browser/JSFunction.h +++ b/SpeckleLib/Speckle/Interface/Browser/JSFunction.h @@ -4,7 +4,7 @@ #include "Active/Serialise/Inventory/Identity.h" #include "Active/Serialise/Item/Wrapper/ItemWrap.h" #include "Active/Serialise/Package/NullPackage.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Speckle/Interface/Browser/JSBinding.h" #include "Speckle/Interface/Browser/NamedFunction.h" #include "Speckle/Utility/String.h" diff --git a/SpeckleLib/Speckle/Record/Credentials/Account.cpp b/SpeckleLib/Speckle/Record/Credentials/Account.cpp index 1e9fc13..adfe089 100644 --- a/SpeckleLib/Speckle/Record/Credentials/Account.cpp +++ b/SpeckleLib/Speckle/Record/Credentials/Account.cpp @@ -1,7 +1,7 @@ #include "Speckle/Record/Credentials/Account.h" #include "Active/Serialise/Item/Wrapper/ValueWrap.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Speckle/Utility/Guid.h" using namespace active::serialise; diff --git a/SpeckleLib/Speckle/Record/Credentials/ServerInfo.cpp b/SpeckleLib/Speckle/Record/Credentials/ServerInfo.cpp index f8cfe91..db98ce8 100644 --- a/SpeckleLib/Speckle/Record/Credentials/ServerInfo.cpp +++ b/SpeckleLib/Speckle/Record/Credentials/ServerInfo.cpp @@ -1,7 +1,7 @@ #include "Speckle/Record/Credentials/ServerInfo.h" -#include "Active/Serialise/Item/Wrapper/ValueWrap.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Item/Wrapper/ValueOptionWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageUnoWrap.h" #include "Speckle/Utility/Guid.h" #include @@ -76,21 +76,21 @@ Cargo::Unique ServerInfo::getCargo(const Inventory::Item& item) const { using namespace active::serialise; switch (item.index) { case nameID: - return std::make_unique>(m_name); + return std::make_unique(m_name); case companyID: - return std::make_unique>(m_company); + return std::make_unique(m_company); case versionID: - return std::make_unique>(m_version); + return std::make_unique(m_version); case contactID: - return std::make_unique>(m_adminContact); + return std::make_unique(m_adminContact); case descriptionID: - return std::make_unique>(m_description); + return std::make_unique(m_description); case frontEndID: return std::make_unique>(m_frontend2); case urlID: - return std::make_unique>(m_url); + return std::make_unique(m_url); case migrationID: - return std::make_unique(m_migration); + return std::make_unique>(m_migration); default: return nullptr; //Requested an unknown index } @@ -102,10 +102,23 @@ Cargo::Unique ServerInfo::getCargo(const Inventory::Item& item) const { --------------------------------------------------------------------*/ void ServerInfo::setDefault() { m_name.clear(); - m_company.clear(); - m_version.clear(); - m_adminContact.clear(); - m_description.clear(); m_frontend2 = false; - m_url.clear(); } //ServerInfo::setDefault + + +/*-------------------------------------------------------------------- + Copy from another object + + source: The object to copy + --------------------------------------------------------------------*/ +void ServerInfo::copy(const ServerInfo& source) { + if (this == &source) + return; + m_name = source.m_name; + m_version = source.m_version; + m_adminContact = source.m_adminContact; + m_description = source.m_description; + m_frontend2 = source.m_frontend2; + m_url = source.m_url; + m_migration = (source.m_migration) ? std::make_unique(*source.m_migration) : nullptr; +} //ServerInfo::copy diff --git a/SpeckleLib/Speckle/Record/Credentials/ServerInfo.h b/SpeckleLib/Speckle/Record/Credentials/ServerInfo.h index 16d76cc..7e7d1a0 100644 --- a/SpeckleLib/Speckle/Record/Credentials/ServerInfo.h +++ b/SpeckleLib/Speckle/Record/Credentials/ServerInfo.h @@ -30,11 +30,29 @@ namespace speckle::record::cred { @param isFrontEnd ? @param migration Server migration record */ - ServerInfo(const utility::String& name, const utility::String& company, const utility::String& version, const utility::String& contact, - const utility::String& description, const utility::String& url, bool isFrontEnd, const ServerMigration& migration) : + ServerInfo(const utility::String& name, const utility::String::Option company = std::nullopt, + const utility::String::Option version = std::nullopt, const utility::String::Option contact = std::nullopt, + const utility::String::Option description = std::nullopt, const utility::String::Option url = std::nullopt, + bool isFrontEnd = false, std::unique_ptr migration = nullptr) : m_name{name}, m_company{company}, m_version{version}, m_adminContact{contact}, m_description{description}, - m_url{url}, m_frontend2{isFrontEnd}, m_migration{migration} {} - ServerInfo(const ServerInfo&) = default; + m_url{url}, m_frontend2{isFrontEnd}, m_migration{std::move(migration)} {} + /*! + Copy constructor + @param source The object to copy + */ + ServerInfo(const ServerInfo& source) { copy(source); } + /*! + Destructor + */ + ~ServerInfo() {} + + // MARK: - Operators + + /*! + Assignment operator + @param source The object to copy + */ + ServerInfo& operator=(const ServerInfo& source) { copy(source); return *this; } // MARK: - Functions (const) @@ -43,37 +61,78 @@ namespace speckle::record::cred { @return The server name */ const utility::String& getName() const { return m_name; } + /*! + Get the company name + @return The company name + */ + const utility::String::Option& getCompany() const { return m_company; } + /*! + Get the version + @return The version + */ + const utility::String::Option& getVersion() const { return m_version; } + /*! + Get the admin contact email + @return The admin contact email + */ + const utility::String::Option& getAdminContact() const { return m_adminContact; } + /*! + Get the description + @return The description + */ + const utility::String::Option& getDescription() const { return m_description; } + /*! + Determine if ? + @return ? + */ + bool isFrontEnd() const { return m_frontend2; } + /*! + Get the URL + @return The URL + */ + const utility::String::Option& getURL() const { return m_url; } + /*! + Get the migration history + @return The migration history (nullptr = no history) + */ + const ServerMigration* getMigration() const { return m_migration.get(); } // MARK: - Serialisation /*! - Fill an inventory with the package items - @param inventory The inventory to receive the package items - @return True if the package has added items to the inventory - */ + Fill an inventory with the package items + @param inventory The inventory to receive the package items + @return True if the package has added items to the inventory + */ bool fillInventory(active::serialise::Inventory& inventory) const override; /*! - Get the specified cargo - @param item The inventory item to retrieve - @return The requested cargo (nullptr on failure) - */ + Get the specified cargo + @param item The inventory item to retrieve + @return The requested cargo (nullptr on failure) + */ Cargo::Unique getCargo(const active::serialise::Inventory::Item& item) const override; /*! - Set to the default package content - */ + Set to the default package content + */ void setDefault() override; private: + /*! + Copy from another object + @param source The object to copy + */ + void copy(const ServerInfo& source); + ///Server name utility::String m_name; ///Company name - utility::String m_company; + utility::String::Option m_company; ///Server version - utility::String m_version; + utility::String::Option m_version; ///Admin contact email - utility::String m_adminContact; + utility::String::Option m_adminContact; ///Server description - utility::String m_description; + utility::String::Option m_description; /*! This field is not returned from the GQL API, it should be populated after construction from the response headers. See "Speckle.Core.Credentials.AccountManager" @@ -84,9 +143,9 @@ namespace speckle::record::cred { This field is not returned from the GQL API, it should be populated after construction. See "Speckle.Core.Credentials.AccountManager" */ - utility::String m_url; + utility::String::Option m_url; ///Server migration record - ServerMigration m_migration; + std::unique_ptr m_migration; }; } diff --git a/SpeckleLib/Speckle/Record/Credentials/ServerMigration.cpp b/SpeckleLib/Speckle/Record/Credentials/ServerMigration.cpp index e6ac223..7479bf7 100644 --- a/SpeckleLib/Speckle/Record/Credentials/ServerMigration.cpp +++ b/SpeckleLib/Speckle/Record/Credentials/ServerMigration.cpp @@ -1,6 +1,6 @@ #include "Speckle/Record/Credentials/ServerMigration.h" -#include "Active/Serialise/Item/Wrapper/ValueWrap.h" +#include "Active/Serialise/Item/Wrapper/ValueOptionWrap.h" #include "Speckle/Utility/Guid.h" using namespace active::serialise; @@ -57,19 +57,10 @@ Cargo::Unique ServerMigration::getCargo(const Inventory::Item& item) const { using namespace active::serialise; switch (item.index) { case movedToID: - return std::make_unique>(movedTo); + return std::make_unique(movedTo); case movedFromID: - return std::make_unique>(movedFrom); + return std::make_unique(movedFrom); default: return nullptr; //Requested an unknown index } } //ServerMigration::getCargo - - -/*-------------------------------------------------------------------- - Set to the default package content - --------------------------------------------------------------------*/ -void ServerMigration::setDefault() { - movedTo.clear(); - movedFrom.clear(); -} //ServerMigration::setDefault diff --git a/SpeckleLib/Speckle/Record/Credentials/ServerMigration.h b/SpeckleLib/Speckle/Record/Credentials/ServerMigration.h index 7020c7b..60f42f6 100644 --- a/SpeckleLib/Speckle/Record/Credentials/ServerMigration.h +++ b/SpeckleLib/Speckle/Record/Credentials/ServerMigration.h @@ -12,6 +12,16 @@ namespace speckle::record::cred { class ServerMigration : public active::serialise::Package { public: + // MARK: - Types + + using base = active::serialise::Package; + ///Unique pointer + using Unique = std::unique_ptr; + ///Shared pointer + using Shared = std::shared_ptr; + ///Optional + using Option = std::optional; + // MARK: - Constructors /*! @@ -25,9 +35,9 @@ namespace speckle::record::cred { // MARK: - Public variables ///New URI where this server is now deployed - speckle::utility::String movedTo; + speckle::utility::String::Option movedTo; ///Previous URI where this server used to be deployed - speckle::utility::String movedFrom; + speckle::utility::String::Option movedFrom; // MARK: - Serialisation @@ -43,10 +53,6 @@ namespace speckle::record::cred { @return The requested cargo (nullptr on failure) */ Cargo::Unique getCargo(const active::serialise::Inventory::Item& item) const override; - /*! - Set to the default package content - */ - void setDefault() override; }; } diff --git a/SpeckleLib/Speckle/Record/Credentials/UserInfo.cpp b/SpeckleLib/Speckle/Record/Credentials/UserInfo.cpp index 2063e44..f6a9773 100644 --- a/SpeckleLib/Speckle/Record/Credentials/UserInfo.cpp +++ b/SpeckleLib/Speckle/Record/Credentials/UserInfo.cpp @@ -1,7 +1,7 @@ #include "Speckle/Record/Credentials/UserInfo.h" -#include "Active/Serialise/Item/Wrapper/ValueWrap.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Item/Wrapper/ValueOptionWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Speckle/Utility/Guid.h" #include @@ -73,9 +73,9 @@ Cargo::Unique UserInfo::getCargo(const Inventory::Item& item) const { case emailID: return std::make_unique>(m_email); case companyID: - return std::make_unique>(m_company); + return std::make_unique(m_company); case avatarID: - return std::make_unique>(m_avatar); + return std::make_unique(m_avatar); default: return nullptr; //Requested an unknown index } @@ -88,7 +88,5 @@ Cargo::Unique UserInfo::getCargo(const Inventory::Item& item) const { void UserInfo::setDefault() { m_id.clear(); m_name.clear(); - m_company.clear(); m_email.clear(); - m_avatar.clear(); } //UserInfo::setDefault diff --git a/SpeckleLib/Speckle/Record/Credentials/UserInfo.h b/SpeckleLib/Speckle/Record/Credentials/UserInfo.h index 7813a68..59552eb 100644 --- a/SpeckleLib/Speckle/Record/Credentials/UserInfo.h +++ b/SpeckleLib/Speckle/Record/Credentials/UserInfo.h @@ -71,9 +71,9 @@ namespace speckle::record::cred { ///User email utility::String m_email; ///Compsny name - utility::String m_company; + utility::String::Option m_company; ///Avatar? - utility::String m_avatar; + utility::String::Option m_avatar; }; } diff --git a/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp b/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp index 0e47fca..8d859e9 100644 --- a/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp +++ b/SpeckleLib/Speckle/Serialise/JSBase/JSBaseTransport.cpp @@ -9,7 +9,7 @@ #include "Active/Setting/Values/StringValue.h" #include "Active/Setting/Values/UInt32Value.h" #include "Active/Serialise/Package/Package.h" -#include "Active/Serialise/Package/PackageWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Active/Serialise/XML/Item/XMLDateTime.h" #include "Speckle/Environment/Platform.h" From 83f38e946eb297f2c4a42e2d5a13a44d7538f1b8 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Fri, 6 Sep 2024 23:21:50 +0100 Subject: [PATCH 05/12] Added account send test --- SpeckleConnector/ConnectorTests/AccountTests.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/SpeckleConnector/ConnectorTests/AccountTests.cpp b/SpeckleConnector/ConnectorTests/AccountTests.cpp index 19d1108..2872613 100644 --- a/SpeckleConnector/ConnectorTests/AccountTests.cpp +++ b/SpeckleConnector/ConnectorTests/AccountTests.cpp @@ -3,6 +3,7 @@ #include "Active/Serialise/JSON/JSONTransport.h" #include "Active/Serialise/Package/Wrapper/PackageWrap.h" #include "Active/Utility/BufferIn.h" +#include "Active/Utility/BufferOut.h" #include "Speckle/Record/Credentials/Account.h" using namespace active::serialise; @@ -13,7 +14,7 @@ using namespace speckle::utility; namespace { - const char* accountJSON = "{\"id\":\"d4468f8d6f1e4c48a899518795326ea8\",\"token\":\"42986a57b3304baa8773f937aa0b7bcd42986a57b3\",\"refreshToken\":\"00b01c421de4404889f30947de1506d3440c476432\",\"isDefault\":false,\"isOnline\":false,\"serverInfo\":{\"name\":\"My new Speckle Server\",\"company\":\"Unknown Company\",\"version\":\"2.20.2-branch.testing.138676-e8c8291\",\"adminContact\":\"n/a\",\"description\":\"This a community deployment of a Speckle Server.\",\"frontend2\":true,\"url\":\"https://testing.speckle.dev\",\"migration\":null},\"userInfo\":{\"id\":\"00b01c421d\",\"name\":\"someone@speckle.systems\",\"email\":\"someone@speckle.systems\",\"company\":null,\"avatar\":null,\"streams\":{\"totalCount\":2},\"commits\":{\"totalCount\":5}}}"; + const char* accountJSON = "{\"id\":\"d4468f8d6f1e4c48a899518795326ea8\",\"token\":\"42986a57b3304baa8773f937aa0b7bcd42986a57b3\",\"refreshToken\":\"00b01c421de4404889f30947de1506d3440c476432\",\"isDefault\":true,\"isOnline\":false,\"serverInfo\":{\"name\":\"My new Speckle Server\",\"company\":\"Unknown Company\",\"version\":\"2.20.2-branch.testing.138676-e8c8291\",\"adminContact\":\"n/a\",\"description\":\"This a community deployment of a Speckle Server.\",\"frontend2\":true,\"url\":\"https://testing.speckle.dev\",\"migration\":null},\"userInfo\":{\"id\":\"00b01c421d\",\"name\":\"someone@speckle.systems\",\"email\":\"someone@speckle.systems\",\"company\":null,\"avatar\":null,\"streams\":{\"totalCount\":2},\"commits\":{\"totalCount\":5}}}"; } @@ -22,11 +23,19 @@ TEST_SUITE(TESTQ(AccountTests)) TEST_SUITE_OPEN //Test to receive account serialised as JSON from SQLite dbase TEST_CASE(TESTQ(testAccountReceive)) { Account account; + JSONTransport transport; try { - JSONTransport().receive(PackageWrap{account}, Identity{}, String{accountJSON}); + transport.receive(PackageWrap{account}, Identity{}, String{accountJSON}); } catch(...) { FAIL_CHECK(TEST_MESSAGE(Account deserialisation failed)); } + String accountOut; + try { + transport.send(PackageWrap{account}, Identity{}, accountOut); + } catch(...) { + FAIL_CHECK(TEST_MESSAGE(Account serialisation failed)); + } + } TEST_SUITE_CLOSE From c14e3ac095dac2872e642308cd89683621803616 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Fri, 6 Sep 2024 23:38:57 +0100 Subject: [PATCH 06/12] Use system-path include for AC API headers to avoid API-code warnings --- SpeckleConnector/Connector/Connector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SpeckleConnector/Connector/Connector.cpp b/SpeckleConnector/Connector/Connector.cpp index 1cc1645..8c18936 100755 --- a/SpeckleConnector/Connector/Connector.cpp +++ b/SpeckleConnector/Connector/Connector.cpp @@ -107,8 +107,8 @@ ConnectorAddon* connector::connector() { The following is the C interface for the plugin to Archicad as specified by the API */ -#include "ACAPinc.h" -#include "APIdefs_Registration.h" +#include +#include /*-------------------------------------------------------------------- Confirm that the plugin is able to run in the current environment From 9acc058f078dfdb4bfacf9b8a01ec976169ecf65 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Sun, 8 Sep 2024 23:01:22 +0100 Subject: [PATCH 07/12] Simplified add/install syntax --- SpeckleConnector/Connector/Connector.cpp | 4 ++-- .../Connector/Interface/ConnectorPalette.cpp | 10 +++++----- SpeckleLib/Speckle/Interface/Browser/JSPortal.h | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/SpeckleConnector/Connector/Connector.cpp b/SpeckleConnector/Connector/Connector.cpp index 8c18936..89ce861 100755 --- a/SpeckleConnector/Connector/Connector.cpp +++ b/SpeckleConnector/Connector/Connector.cpp @@ -27,8 +27,8 @@ namespace { class ConnectorInstance : public ConnectorAddon { public: ConnectorInstance(const String& name) : ConnectorAddon{name} { - add(std::make_shared()); - add(std::make_shared()); + add(); + add(); } // MARK: Functions (const) diff --git a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp index 8c48f37..acc4979 100644 --- a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp +++ b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp @@ -163,11 +163,11 @@ BrowserPalette::BrowserPalette() : Attach(*this); BeginEventProcessing(); //Install required connector bridges - install(std::make_shared()); - install(std::make_shared()); - install(std::make_shared()); - //install(std::make_shared()); - install(std::make_shared()); + install(); + install(); + install(); + //install(); + install(); InitBrowserControl(); } diff --git a/SpeckleLib/Speckle/Interface/Browser/JSPortal.h b/SpeckleLib/Speckle/Interface/Browser/JSPortal.h index 7b93aa1..b610291 100644 --- a/SpeckleLib/Speckle/Interface/Browser/JSPortal.h +++ b/SpeckleLib/Speckle/Interface/Browser/JSPortal.h @@ -49,6 +49,13 @@ namespace speckle::interfac::browser { @return True if the object was successfully installed */ bool install(std::shared_ptr> object); + /*! + Install a JS function object + @return True if the object was successfully installed + @tparam T The type of object to install + */ + template requires std::is_base_of_v, T> + bool install() { return install(std::make_shared()); } protected: #ifdef ARCHICAD From c68d2f3e255ec9b0972803ad16bd386a55c306fb Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Mon, 9 Sep 2024 09:28:00 +0100 Subject: [PATCH 08/12] Added placeholder Send binding --- .../Connector.xcodeproj/project.pbxproj | 6 +++ .../Interface/Browser/Bridge/Send/Send.cpp | 25 ++++++++++++ .../Interface/Browser/Bridge/Send/Send.h | 40 +++++++++++++++++++ .../Browser/Bridge/Send/SendBridge.cpp | 3 ++ .../Connector/Interface/ConnectorPalette.cpp | 2 +- 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.h diff --git a/SpeckleConnector/Connector.xcodeproj/project.pbxproj b/SpeckleConnector/Connector.xcodeproj/project.pbxproj index c46fb68..95f0a96 100644 --- a/SpeckleConnector/Connector.xcodeproj/project.pbxproj +++ b/SpeckleConnector/Connector.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 21D0BD602C89BFEA0077E104 /* SendBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */; }; 21D0BD672C89D7410077E104 /* AccountTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD642C89D7400077E104 /* AccountTests.cpp */; }; 21D0BD6A2C8A0DB40077E104 /* GetIsDevMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD682C8A0DB40077E104 /* GetIsDevMode.cpp */; }; + 21D0BD8E2C8EE4490077E104 /* Send.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD8D2C8EE4490077E104 /* Send.cpp */; }; 21D1E9AD2BF14AF200957EAA /* BIMData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9152BF14AEC00957EAA /* BIMData.framework */; }; 21D1E9AE2BF14AF200957EAA /* TeamworkPortalServerClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */; }; 21D1E9AF2BF14AF200957EAA /* GDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9172BF14AEC00957EAA /* GDL.framework */; }; @@ -312,6 +313,8 @@ 21D0BD642C89D7400077E104 /* AccountTests.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = AccountTests.cpp; sourceTree = ""; }; 21D0BD682C8A0DB40077E104 /* GetIsDevMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetIsDevMode.cpp; sourceTree = ""; }; 21D0BD692C8A0DB40077E104 /* GetIsDevMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetIsDevMode.h; sourceTree = ""; }; + 21D0BD8A2C8EE4490077E104 /* Send.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Send.h; sourceTree = ""; }; + 21D0BD8D2C8EE4490077E104 /* Send.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Send.cpp; sourceTree = ""; }; 21D1E9152BF14AEC00957EAA /* BIMData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BIMData.framework; path = "../Archicad 27/Support/Frameworks/BIMData.framework"; sourceTree = ""; }; 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TeamworkPortalServerClient.framework; path = "../Archicad 27/Support/Frameworks/TeamworkPortalServerClient.framework"; sourceTree = ""; }; 21D1E9172BF14AEC00957EAA /* GDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GDL.framework; path = "../Archicad 27/Support/Frameworks/GDL.framework"; sourceTree = ""; }; @@ -979,6 +982,8 @@ 21D0BD5D2C89BFEA0077E104 /* Send */ = { isa = PBXGroup; children = ( + 21D0BD8D2C8EE4490077E104 /* Send.cpp */, + 21D0BD8A2C8EE4490077E104 /* Send.h */, 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */, 21D0BD5C2C89BFEA0077E104 /* SendBridge.h */, ); @@ -1304,6 +1309,7 @@ 21B67CE32C78D1FB00FD64FC /* SayHiArg.cpp in Sources */, 21F69FBB2C762EF0008B6A06 /* ConfigBridge.cpp in Sources */, 21F69F8A2C70D2C4008B6A06 /* AccountBridge.cpp in Sources */, + 21D0BD8E2C8EE4490077E104 /* Send.cpp in Sources */, 21B67CF72C78D4DE00FD64FC /* GetComplexType.cpp in Sources */, 21B67CAE2C77329800FD64FC /* GetSourceApplicationVersion.cpp in Sources */, 21B67CC32C77649F00FD64FC /* GetDocumentState.cpp in Sources */, diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp new file mode 100644 index 0000000..12ce6ed --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.cpp @@ -0,0 +1,25 @@ +#include "Connector/Interface/Browser/Bridge/Send/Send.h" + +#include "Active/Serialise/CargoHold.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" + +using namespace active::serialise; +using namespace connector::interfac::browser::bridge; +using namespace speckle::utility; + +/*-------------------------------------------------------------------- + Default constructor + --------------------------------------------------------------------*/ +Send::Send() : BridgeMethod{"Send", [&](UpdateArgs args) { + run(args); +}} {} + + +/*-------------------------------------------------------------------- + Send a specified model + + modelCardID: The ID of the madel to send + --------------------------------------------------------------------*/ +void Send::run(const String& modelCardID) const { + ///TODO: Send the requested model +} //Send::run diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.h new file mode 100644 index 0000000..6ab3a91 --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Send.h @@ -0,0 +1,40 @@ +#ifndef CONNECTOR_INTERFACE_BRIDGE_SEND +#define CONNECTOR_INTERFACE_BRIDGE_SEND + +#include "Active/Serialise/CargoHold.h" +#include "Connector/Interface/Browser/Bridge/Config/Arg/ConnectorConfig.h" +#include "Speckle/Interface/Browser/Bridge/BridgeMethod.h" + +namespace connector::interfac::browser::bridge { + + class ConnectorConfig; + + ///Argument for a JS call to update the configuration + using UpdateArgs = speckle::interfac::browser::bridge::JSArgType; + + /*! + JS Function class to retrieve the names of the methods supported by the bridge + */ + class Send : public speckle::interfac::browser::bridge::BridgeMethod { + public: + + // MARK: - Constructors + + /*! + Constructor + @param bridge The parent bridge object (provides access to bridge methods) + */ + Send(); + + // MARK: - Functions (const) + + /*! + Send a specified model + @param modelCardID The ID of the madel to send + */ + void run(const speckle::utility::String& modelCardID) const; + }; + +} + +#endif //CONNECTOR_INTERFACE_BRIDGE_SEND diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp index 9f898f7..6484156 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp @@ -1,5 +1,7 @@ #include "Connector/Interface/Browser/Bridge/Send/SendBridge.h" +#include "Connector/Interface/Browser/Bridge/Send/Send.h" + using namespace connector::interfac::browser::bridge; /*-------------------------------------------------------------------- @@ -7,4 +9,5 @@ using namespace connector::interfac::browser::bridge; --------------------------------------------------------------------*/ SendBridge::SendBridge() : BrowserBridge{"sendBinding"} { //Add bridge methods + addMethod(); } //SendBridge::SendBridge diff --git a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp index acc4979..53c0ab8 100644 --- a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp +++ b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp @@ -166,7 +166,7 @@ BrowserPalette::BrowserPalette() : install(); install(); install(); - //install(); + install(); install(); InitBrowserControl(); } From 0b00af7d1daf5eefa37b9fef0aceeec3b64a5136 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Mon, 9 Sep 2024 09:39:47 +0100 Subject: [PATCH 09/12] Updated VS project Temporarily deactived "sendBinding" - appears to stop usual palette rendering (possibly further implementation required) --- SpeckleConnector/Connector.vcxproj | 4 +++- SpeckleConnector/Connector.vcxproj.filters | 8 ++++++++ SpeckleConnector/Connector/Interface/ConnectorPalette.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SpeckleConnector/Connector.vcxproj b/SpeckleConnector/Connector.vcxproj index 017662c..a3c5923 100644 --- a/SpeckleConnector/Connector.vcxproj +++ b/SpeckleConnector/Connector.vcxproj @@ -106,8 +106,9 @@ - + + @@ -137,6 +138,7 @@ + diff --git a/SpeckleConnector/Connector.vcxproj.filters b/SpeckleConnector/Connector.vcxproj.filters index b28e1ac..81a8c08 100644 --- a/SpeckleConnector/Connector.vcxproj.filters +++ b/SpeckleConnector/Connector.vcxproj.filters @@ -149,6 +149,10 @@ Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send + @@ -232,5 +236,9 @@ Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send + \ No newline at end of file diff --git a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp index 53c0ab8..acc4979 100644 --- a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp +++ b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp @@ -166,7 +166,7 @@ BrowserPalette::BrowserPalette() : install(); install(); install(); - install(); + //install(); install(); InitBrowserControl(); } From ea3152d942cec391383b7c4b3f90c863b58c9ea3 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Mon, 9 Sep 2024 12:59:07 +0100 Subject: [PATCH 10/12] Added GetSendFilter Reactivated sendBinding --- .../Connector.xcodeproj/project.pbxproj | 20 +++++ .../Browser/Bridge/Base/Arg/DocumentInfo.h | 6 +- .../Browser/Bridge/Send/Arg/SendFilter.cpp | 80 +++++++++++++++++++ .../Browser/Bridge/Send/Arg/SendFilter.h | 67 ++++++++++++++++ .../Browser/Bridge/Send/GetSendFilters.cpp | 37 +++++++++ .../Browser/Bridge/Send/GetSendFilters.h | 36 +++++++++ .../Browser/Bridge/Send/SendBridge.cpp | 2 + .../Connector/Interface/ConnectorPalette.cpp | 2 +- 8 files changed, 246 insertions(+), 4 deletions(-) create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.cpp create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.h create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.cpp create mode 100644 SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.h diff --git a/SpeckleConnector/Connector.xcodeproj/project.pbxproj b/SpeckleConnector/Connector.xcodeproj/project.pbxproj index 95f0a96..028a510 100644 --- a/SpeckleConnector/Connector.xcodeproj/project.pbxproj +++ b/SpeckleConnector/Connector.xcodeproj/project.pbxproj @@ -46,6 +46,8 @@ 21D0BD672C89D7410077E104 /* AccountTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD642C89D7400077E104 /* AccountTests.cpp */; }; 21D0BD6A2C8A0DB40077E104 /* GetIsDevMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD682C8A0DB40077E104 /* GetIsDevMode.cpp */; }; 21D0BD8E2C8EE4490077E104 /* Send.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD8D2C8EE4490077E104 /* Send.cpp */; }; + 21D0BD972C8F13F30077E104 /* GetSendFilters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD962C8F13F30077E104 /* GetSendFilters.cpp */; }; + 21D0BD9B2C8F154B0077E104 /* SendFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21D0BD982C8F154B0077E104 /* SendFilter.cpp */; }; 21D1E9AD2BF14AF200957EAA /* BIMData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9152BF14AEC00957EAA /* BIMData.framework */; }; 21D1E9AE2BF14AF200957EAA /* TeamworkPortalServerClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */; }; 21D1E9AF2BF14AF200957EAA /* GDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21D1E9172BF14AEC00957EAA /* GDL.framework */; }; @@ -315,6 +317,10 @@ 21D0BD692C8A0DB40077E104 /* GetIsDevMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetIsDevMode.h; sourceTree = ""; }; 21D0BD8A2C8EE4490077E104 /* Send.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Send.h; sourceTree = ""; }; 21D0BD8D2C8EE4490077E104 /* Send.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Send.cpp; sourceTree = ""; }; + 21D0BD952C8F13F30077E104 /* GetSendFilters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetSendFilters.h; sourceTree = ""; }; + 21D0BD962C8F13F30077E104 /* GetSendFilters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetSendFilters.cpp; sourceTree = ""; }; + 21D0BD982C8F154B0077E104 /* SendFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SendFilter.cpp; sourceTree = ""; }; + 21D0BD992C8F154B0077E104 /* SendFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SendFilter.h; sourceTree = ""; }; 21D1E9152BF14AEC00957EAA /* BIMData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BIMData.framework; path = "../Archicad 27/Support/Frameworks/BIMData.framework"; sourceTree = ""; }; 21D1E9162BF14AEC00957EAA /* TeamworkPortalServerClient.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TeamworkPortalServerClient.framework; path = "../Archicad 27/Support/Frameworks/TeamworkPortalServerClient.framework"; sourceTree = ""; }; 21D1E9172BF14AEC00957EAA /* GDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GDL.framework; path = "../Archicad 27/Support/Frameworks/GDL.framework"; sourceTree = ""; }; @@ -982,6 +988,9 @@ 21D0BD5D2C89BFEA0077E104 /* Send */ = { isa = PBXGroup; children = ( + 21D0BD9A2C8F154B0077E104 /* Arg */, + 21D0BD962C8F13F30077E104 /* GetSendFilters.cpp */, + 21D0BD952C8F13F30077E104 /* GetSendFilters.h */, 21D0BD8D2C8EE4490077E104 /* Send.cpp */, 21D0BD8A2C8EE4490077E104 /* Send.h */, 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */, @@ -990,6 +999,15 @@ path = Send; sourceTree = ""; }; + 21D0BD9A2C8F154B0077E104 /* Arg */ = { + isa = PBXGroup; + children = ( + 21D0BD982C8F154B0077E104 /* SendFilter.cpp */, + 21D0BD992C8F154B0077E104 /* SendFilter.h */, + ); + path = Arg; + sourceTree = ""; + }; 21D1EA472BF14B6C00957EAA /* Archicad */ = { isa = PBXGroup; children = ( @@ -1309,11 +1327,13 @@ 21B67CE32C78D1FB00FD64FC /* SayHiArg.cpp in Sources */, 21F69FBB2C762EF0008B6A06 /* ConfigBridge.cpp in Sources */, 21F69F8A2C70D2C4008B6A06 /* AccountBridge.cpp in Sources */, + 21D0BD9B2C8F154B0077E104 /* SendFilter.cpp in Sources */, 21D0BD8E2C8EE4490077E104 /* Send.cpp in Sources */, 21B67CF72C78D4DE00FD64FC /* GetComplexType.cpp in Sources */, 21B67CAE2C77329800FD64FC /* GetSourceApplicationVersion.cpp in Sources */, 21B67CC32C77649F00FD64FC /* GetDocumentState.cpp in Sources */, 21D0BD602C89BFEA0077E104 /* SendBridge.cpp in Sources */, + 21D0BD972C8F13F30077E104 /* GetSendFilters.cpp in Sources */, 21B67CAC2C77329800FD64FC /* BaseBridge.cpp in Sources */, 21D0BD6A2C8A0DB40077E104 /* GetIsDevMode.cpp in Sources */, 210CC8832C80E6A300610F58 /* TriggerEvent.cpp in Sources */, diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/Arg/DocumentInfo.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/Arg/DocumentInfo.h index fa82f75..b9ed59f 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/Arg/DocumentInfo.h +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/Arg/DocumentInfo.h @@ -1,5 +1,5 @@ -#ifndef CONNECTOR_INTERFACE_BRIDGE_CONNECTOR_CONFIG -#define CONNECTOR_INTERFACE_BRIDGE_CONNECTOR_CONFIG +#ifndef CONNECTOR_INTERFACE_BRIDGE_DOCUMENT_INFO +#define CONNECTOR_INTERFACE_BRIDGE_DOCUMENT_INFO #include "Active/Serialise/Package/Package.h" #include "Speckle/Utility/String.h" @@ -58,4 +58,4 @@ namespace connector::interfac::browser::bridge { } -#endif //CONNECTOR_INTERFACE_BRIDGE_CONNECTOR_CONFIG +#endif //CONNECTOR_INTERFACE_BRIDGE_DOCUMENT_INFO diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.cpp new file mode 100644 index 0000000..8abef93 --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.cpp @@ -0,0 +1,80 @@ +#include "Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.h" + +#include "Active/Serialise/Item/Wrapper/ValueWrap.h" + +#include + +using namespace active::serialise; +using namespace connector::interfac::browser::bridge; +using namespace speckle::utility; + +namespace { + + ///Serialisation fields + enum FieldIndex { + nameID, + summaryID, + defaultID, + }; + + ///Serialisation field IDs + static std::array fieldID = { + Identity{"name"}, + Identity{"summary"}, + Identity{"isDefault"}, + }; + +} + +/*-------------------------------------------------------------------- + Fill an inventory with the package items + + inventory: The inventory to receive the package items + + return: True if the package has added items to the inventory + --------------------------------------------------------------------*/ +bool SendFilter::fillInventory(Inventory& inventory) const { + using enum Entry::Type; + inventory.merge(Inventory{ + { + { fieldID[nameID], nameID, element }, + { fieldID[summaryID], summaryID, element }, + { fieldID[defaultID], defaultID, element }, + }, + }.withType(&typeid(SendFilter))); + return true; +} //SendFilter::fillInventory + + +/*-------------------------------------------------------------------- + Get the specified cargo + + item: The inventory item to retrieve + + return: The requested cargo (nullptr on failure) + --------------------------------------------------------------------*/ +Cargo::Unique SendFilter::getCargo(const Inventory::Item& item) const { + if (item.ownerType != &typeid(SendFilter)) + return nullptr; + using namespace active::serialise; + switch (item.index) { + case nameID: + return std::make_unique>(name); + case summaryID: + return std::make_unique>(summary); + case defaultID: + return std::make_unique>(isDefault); + default: + return nullptr; //Requested an unknown index + } +} //SendFilter::getCargo + + +/*-------------------------------------------------------------------- + Set to the default package content + --------------------------------------------------------------------*/ +void SendFilter::setDefault() { + name.clear(); + summary.clear(); + isDefault = false; +} //SendFilter::setDefault diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.h new file mode 100644 index 0000000..d86abc6 --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.h @@ -0,0 +1,67 @@ +#ifndef CONNECTOR_INTERFACE_BRIDGE_SEND_FILTER +#define CONNECTOR_INTERFACE_BRIDGE_SEND_FILTER + +#include "Active/Serialise/Package/Package.h" +#include "Active/Utility/Cloner.h" +#include "Speckle/Utility/String.h" + +namespace connector::interfac::browser::bridge { + + /*! + A connector send filter + */ + class SendFilter : public active::serialise::Package, public active::utility::Cloner { + public: + + // MARK: - Types + + using base = active::serialise::Package; + + // MARK: - Constructors + + /*! + Default constructor + @param nm The filter name + @param sum A summary + @param isDef True if this is the default filter + */ + SendFilter(const speckle::utility::String& nm = {}, const speckle::utility::String& sum = {}, bool isDef = false) : + name{nm}, summary{sum}, isDefault{isDef} {} + /*! + Record cloning + @return A clone of this record + */ + virtual SendFilter* clonePtr() const override { return new SendFilter(*this); }; + + // MARK: - Public variables (NB: Assuming to class invariants or overrides for this data, so making public for simplicity) + + ///The filter name + speckle::utility::String name; + ///A summary + speckle::utility::String summary; + ///True if this is the default filter + bool isDefault = false; + + // MARK: - Serialisation + + /*! + Fill an inventory with the package items + @param inventory The inventory to receive the package items + @return True if the package has added items to the inventory + */ + bool fillInventory(active::serialise::Inventory& inventory) const override; + /*! + Get the specified cargo + @param item The inventory item to retrieve + @return The requested cargo (nullptr on failure) + */ + Cargo::Unique getCargo(const active::serialise::Inventory::Item& item) const override; + /*! + Set to the default package content + */ + void setDefault() override; + }; + +} + +#endif //CONNECTOR_INTERFACE_BRIDGE_SEND_FILTER diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.cpp new file mode 100644 index 0000000..6897267 --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.cpp @@ -0,0 +1,37 @@ +#include "Connector/Interface/Browser/Bridge/Send/GetSendFilters.h" + +#include "Active/Container/Vector.h" +#include "Active/Serialise/CargoHold.h" +#include "Active/Serialise/Package/Wrapper/ContainerWrap.h" +#include "Active/Serialise/Package/Wrapper/PackageWrap.h" +#include "Connector/Interface/Browser/Bridge/Send/Arg/SendFilter.h" + +using namespace active::container; +using namespace active::serialise; +using namespace connector::interfac::browser::bridge; +using namespace speckle::utility; + +namespace { + + using WrappedValue = active::serialise::CargoHold, Vector>; + +} + +/*-------------------------------------------------------------------- + Default constructor + --------------------------------------------------------------------*/ +GetSendFilters::GetSendFilters() : BridgeMethod{"GetSendFilters", [&]() { + return run(); +}} {} + + +/*-------------------------------------------------------------------- + Get the send filters + + return: The send filters + --------------------------------------------------------------------*/ +std::unique_ptr GetSendFilters::run() const { + Vector filters; + ///TODO: Get real filters + return std::make_unique(filters); +} //GetSendFilters::run diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.h new file mode 100644 index 0000000..9f52396 --- /dev/null +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/GetSendFilters.h @@ -0,0 +1,36 @@ +#ifndef CONNECTOR_INTERFACE_BRIDGE_GET_SEND_FILTERS +#define CONNECTOR_INTERFACE_BRIDGE_GET_SEND_FILTERS + +#include "Active/Serialise/CargoHold.h" +#include "Speckle/Interface/Browser/Bridge/BridgeMethod.h" + +namespace connector::interfac::browser::bridge { + + class ConnectorConfig; + + /*! + JS Function class to retrieve the send filters + */ + class GetSendFilters : public speckle::interfac::browser::bridge::BridgeMethod { + public: + + // MARK: - Constructors + + /*! + Constructor + @param bridge The parent bridge object (provides access to bridge methods) + */ + GetSendFilters(); + + // MARK: - Functions (const) + + /*! + Get the send filters + @return The send filters + */ + std::unique_ptr run() const; + }; + +} + +#endif //CONNECTOR_INTERFACE_BRIDGE_GET_SEND_FILTERS diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp index 6484156..d4180e6 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp @@ -1,5 +1,6 @@ #include "Connector/Interface/Browser/Bridge/Send/SendBridge.h" +#include "Connector/Interface/Browser/Bridge/Send/GetSendFilters.h" #include "Connector/Interface/Browser/Bridge/Send/Send.h" using namespace connector::interfac::browser::bridge; @@ -9,5 +10,6 @@ using namespace connector::interfac::browser::bridge; --------------------------------------------------------------------*/ SendBridge::SendBridge() : BrowserBridge{"sendBinding"} { //Add bridge methods + addMethod(); addMethod(); } //SendBridge::SendBridge diff --git a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp index acc4979..53c0ab8 100644 --- a/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp +++ b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp @@ -166,7 +166,7 @@ BrowserPalette::BrowserPalette() : install(); install(); install(); - //install(); + install(); install(); InitBrowserControl(); } From 997545b6acd9eb22efe573a04e063b0e0aa3393a Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Mon, 9 Sep 2024 13:03:13 +0100 Subject: [PATCH 11/12] Updated VS projects --- SpeckleConnector/Connector.vcxproj | 4 ++++ SpeckleConnector/Connector.vcxproj.filters | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/SpeckleConnector/Connector.vcxproj b/SpeckleConnector/Connector.vcxproj index a3c5923..355ea9f 100644 --- a/SpeckleConnector/Connector.vcxproj +++ b/SpeckleConnector/Connector.vcxproj @@ -108,6 +108,8 @@ + + @@ -138,6 +140,8 @@ + + diff --git a/SpeckleConnector/Connector.vcxproj.filters b/SpeckleConnector/Connector.vcxproj.filters index 81a8c08..2303713 100644 --- a/SpeckleConnector/Connector.vcxproj.filters +++ b/SpeckleConnector/Connector.vcxproj.filters @@ -53,6 +53,9 @@ {2b87cf11-87cd-435f-ab24-42170c2e657e} + + {3bc97363-0091-4f84-a5f7-085193bad850} + @@ -153,6 +156,12 @@ Connector\Interface\Browser\Bridge\Send + + Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send\Arg + @@ -240,5 +249,11 @@ Connector\Interface\Browser\Bridge\Send + + Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send\Arg + \ No newline at end of file From 7393fac4377d9f04949ccecc1725c6c55c9c316c Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Mon, 9 Sep 2024 13:07:05 +0100 Subject: [PATCH 12/12] Version bump --- SpeckleConnector/Connector/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpeckleConnector/Connector/Version.h b/SpeckleConnector/Connector/Version.h index 54239e7..5c79e01 100644 --- a/SpeckleConnector/Connector/Version.h +++ b/SpeckleConnector/Connector/Version.h @@ -7,7 +7,7 @@ namespace connector { static const unsigned int versionMinor = 2; - static const unsigned int versionPatch = 1; + static const unsigned int versionPatch = 2; }