From 9acc058f078dfdb4bfacf9b8a01ec976169ecf65 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Sun, 8 Sep 2024 23:01:22 +0100 Subject: [PATCH] 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