Simplified add/install syntax

This commit is contained in:
Ralph Wessel
2024-09-08 23:01:22 +01:00
parent c14e3ac095
commit 9acc058f07
3 changed files with 14 additions and 7 deletions
+2 -2
View File
@@ -27,8 +27,8 @@ namespace {
class ConnectorInstance : public ConnectorAddon {
public:
ConnectorInstance(const String& name) : ConnectorAddon{name} {
add(std::make_shared<ConnectorMenu>());
add(std::make_shared<ConnectorPalette>());
add<ConnectorMenu>();
add<ConnectorPalette>();
}
// MARK: Functions (const)
@@ -163,11 +163,11 @@ BrowserPalette::BrowserPalette() :
Attach(*this);
BeginEventProcessing();
//Install required connector bridges
install(std::make_shared<AccountBridge>());
install(std::make_shared<BaseBridge>());
install(std::make_shared<ConfigBridge>());
//install(std::make_shared<SendBridge>());
install(std::make_shared<TestBridge>());
install<AccountBridge>();
install<BaseBridge>();
install<ConfigBridge>();
//install<SendBridge>();
install<TestBridge>();
InitBrowserControl();
}
@@ -49,6 +49,13 @@ namespace speckle::interfac::browser {
@return True if the object was successfully installed
*/
bool install(std::shared_ptr<JSObject<FunctionBinding>> object);
/*!
Install a JS function object
@return True if the object was successfully installed
@tparam T The type of object to install
*/
template<typename T> requires std::is_base_of_v<JSObject<FunctionBinding>, T>
bool install() { return install(std::make_shared<T>()); }
protected:
#ifdef ARCHICAD