| 58 | } |
| 59 | |
| 60 | void WorkspaceObject_Impl::initializeOnAdd(bool expectToLosePointers) { |
| 61 | OS_ASSERT(m_workspace); |
| 62 | bool ptrsAsHandles = iddObject().hasHandleField(); |
| 63 | // loop through object list fields |
| 64 | UnsignedVector fields = objectListFields(); |
| 65 | for (unsigned index : fields) { |
| 66 | // determine if field should be managed |
| 67 | OptionalIddField iddField = iddObject().getField(index); |
| 68 | OS_ASSERT(iddField); |
| 69 | |
| 70 | // for each one, try to match targetName |
| 71 | std::string targetName = IdfObject_Impl::getString(index).get(); |
| 72 | if (targetName.empty()) { // set null pointer |
| 73 | setPointerImpl(index, Handle()); |
| 74 | continue; |
| 75 | } |
| 76 | |
| 77 | // look for target |
| 78 | Handle targetHandle; |
| 79 | if (ptrsAsHandles) { |
| 80 | targetHandle = toUUID(targetName); |
| 81 | if (!workspace().isMember(targetHandle)) { |
| 82 | if (!expectToLosePointers) { |
| 83 | LOG(Trace, "Field " << index << " of '" << iddObject().name() << "' object points to an object with handle " << toString(targetHandle) |
| 84 | << ", but there is not object with that handle in the Workspace. Will try to " << "interpret as a name."); |
| 85 | } |
| 86 | targetHandle = Handle(); |
| 87 | } |
| 88 | } |
| 89 | if (targetHandle.isNull()) { |
| 90 | StringSet intermediate = iddObject().objectLists(index); |
| 91 | StringVector referenceLists(intermediate.begin(), intermediate.end()); |
| 92 | OptionalWorkspaceObject target = m_workspace->getObjectByNameAndReference(targetName, referenceLists); |
| 93 | if (target) { |
| 94 | targetHandle = target->handle(); |
| 95 | } |
| 96 | } |
| 97 | setPointerImpl(index, targetHandle); |
| 98 | if (targetHandle.isNull()) { |
| 99 | if (!expectToLosePointers) { |
| 100 | LOG(Warn, briefDescription() << ", points to an object named " << targetName << " from field " << index |
| 101 | << ", but that object cannot be located."); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | void WorkspaceObject_Impl::initializeOnClone(const HandleMap& oldNewHandleMap) { |
| 108 | OS_ASSERT(m_workspace); |
no test coverage detected