Skip to content

Commit

Permalink
STYLE: Make SubjectImplementation a private nested type of itk::Object
Browse files Browse the repository at this point in the history
Note that `SubjectImplementation` was already marked `ITKCommon_HIDDEN`. It is
just a private implementation detail of `itk::Object`.
  • Loading branch information
N-Dekker authored and dzenanz committed Sep 23, 2022
1 parent 1f3ec8c commit 4c0526e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions Modules/Core/Common/include/itkObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

namespace itk
{
// Forward reference because of private implementation
class SubjectImplementation;
// Forward reference because of circular dependencies
class ITK_FORWARD_EXPORT Command;

Expand Down Expand Up @@ -272,6 +270,9 @@ class ITKCommon_EXPORT Object : public LightObject
/** Global object debug flag. */
static bool * m_GlobalWarningDisplay;

// Forward reference because of private implementation
class SubjectImplementation;

/** Implementation class for Subject/Observer Pattern.
* This is only allocated if used. */
std::unique_ptr<SubjectImplementation> m_SubjectImplementation;
Expand Down
24 changes: 12 additions & 12 deletions Modules/Core/Common/src/itkObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ITKCommon_HIDDEN Observer
};
} // namespace

class ITKCommon_HIDDEN SubjectImplementation
class ITKCommon_HIDDEN Object::SubjectImplementation
{
public:
SubjectImplementation() { m_Count = 0; }
Expand Down Expand Up @@ -117,7 +117,7 @@ class ITKCommon_HIDDEN SubjectImplementation
};

unsigned long
SubjectImplementation::AddObserver(const EventObject & event, Command * cmd)
Object::SubjectImplementation::AddObserver(const EventObject & event, Command * cmd)
{
const unsigned long tag{ m_Count };
m_Observers.emplace_back(cmd, event.MakeObject(), tag);
Expand All @@ -126,7 +126,7 @@ SubjectImplementation::AddObserver(const EventObject & event, Command * cmd)
}

void
SubjectImplementation::RemoveObserver(unsigned long tag)
Object::SubjectImplementation::RemoveObserver(unsigned long tag)
{
for (auto i = m_Observers.begin(); i != m_Observers.end(); ++i)
{
Expand All @@ -140,14 +140,14 @@ SubjectImplementation::RemoveObserver(unsigned long tag)
}

void
SubjectImplementation::RemoveAllObservers()
Object::SubjectImplementation::RemoveAllObservers()
{
m_Observers.clear();
m_ListModified = true;
}

void
SubjectImplementation::InvokeEvent(const EventObject & event, Object * self)
Object::SubjectImplementation::InvokeEvent(const EventObject & event, Object * self)
{
// While an event is being invoked, it's possible to remove
// observers, or another event to be invoked. All methods which
Expand All @@ -162,7 +162,7 @@ SubjectImplementation::InvokeEvent(const EventObject & event, Object * self)
}

void
SubjectImplementation::InvokeEvent(const EventObject & event, const Object * self)
Object::SubjectImplementation::InvokeEvent(const EventObject & event, const Object * self)
{
SaveRestoreListModified save(this);

Expand All @@ -172,9 +172,9 @@ SubjectImplementation::InvokeEvent(const EventObject & event, const Object * sel

template <typename TObject>
void
SubjectImplementation::InvokeEventRecursion(const EventObject & event,
TObject * self,
std::list<Observer>::reverse_iterator & i)
Object::SubjectImplementation::InvokeEventRecursion(const EventObject & event,
TObject * self,
std::list<Observer>::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 @@ -215,7 +215,7 @@ SubjectImplementation::InvokeEventRecursion(const EventObject &
}

Command *
SubjectImplementation::GetCommand(unsigned long tag)
Object::SubjectImplementation::GetCommand(unsigned long tag)
{
for (auto & observer : m_Observers)
{
Expand All @@ -228,7 +228,7 @@ SubjectImplementation::GetCommand(unsigned long tag)
}

bool
SubjectImplementation::HasObserver(const EventObject & event) const
Object::SubjectImplementation::HasObserver(const EventObject & event) const
{
for (const auto & observer : m_Observers)
{
Expand All @@ -242,7 +242,7 @@ SubjectImplementation::HasObserver(const EventObject & event) const
}

bool
SubjectImplementation::PrintObservers(std::ostream & os, Indent indent) const
Object::SubjectImplementation::PrintObservers(std::ostream & os, Indent indent) const
{
if (m_Observers.empty())
{
Expand Down

0 comments on commit 4c0526e

Please sign in to comment.