MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getEquivalentObject

Method getEquivalentObject

src/utilities/idf/Workspace.cpp:1849–1883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1847 }
1848
1849 boost::optional<WorkspaceObject> Workspace_Impl::getEquivalentObject(const IdfObject& other) const {
1850 // never overwrite existing version object
1851 if (other.iddObject().isVersionObject()) {
1852 return versionObject();
1853 }
1854
1855 // get candidates by type and name
1856 OptionalString oName = other.name();
1857 WorkspaceObjectVector candidates;
1858 if (oName && !oName->empty()) {
1859 OptionalWorkspaceObject owo = getObjectByTypeAndName(other.iddObject().type(), *oName);
1860 if (owo) {
1861 candidates.push_back(*owo);
1862 }
1863 } else {
1864 candidates = getObjectsByType(other.iddObject().type());
1865 }
1866
1867 // test for equivalency
1868 OptionalWorkspaceObject result;
1869 OptionalWorkspaceObject wsOther = other.optionalCast<WorkspaceObject>();
1870 for (const WorkspaceObject& candidate : candidates) {
1871 if (wsOther) {
1872 if (candidate.dataFieldsEqual(*wsOther) && candidate.objectListFieldsNonConflicting(*wsOther)) {
1873 result = candidate;
1874 break;
1875 }
1876 } else if (other.dataFieldsEqual(candidate) && other.objectListFieldsNonConflicting(candidate)) {
1877 result = candidate;
1878 break;
1879 }
1880 }
1881
1882 return result;
1883 }
1884
1885 // SETTER HELPERS
1886

Callers

nothing calls this directly

Calls 8

isVersionObjectMethod · 0.80
iddObjectMethod · 0.80
dataFieldsEqualMethod · 0.80
nameMethod · 0.45
emptyMethod · 0.45
typeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected