Fixes to Column and ColumnSegment classes

This commit is contained in:
Ralph Wessel
2024-10-15 23:05:07 +01:00
parent ffb9cf0cef
commit 2d23eb6b28
8 changed files with 51 additions and 8 deletions
@@ -40,7 +40,7 @@ bool Record::fillInventory(active::serialise::Inventory& inventory) const {
}.withType(&typeid(base)));
inventory.merge(Inventory{
{
{ Identity{fieldID[speckleTypeID]}, speckleTypeID, element },
{ Identity{fieldID[speckleTypeID]}, speckleTypeID, attribute },
},
}.withType(&typeid(Record)));
return true;
@@ -137,8 +137,11 @@ std::unique_ptr<Element> ArchicadElementDBaseEngine::getObject(const BIMRecordID
uint64_t filter = documentID ? Guid::toInt(*documentID) : APIMemoMask_All;
if (auto err = ACAPI_Element_GetMemo(ID, memo.get(), filter); err != NoError)
ACAPI_DisposeElemMemoHdls(memo.get());
else
return std::make_unique<Memo>(std::move(memo));
else {
auto result = std::make_unique<Memo>();
result->set(std::move(memo));
return result;
}
}
if (!tableID) {
//Use the active table if none is specified
@@ -86,6 +86,16 @@ ColumnSegment::ColumnSegment(const ColumnSegment& source) : base{ source } {
} //ColumnSegment::ColumnSegment
/*--------------------------------------------------------------------
Move constructor
source: The object to move
--------------------------------------------------------------------*/
ColumnSegment::ColumnSegment(ColumnSegment&& source) : base{source} {
m_data = std::move(source.m_data);
} //ColumnSegment::ColumnSegment
/*--------------------------------------------------------------------
Destructor
--------------------------------------------------------------------*/
@@ -45,6 +45,11 @@ namespace speckle::record::element {
@param source The object to copy
*/
ColumnSegment(const ColumnSegment& source);
/*!
Move constructor
@param source The object to move
*/
ColumnSegment(ColumnSegment&& source);
/*!
Destructor
*/
+11 -2
View File
@@ -87,6 +87,16 @@ Element::Element(const Element& source) : base{ source } {
} //Element::Element
/*--------------------------------------------------------------------
Move constructor
source: The object to move
--------------------------------------------------------------------*/
Element::Element(Element&& source) : base{source} {
m_data = std::move(source.m_data);
} //Element::Element
/*--------------------------------------------------------------------
Destructor
--------------------------------------------------------------------*/
@@ -277,8 +287,7 @@ void Element::loadMemo(Part::filter_bits filter, std::unique_ptr<Memo>& memo) co
auto project = addon()->getActiveProject().lock();
if (!project)
return;
auto elementDatabase = project->getElementDatabase();
if (auto loaded = elementDatabase->getMemo(getBIMID(), filter); loaded)
if (auto loaded = project->getElementDatabase()->getMemo(getBIMID(), filter); loaded)
memo.reset(loaded.release());
}
} //Element::loadMemo
@@ -52,6 +52,11 @@ namespace speckle::record::element {
@param source The object to copy
*/
Element(const Element& source);
/*!
Move constructor
@param source The object to move
*/
Element(Element&& source);
/*!
Destructor
*/
@@ -131,7 +131,7 @@ bool SegmentedColumn::receive(const Memo& memo) const {
auto cutPtr = memo.root()->assemblySegmentCuts;
auto schemePtr = memo.root()->assemblySegmentSchemes;
auto profilePtr = memo.root()->assemblySegmentProfiles;
if ((segmentPtr == nullptr) || (cutPtr == nullptr) || (schemePtr == nullptr) || (profilePtr == nullptr))
if ((segmentPtr == nullptr) || (cutPtr == nullptr) || (schemePtr == nullptr))
return false;
//Determine available item count
auto segmentCount = BIMMemory::getPtrSize(segmentPtr) / sizeof(API_ColumnSegmentType);
@@ -149,7 +149,7 @@ bool SegmentedColumn::receive(const Memo& memo) const {
break;
}
}
m_data->segments.push_back({segmentPtr[n], getTableID(), cutPtr[n], cutPtr[n + 1], schemePtr[n], thisProfile});
m_data->segments.emplace_back(ColumnSegment{segmentPtr[n], getTableID(), cutPtr[n], cutPtr[n + 1], schemePtr[n], thisProfile});
m_data->segments.back().setPath(path);
}
setMemoLoaded(true);
+12 -1
View File
@@ -63,7 +63,18 @@ namespace speckle::record::element {
#endif
// MARK: - Functions (mutating)
#ifdef ARCHICAD
/*!
Get the memo root data
@return The memo root data (nullptr on failure)
*/
Memo& set(std::unique_ptr<API_ElementMemo> memo) {
m_data = std::move(memo);
return *this;
}
#endif
private:
#ifdef ARCHICAD
//NB: The following is functionally redundant for memos - requirement of base class