Skip to content

Commit

Permalink
STYLE: Do "const" iteration over Object::SubjectImplementation observers
Browse files Browse the repository at this point in the history
Added "const" to iterations over those observers, as the data of each `Observer`
is meant to remain unmodified during those iterations.
  • Loading branch information
N-Dekker authored and dzenanz committed Sep 23, 2022
1 parent 2a18aab commit 090cb23
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Modules/Core/Common/src/itkObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ITKCommon_HIDDEN Object::SubjectImplementation

template <typename TObject>
void
InvokeEventRecursion(const EventObject & event, TObject * self, std::list<Observer>::reverse_iterator & i);
InvokeEventRecursion(const EventObject & event, TObject * self, std::list<Observer>::const_reverse_iterator & i);

std::list<Observer> m_Observers;
unsigned long m_Count;
Expand Down Expand Up @@ -156,7 +156,7 @@ Object::SubjectImplementation::InvokeEvent(const EventObject & event, Object * s

SaveRestoreListModified save(this);

auto i = m_Observers.rbegin();
auto i = m_Observers.crbegin();
InvokeEventRecursion(event, self, i);
}

Expand All @@ -165,15 +165,15 @@ Object::SubjectImplementation::InvokeEvent(const EventObject & event, const Obje
{
SaveRestoreListModified save(this);

auto i = m_Observers.rbegin();
auto i = m_Observers.crbegin();
InvokeEventRecursion(event, self, i);
}

template <typename TObject>
void
Object::SubjectImplementation::InvokeEventRecursion(const EventObject & event,
TObject * self,
std::list<Observer>::reverse_iterator & i)
Object::SubjectImplementation::InvokeEventRecursion(const EventObject & event,
TObject * self,
std::list<Observer>::const_reverse_iterator & i)
{
// This method recursively visits the list of observers in reverse
// order so that on the last recursion the first observer can be
Expand Down Expand Up @@ -216,7 +216,7 @@ Object::SubjectImplementation::InvokeEventRecursion(const EventObject &
Command *
Object::SubjectImplementation::GetCommand(unsigned long tag)
{
for (auto & observer : m_Observers)
for (const auto & observer : m_Observers)
{
if (observer.m_Tag == tag)
{
Expand Down

0 comments on commit 090cb23

Please sign in to comment.