Hello, everyone. I work with ITK at my day job. Upon inspection into the header of itkObject, I noticed there is a const API available for AddObserver but not for RemoveObserver. Since both APIs internally just call the mutable m_SubjectImplementation’s RemoveObserver(), would it make sense to provide a const version of the RemoveObserver API just like AddObserver()?
Here’s a patch, if you’d like to accept the proposal:-
index 3a63ffaa45..f2ba3d7dd5 100644
--- a/Modules/Core/Common/src/itkObject.cxx
+++ b/Modules/Core/Common/src/itkObject.cxx
@@ -494,6 +494,13 @@ Object::GetCommand(unsigned long tag)
void
Object::RemoveObserver(unsigned long tag)
+{
+ const auto & thisAsConst = *this;
+ return thisAsConst.RemoveObserver(tag);
+}
+
+void
+Object::RemoveObserver(unsigned long tag) const
{
if (this->m_SubjectImplementation)
{
this->m_SubjectImplementation->RemoveObserver(tag);
}
}