Files
speckle-cpp-connectors/SpeckleConnector/Connector/Database/Model/Card/ModelCardDatabase.cpp
T
Ralph Wessel bd0be2bb42 Changed model card dagtabase tag to "models"
Minor namespace tweaks
2024-08-29 14:07:01 +01:00

72 lines
2.1 KiB
C++

#include "Connector/Database/Model/Card/ModelCardDatabase.h"
#include "Active/Serialise/CargoHold.h"
#include "Active/Serialise/Item/Wrapper/ValueWrap.h"
#include "Active/Serialise/Package/Wrapper/ValueSettingWrap.h"
#include "Active/Setting/ValueSetting.h"
#include <array>
using namespace active::serialise;
using namespace active::setting;
using namespace connector::database;
using namespace speckle::utility;
namespace {
///Serialisation fields
enum FieldIndex {
model,
};
///Serialisation field IDs
static std::array fieldID = {
Identity{"models"},
};
}
/*--------------------------------------------------------------------
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 ModelCardDatabase::fillInventory(Inventory& inventory) const {
using enum Entry::Type;
inventory.merge(Inventory{
{
{ fieldID[model], model, element },
},
}.withType(&typeid(ModelCardDatabase)));
return true;
} //ModelCardDatabase::fillInventory
/*--------------------------------------------------------------------
Get the specified cargo
item: The inventory item to retrieve
return: The requested cargo (nullptr on failure)
--------------------------------------------------------------------*/
Cargo::Unique ModelCardDatabase::getCargo(const Inventory::Item& item) const {
if (item.ownerType != &typeid(ModelCardDatabase))
return nullptr;
using namespace active::serialise;
switch (item.index) {
case model:
return std::make_unique<CargoHold<ValueSettingWrap, ValueSetting>>(); //NB: This is a placeholder until we define the content
default:
return nullptr; //Requested an unknown index
}
} //ModelCardDatabase::getCargo
/*--------------------------------------------------------------------
Set to the default package content
--------------------------------------------------------------------*/
void ModelCardDatabase::setDefault() {
} //ModelCardDatabase::setDefault