| 24 | namespace detail { |
| 25 | |
| 26 | ComponentWatcher_Impl::ComponentWatcher_Impl(ComponentData& componentData) : m_componentData(componentData) { |
| 27 | // get componentObjects and connect signals |
| 28 | ModelObject_ImplPtr implPtr; |
| 29 | if (componentData.numComponentObjects() < 1) { |
| 30 | LOG_AND_THROW("Invalid ComponentData object--no objects listed in contents."); |
| 31 | } |
| 32 | for (unsigned i = 0, n = componentData.numComponentObjects(); i < n; ++i) { |
| 33 | // get object |
| 34 | OptionalModelObject omo = componentData.getComponentObject(i); |
| 35 | if (!omo) { |
| 36 | LOG_AND_THROW("Invalid ComponentData object--blank entry in contents list."); |
| 37 | } |
| 38 | ModelObject object = *omo; |
| 39 | m_componentObjects.push_back(object); |
| 40 | // connect to object's signals |
| 41 | implPtr = object.getImpl<ModelObject_Impl>(); |
| 42 | // data change |
| 43 | implPtr.get()->ModelObject_Impl::onDataChange.connect<ComponentWatcher_Impl, &ComponentWatcher_Impl::dataChange>(this); |
| 44 | // name change |
| 45 | implPtr.get()->ModelObject_Impl::onNameChange.connect<ComponentWatcher_Impl, &ComponentWatcher_Impl::nameChange>(this); |
| 46 | // relationship change |
| 47 | implPtr.get()->ModelObject_Impl::onRelationshipChange.connect<ComponentWatcher_Impl, &ComponentWatcher_Impl::relationshipChange>(this); |
| 48 | // remove |
| 49 | implPtr.get()->ModelObject_Impl::onRemoveFromWorkspace.connect<ComponentWatcher_Impl, &ComponentWatcher_Impl::objectRemove>(this); |
| 50 | } |
| 51 | // connect signals for ComponentData, ComponentDataTags, and ComponentDataAttributes |
| 52 | implPtr = componentData.getImpl<ModelObject_Impl>(); |
| 53 | // component data change |
| 54 | implPtr.get()->ModelObject_Impl::onDataChange.connect<ComponentWatcher_Impl, &ComponentWatcher_Impl::componentDataChange>(this); |
| 55 | // component data remove |
| 56 | implPtr.get()->ModelObject_Impl::onRemoveFromWorkspace.connect<ComponentWatcher_Impl, &ComponentWatcher_Impl::objectRemove>(this); |
| 57 | // connect to addWorkspaceObject signal |
| 58 | std::shared_ptr<Model_Impl> modelImplPtr = m_componentData.model().getImpl<Model_Impl>(); |
| 59 | modelImplPtr.get()->Model_Impl::addWorkspaceObject.connect<ComponentWatcher_Impl, &ComponentWatcher_Impl::objectAdd>(this); |
| 60 | } |
| 61 | |
| 62 | ComponentWatcher ComponentWatcher_Impl::componentWatcher() const { |
| 63 | ComponentWatcher result(std::const_pointer_cast<ComponentWatcher_Impl>(shared_from_this())); |
nothing calls this directly
no test coverage detected