diff --git a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Attribute/ArchicadAttributeDBaseEngine.h b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Attribute/ArchicadAttributeDBaseEngine.h index 8955772..454172b 100644 --- a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Attribute/ArchicadAttributeDBaseEngine.h +++ b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Attribute/ArchicadAttributeDBaseEngine.h @@ -51,6 +51,15 @@ namespace speckle::database { // MARK: - Functions (const) + /*! + Find a filtered list of objects + @param filter The object filter (nullptr = find all objects) + @param tableID Optional table ID (defaults to the first table) + @param documentID Optional document ID (filter for this document only - nullopt = all objects) + @return A list containing IDs of found elements (empty if none found) + */ + virtual std::vector findObjects(const Filter& filter = nullptr, std::optional tableID = std::nullopt, + std::optional documentID = std::nullopt) const override { return {}; } //Implement when required /*! Get an object by ID @param objID The object ID @@ -64,7 +73,7 @@ namespace speckle::database { @param objID The object ID @param tableID Optional table ID (defaults to the floor plan) @param documentID Optional document ID (when the object is bound to a specific document) - @return: The requested wrapped cargo (nullptr on failure) + @return The requested wrapped cargo (nullptr on failure) */ active::serialise::Cargo::Unique getObjectCargo(const BIMRecordID& objID, std::optional tableID = std::nullopt, std::optional documentID = std::nullopt) const override; /*! diff --git a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.cpp b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.cpp index 055dbd5..9d73d60 100644 --- a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.cpp +++ b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.cpp @@ -162,6 +162,32 @@ void ArchicadElementDBaseEngine::clearSelection() const { } //ArchicadElementDBaseEngine::clearSelection +/*-------------------------------------------------------------------- + Find a filtered list of objects + + filter: The object filter (nullptr = find all objects) + tableID: Optional table ID (defaults to the first table) + documentID: Optional document ID (filter for this document only - nullopt = all objects) + + return: A list containing IDs of found elements (empty if none found) + --------------------------------------------------------------------*/ +std::vector ArchicadElementDBaseEngine::findObjects(const Filter& filter, std::optional tableID, + std::optional documentID) const { + //First check for no filter (in which case we return all objects) + if (filter == nullptr) { + GS::Array found; + if ((ACAPI_Element_GetElemList({}, &found) != NoError) || found.IsEmpty()) + return {}; + std::vector result; + for (const auto& item : found) + result.emplace_back(item); + return result; + } + //Implement other filtering as required - ideally identify characteristics supported by API, e.g. filter by type/renovation etc + return {}; +} //ArchicadElementDBaseEngine::findObjects + + /*-------------------------------------------------------------------- Get an object by index @@ -229,7 +255,19 @@ active::container::Vector ArchicadElementDBaseEngine::getObjects(std::o std::optional documentID) const { if (tableID) setActiveTable(*tableID); - return {}; //TODO: Implement + else { + //Use the active table if none is specified + tableID = getActiveTable(); + if (!tableID) + return {}; + } + //Retrieve the element objects to build the result + active::container::Vector result; + auto objectIDs = findObjects(); + for (const auto& ID : objectIDs) + if (auto element = getObject(ID, tableID); element) + result.emplace_back(std::move(element)); + return result; } //ArchicadElementDBaseEngine::getObjects diff --git a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.h b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.h index d668615..18101d1 100644 --- a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.h +++ b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Element/ArchicadElementDBaseEngine.h @@ -66,6 +66,15 @@ namespace speckle::database { Clear the element selection */ void clearSelection() const; + /*! + Find a filtered list of objects + @param filter The object filter (nullptr = find all objects) + @param tableID Optional table ID (defaults to the first table) + @param documentID Optional document ID (filter for this document only - nullopt = all objects) + @return A list containing IDs of found elements (empty if none found) + */ + virtual std::vector findObjects(const Filter& filter = nullptr, std::optional tableID = std::nullopt, + std::optional documentID = std::nullopt) const override; /*! Get an object by index @param objID The object ID @@ -79,7 +88,7 @@ namespace speckle::database { @param objID The object ID @param tableID Optional table ID (defaults to the floor plan) @param documentID Optional document ID (when the object is bound to a specific document) - @return: The requested wrapped cargo (nullptr on failure) + @return The requested wrapped cargo (nullptr on failure) */ active::serialise::Cargo::Unique getObjectCargo(const BIMRecordID& objID, std::optional tableID = std::nullopt, std::optional documentID = std::nullopt) const override; /*! diff --git a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadGroupDBaseEngine.h b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadGroupDBaseEngine.h index e6f8f1a..92fc16b 100644 --- a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadGroupDBaseEngine.h +++ b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadGroupDBaseEngine.h @@ -46,6 +46,15 @@ namespace speckle::database { // MARK: - Functions (const) + /*! + Find a filtered list of objects + @param filter The object filter (nullptr = find all objects) + @param tableID Optional table ID (defaults to the first table) + @param documentID Optional document ID (filter for this document only - nullopt = all objects) + @return A list containing IDs of found elements (empty if none found) + */ + virtual std::vector findObjects(const Filter& filter = nullptr, std::optional tableID = std::nullopt, + std::optional documentID = std::nullopt) const override { return {}; } //Implement when required /*! Get an object by ID @param objID The object ID @@ -59,7 +68,7 @@ namespace speckle::database { @param objID The object ID @param tableID Optional table ID (default selected based on record type) @param documentID Optional document ID (when the object is bound to a specific document) - @return: The requested wrapped cargo (nullptr on failure) + @return The requested wrapped cargo (nullptr on failure) */ active::serialise::Cargo::Unique getObjectCargo(const BIMRecordID& objID, std::optional tableID = std::nullopt, std::optional documentID = std::nullopt) const override; /*! diff --git a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadPropertyDBaseEngine.h b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadPropertyDBaseEngine.h index 4b61612..a681ca5 100644 --- a/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadPropertyDBaseEngine.h +++ b/SpeckleLib/Speckle/Database/Storage/ArchicadDBase/Property/ArchicadPropertyDBaseEngine.h @@ -47,6 +47,15 @@ namespace speckle::database { // MARK: - Functions (const) + /*! + Find a filtered list of objects + @param filter The object filter (nullptr = find all objects) + @param tableID Optional table ID (defaults to the first table) + @param documentID Optional document ID (filter for this document only - nullopt = all objects) + @return A list containing IDs of found elements (empty if none found) + */ + virtual std::vector findObjects(const Filter& filter = nullptr, std::optional tableID = std::nullopt, + std::optional documentID = std::nullopt) const override { return {}; } //Implement when required /*! Find all property templates linked to specified classifications @param classifications The classifications @@ -66,7 +75,7 @@ namespace speckle::database { @param objID The object ID @param tableID Optional table ID (default selected based on record type) @param documentID Optional document ID (when the object is bound to a specific document) - @return: The requested wrapped cargo (nullptr on failure) + @return The requested wrapped cargo (nullptr on failure) */ active::serialise::Cargo::Unique getObjectCargo(const BIMRecordID& objID, std::optional tableID = std::nullopt, std::optional documentID = std::nullopt) const override; /*! diff --git a/SpeckleLib/Speckle/Database/Storage/DocumentStore/DocumentStoreEngine.h b/SpeckleLib/Speckle/Database/Storage/DocumentStore/DocumentStoreEngine.h index 1d92a70..ef91e3e 100644 --- a/SpeckleLib/Speckle/Database/Storage/DocumentStore/DocumentStoreEngine.h +++ b/SpeckleLib/Speckle/Database/Storage/DocumentStore/DocumentStoreEngine.h @@ -59,6 +59,15 @@ namespace speckle::database { // MARK: - Functions (const) + /*! + Find a filtered list of objects + @param filter The object filter (nullptr = find all objects) + @param tableID Optional table ID (defaults to the first table) + @param documentID Optional document ID (filter for this document only - nullopt = all objects) + @return A list containing IDs of found elements (empty if none found) + */ + virtual std::vector findObjects(const Filter& filter = nullptr, std::optional tableID = std::nullopt, + std::optional documentID = std::nullopt) const override { return {}; } //Implement when required /*! Get an object by index @param ID The object ID @@ -72,7 +81,7 @@ namespace speckle::database { @param ID The object ID @param tableID Optional table ID (defaults to the first table) @param documentID Optional document ID (when the object is bound to a specific document) - @return: The requested wrapped cargo (nullptr on failure) + @return The requested wrapped cargo (nullptr on failure) */ active::serialise::Cargo::Unique getObjectCargo(const ObjID& objID, std::optional tableID = std::nullopt, std::optional documentID = std::nullopt) const override; /*! diff --git a/SpeckleLib/Speckle/Serialise/Collection/FinishProxy.h b/SpeckleLib/Speckle/Serialise/Collection/FinishProxy.h index b9c0dfd..1e3fa8a 100644 --- a/SpeckleLib/Speckle/Serialise/Collection/FinishProxy.h +++ b/SpeckleLib/Speckle/Serialise/Collection/FinishProxy.h @@ -27,7 +27,7 @@ namespace speckle::serialise { /*! 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 + @return True if the package has added items to the inventory */ bool fillInventory(active::serialise::Inventory& inventory) const { //NB: This object only exists to populate the finish collection - it doesn't carry any serialisable content diff --git a/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj b/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj index 4b240b0..c65f283 100644 --- a/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj +++ b/SpeckleLib/SpeckleLib.xcodeproj/project.pbxproj @@ -35,14 +35,14 @@ 21384C002CD558D100D4602B /* Slab.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BFE2CD558D000D4602B /* Slab.h */; }; 21384C032CD57CA500D4602B /* Wall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384C012CD57CA500D4602B /* Wall.cpp */; }; 21384C042CD57CA500D4602B /* Wall.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384C022CD57CA500D4602B /* Wall.h */; }; - 21384C072CD57EE600D4602B /* Mesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384C052CD57EE600D4602B /* Mesh.cpp */; }; - 21384C082CD57EE600D4602B /* Mesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384C062CD57EE600D4602B /* Mesh.h */; }; 21384C182CD585A600D4602B /* Roof.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384C162CD585A600D4602B /* Roof.cpp */; }; 21384C192CD585A600D4602B /* Roof.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384C172CD585A600D4602B /* Roof.h */; }; 21384C1C2CD586D800D4602B /* Morph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384C1A2CD586D800D4602B /* Morph.cpp */; }; 21384C1D2CD586D800D4602B /* Morph.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384C1B2CD586D800D4602B /* Morph.h */; }; 21384C202CD5880400D4602B /* Shell.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384C1E2CD5880400D4602B /* Shell.h */; }; 21384C212CD5880400D4602B /* Shell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384C1F2CD5880400D4602B /* Shell.cpp */; }; + 21384C242CD59B4100D4602B /* MeshElem.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384C222CD59B4100D4602B /* MeshElem.h */; }; + 21384C252CD59B4100D4602B /* MeshElem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384C232CD59B4100D4602B /* MeshElem.cpp */; }; 215F08552C99DA8D00CD343B /* Project.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08512C99DA8D00CD343B /* Project.cpp */; }; 215F08562C99DA8D00CD343B /* Project.h in Headers */ = {isa = PBXBuildFile; fileRef = 215F08542C99DA8D00CD343B /* Project.h */; }; 215F08662C9B006800CD343B /* ProjectEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08652C9B006700CD343B /* ProjectEvent.cpp */; }; @@ -244,14 +244,14 @@ 21384BFE2CD558D000D4602B /* Slab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Slab.h; sourceTree = ""; }; 21384C012CD57CA500D4602B /* Wall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Wall.cpp; sourceTree = ""; }; 21384C022CD57CA500D4602B /* Wall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Wall.h; sourceTree = ""; }; - 21384C052CD57EE600D4602B /* Mesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mesh.cpp; path = Speckle/Record/Element/Mesh.cpp; sourceTree = SOURCE_ROOT; }; - 21384C062CD57EE600D4602B /* Mesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mesh.h; path = Speckle/Record/Element/Mesh.h; sourceTree = SOURCE_ROOT; }; 21384C162CD585A600D4602B /* Roof.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Roof.cpp; sourceTree = ""; }; 21384C172CD585A600D4602B /* Roof.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Roof.h; sourceTree = ""; }; 21384C1A2CD586D800D4602B /* Morph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Morph.cpp; sourceTree = ""; }; 21384C1B2CD586D800D4602B /* Morph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Morph.h; sourceTree = ""; }; 21384C1E2CD5880400D4602B /* Shell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shell.h; sourceTree = ""; }; 21384C1F2CD5880400D4602B /* Shell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shell.cpp; sourceTree = ""; }; + 21384C222CD59B4100D4602B /* MeshElem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeshElem.h; sourceTree = ""; }; + 21384C232CD59B4100D4602B /* MeshElem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeshElem.cpp; sourceTree = ""; }; 214EA4C52BA374FD008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 214EA4C62BA3762D008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = SOURCE_ROOT; }; 215F08512C99DA8D00CD343B /* Project.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Project.cpp; sourceTree = ""; }; @@ -554,8 +554,8 @@ 21A0FBE72CBD6B1A0023F24E /* Interface */, 21A0FBF32CBD6B700023F24E /* Memo.cpp */, 21A0FBF22CBD6B700023F24E /* Memo.h */, - 21384C052CD57EE600D4602B /* Mesh.cpp */, - 21384C062CD57EE600D4602B /* Mesh.h */, + 21384C232CD59B4100D4602B /* MeshElem.cpp */, + 21384C222CD59B4100D4602B /* MeshElem.h */, 21A0FC0C2CBE92F10023F24E /* ModelElement.cpp */, 21A0FC0D2CBE92F10023F24E /* ModelElement.h */, 21384C1A2CD586D800D4602B /* Morph.cpp */, @@ -1043,6 +1043,7 @@ 21A890C92CC1B5FF0087E732 /* DrawingElement.h in Headers */, 21D0BD562C890B1C0077E104 /* ServerMigration.h in Headers */, 210CC88F2C81A98500610F58 /* Guid64.h in Headers */, + 21384C242CD59B4100D4602B /* MeshElem.h in Headers */, 21AEF9DD2CAAA4EA000B8681 /* DetachedObjectStore.h in Headers */, 21A0FBF12CBD6B1A0023F24E /* Column.h in Headers */, 21AE19662CC2F702004DBCFC /* BIMPropertyDatabase.h in Headers */, @@ -1077,7 +1078,6 @@ 21AE19AA2CC8F1F8004DBCFC /* BeamSegment.h in Headers */, 21384BF12CD3F3A500D4602B /* MaterialWrap.h in Headers */, 21AE19942CC82866004DBCFC /* BIMGroupDatabase.h in Headers */, - 21384C082CD57EE600D4602B /* Mesh.h in Headers */, 21AE19542CC273F1004DBCFC /* Template.h in Headers */, 21A0FBBC2CBBC04C0023F24E /* ArchicadRGB.h in Headers */, 21384BFC2CD52C7500D4602B /* Conversion.h in Headers */, @@ -1246,9 +1246,9 @@ 21D0BD4E2C8901A00077E104 /* ServerInfo.cpp in Sources */, 21AE19512CC273F1004DBCFC /* Property.cpp in Sources */, 21384BED2CD3EBE200D4602B /* Material.cpp in Sources */, + 21384C252CD59B4100D4602B /* MeshElem.cpp in Sources */, 21B67D0E2C7E0E8D00FD64FC /* ErrorReport.cpp in Sources */, 21AE19902CC80541004DBCFC /* ArchicadGroupDBaseEngine.cpp in Sources */, - 21384C072CD57EE600D4602B /* Mesh.cpp in Sources */, 21AE19692CC57832004DBCFC /* Propertied.cpp in Sources */, 21F69F7E2C6FD9FC008B6A06 /* GetCallResult.cpp in Sources */, 2196F3052CB57E8000450DFC /* Storey.cpp in Sources */,