diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/GetDocumentState.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/GetDocumentState.cpp index ed812b5..d57c177 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/GetDocumentState.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Base/GetDocumentState.cpp @@ -1,7 +1,6 @@ #include "Connector/Interface/Browser/Bridge/Base/GetDocumentState.h" #include "Active/Serialise/CargoHold.h" -#include "Active/Serialise/Package/Wrapper/ContainerWrap.h" #include "Connector/Connector.h" #include "Connector/Record/Model/ModelCard.h" #include "Connector/Database/ModelCardDatabase.h" diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendObject.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendObject.cpp index 94666e6..7b8eb71 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendObject.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Send/Arg/SendObject.cpp @@ -1,17 +1,9 @@ -#include "Connector/Interface/Browser/Bridge/Send/Send.h" +#include "Connector/Interface/Browser/Bridge/Send/Arg/SendObject.h" -#include "Active/Serialise/CargoHold.h" -#include "Active/Serialise/Package/Wrapper/PackageWrap.h" -#include "Connector/Connector.h" -#include "Connector/ConnectorResource.h" -#include "Connector/Database/ModelCardDatabase.h" -#include "Speckle/Interface/Browser/Bridge/BrowserBridge.h" -#include "Speckle/Serialise/Detached/Storage/DetachedMemoryStore.h" -#include "Speckle/Utility/Exception.h" +#include "Active/Serialise/Package/Wrapper/ContainerWrap.h" using namespace active::serialise; using namespace connector::interfac::browser::bridge; -using namespace speckle::database; using namespace speckle::serialise; using namespace speckle::utility; @@ -19,55 +11,17 @@ namespace { ///Serialisation fields enum FieldIndex { - errorID, - cardID, + idID, + totChildID, + batchesID, }; ///Serialisation field IDs static std::array fieldID = { Identity{"error"}, - Identity{"modelCardId"}, + Identity{"totalChildrenCount"}, + Identity{"batches"}, }; - - /*! - A send error to return to the JS in the event of an error - */ - class SendError final : public active::serialise::Package { - public: - - // MARK: - Constructors - - /*! - Constructor - @param errMess The error message - @param card The ID of the model card associated with the wrror - */ - SendError(const String& errMess, const String& card) : message{errMess}, modelCardID{card} {} - - // MARK: - Public variables - - ///The error message - String message; - ///The ID of the model card associated with the data - String modelCardID; - - // 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; - }; - - } @@ -78,16 +32,17 @@ namespace { return: True if the package has added items to the inventory --------------------------------------------------------------------*/ -bool SendError::fillInventory(active::serialise::Inventory& inventory) const { +bool SendObject::fillInventory(active::serialise::Inventory& inventory) const { using enum Entry::Type; inventory.merge(Inventory{ { - { fieldID[errorID], errorID, element }, - { fieldID[cardID], cardID, element }, + { fieldID[idID], idID, element }, + { fieldID[totChildID], totChildID, element }, + { fieldID[batchesID], batchesID, element }, }, - }.withType(&typeid(SendError))); + }.withType(&typeid(SendObject))); return true; -} //SendError::fillInventory +} //SendObject::fillInventory /*-------------------------------------------------------------------- @@ -97,50 +52,18 @@ bool SendError::fillInventory(active::serialise::Inventory& inventory) const { return: The requested cargo (nullptr on failure) --------------------------------------------------------------------*/ -Cargo::Unique SendError::getCargo(const active::serialise::Inventory::Item& item) const { - if (item.ownerType != &typeid(SendError)) +Cargo::Unique SendObject::getCargo(const active::serialise::Inventory::Item& item) const { + if (item.ownerType != &typeid(SendObject)) return nullptr; using namespace active::serialise; switch (item.index) { - case errorID: - return std::make_unique>(message); - case cardID: - return std::make_unique>(modelCardID); + case idID: + return std::make_unique(id); + case totChildID: + return std::make_unique(totalChildrenCount); + case batchesID: + return std::make_unique>>(batches); default: return nullptr; //Requested an unknown index } -} //SendError::getCargo - - -/*-------------------------------------------------------------------- - Default constructor - --------------------------------------------------------------------*/ -Send::Send() : BridgeMethod{"Send", [&](const SendArgs& args) { - run(args); -}} {} - - -/*-------------------------------------------------------------------- - Send a specified model - - modelCardID: The ID of the model to send - --------------------------------------------------------------------*/ -void Send::run(const String& modelCardID) const { - //Find the specified model card - auto modelCardDatabase = connector()->getModelCardDatabase(); - auto modelCard = modelCardDatabase->getCard(modelCardID); - if (!modelCard) { - getBridge()->sendEvent("setModelError", - std::make_unique(connector()->getLocalString(errorString, modelCardNotFoundID), modelCardID)); - return; - } - //Get the active project - auto project = connector()->getActiveProject().lock(); - if (!project) { - getBridge()->sendEvent("setModelError", - std::make_unique(connector()->getLocalString(errorString, noProjectOpenID), modelCardID)); - return; - } - - DetachedMemoryStore detachedObjects; -} //Send::run +} //SendObject::getCargo