diff --git a/SpeckleConnector/Connector.vcxproj b/SpeckleConnector/Connector.vcxproj index 11d3c20..355ea9f 100644 --- a/SpeckleConnector/Connector.vcxproj +++ b/SpeckleConnector/Connector.vcxproj @@ -106,7 +106,11 @@ + + + + @@ -134,7 +138,11 @@ + + + + diff --git a/SpeckleConnector/Connector.vcxproj.filters b/SpeckleConnector/Connector.vcxproj.filters index b28e1ac..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} + @@ -149,6 +152,16 @@ Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send\Arg + @@ -232,5 +245,15 @@ Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send + + + Connector\Interface\Browser\Bridge\Send\Arg + \ No newline at end of file diff --git a/SpeckleConnector/Connector.xcodeproj/project.pbxproj b/SpeckleConnector/Connector.xcodeproj/project.pbxproj index f66fa1a..028a510 100644 --- a/SpeckleConnector/Connector.xcodeproj/project.pbxproj +++ b/SpeckleConnector/Connector.xcodeproj/project.pbxproj @@ -43,6 +43,11 @@ 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 */; }; + 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 */; }; @@ -307,6 +312,15 @@ 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 = ""; }; + 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 = ""; }; + 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 = ""; }; @@ -874,6 +888,7 @@ 219F30412C769282009834E9 /* ConnectorTests */ = { isa = PBXGroup; children = ( + 21D0BD642C89D7400077E104 /* AccountTests.cpp */, 219F30402C769282009834E9 /* ConfigTests.cpp */, 219F30432C7693B6009834E9 /* Connector-AC27-Debug.xctestplan */, ); @@ -973,12 +988,26 @@ 21D0BD5D2C89BFEA0077E104 /* Send */ = { isa = PBXGroup; children = ( + 21D0BD9A2C8F154B0077E104 /* Arg */, + 21D0BD962C8F13F30077E104 /* GetSendFilters.cpp */, + 21D0BD952C8F13F30077E104 /* GetSendFilters.h */, + 21D0BD8D2C8EE4490077E104 /* Send.cpp */, + 21D0BD8A2C8EE4490077E104 /* Send.h */, 21D0BD5B2C89BFEA0077E104 /* SendBridge.cpp */, 21D0BD5C2C89BFEA0077E104 /* SendBridge.h */, ); path = Send; sourceTree = ""; }; + 21D0BD9A2C8F154B0077E104 /* Arg */ = { + isa = PBXGroup; + children = ( + 21D0BD982C8F154B0077E104 /* SendFilter.cpp */, + 21D0BD992C8F154B0077E104 /* SendFilter.h */, + ); + path = Arg; + sourceTree = ""; + }; 21D1EA472BF14B6C00957EAA /* Archicad */ = { isa = PBXGroup; children = ( @@ -1082,6 +1111,8 @@ 21F69FB52C762EF0008B6A06 /* ConfigBridge.h */, 21F69FB62C762EF0008B6A06 /* GetConfig.cpp */, 21F69FB72C762EF0008B6A06 /* GetConfig.h */, + 21D0BD682C8A0DB40077E104 /* GetIsDevMode.cpp */, + 21D0BD692C8A0DB40077E104 /* GetIsDevMode.h */, 21F69FBD2C7630B3008B6A06 /* UpdateConfig.cpp */, 21F69FBE2C7630B3008B6A06 /* UpdateConfig.h */, ); @@ -1296,11 +1327,15 @@ 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 */, 21B67CEB2C78D27200FD64FC /* DocumentInfo.cpp in Sources */, 21B67CB92C774BFA00FD64FC /* GetConnectorVersion.cpp in Sources */, @@ -1325,6 +1360,7 @@ buildActionMask = 2147483647; files = ( 219F30422C769283009834E9 /* ConfigTests.cpp in Sources */, + 21D0BD672C89D7410077E104 /* AccountTests.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/SpeckleConnector/Connector/Connector.cpp b/SpeckleConnector/Connector/Connector.cpp index 1cc1645..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) @@ -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 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/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/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.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/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 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/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/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..d4180e6 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/SendBridge.cpp @@ -1,5 +1,8 @@ #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; /*-------------------------------------------------------------------- @@ -7,4 +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/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/Connector/Interface/ConnectorPalette.cpp b/SpeckleConnector/Connector/Interface/ConnectorPalette.cpp index 8c48f37..53c0ab8 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/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; } diff --git a/SpeckleConnector/ConnectorTests/AccountTests.cpp b/SpeckleConnector/ConnectorTests/AccountTests.cpp new file mode 100644 index 0000000..2872613 --- /dev/null +++ b/SpeckleConnector/ConnectorTests/AccountTests.cpp @@ -0,0 +1,41 @@ +#include "ActiveLibDoctest/TestingPlatforms.h" + +#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; +using namespace active::serialise::json; +using namespace active::serialise::json; +using namespace speckle::record::cred; +using namespace speckle::utility; + +namespace { + + 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}}}"; +} + + +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 { + 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 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/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 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" 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