| 221 | |
| 222 | private: |
| 223 | void AddDeleteEventObserver() |
| 224 | { |
| 225 | if (nullptr != m_RawPointer) |
| 226 | { |
| 227 | auto command = itk::SimpleMemberCommand<WeakPointer>::New(); |
| 228 | command->SetCallbackFunction(this, &WeakPointer::OnDeleteEvent); |
| 229 | |
| 230 | using TWithoutConst = typename std::remove_const_t<T>; |
| 231 | //cast the pointer to non const before adding the observer. This is done to ensure that |
| 232 | //weak pointer also supports const pointers. |
| 233 | auto nonConstPointer = const_cast<TWithoutConst*>(m_RawPointer); |
| 234 | m_ObserverTag = nonConstPointer->AddObserver(itk::DeleteEvent(), command); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | void RemoveDeleteEventObserver() |
| 239 | { |
no test coverage detected