Audacity 3.2.0
Public Types | Public Member Functions | Private Attributes | List of all members
Observer::detail::RecordList Struct Reference

#include <Observer.h>

Inheritance diagram for Observer::detail::RecordList:
[legend]
Collaboration diagram for Observer::detail::RecordList:
[legend]

Public Types

using Visitor = bool(*)(const RecordBase &record, const void *arg)
 Type of function visiting the list; stop visit on true return. More...
 

Public Member Functions

 RecordList (ExceptionPolicy *pPolicy, Visitor visitor)
 
 ~RecordList () noexcept
 
Subscription Subscribe (std::shared_ptr< RecordBase > pRecord)
 
bool Visit (const void *arg)
 

Private Attributes

ExceptionPolicy *const m_pPolicy
 
const Visitor m_visitor
 

Additional Inherited Members

Detailed Description

Definition at line 53 of file Observer.h.

Member Typedef Documentation

◆ Visitor

using Observer::detail::RecordList::Visitor = bool(*)(const RecordBase &record, const void *arg)

Type of function visiting the list; stop visit on true return.

Definition at line 56 of file Observer.h.

Constructor & Destructor Documentation

◆ RecordList()

Observer::detail::RecordList::RecordList ( ExceptionPolicy pPolicy,
Visitor  visitor 
)
explicit
Precondition
visitor != nullptr

Definition at line 26 of file Observer.cpp.

27 : m_pPolicy{ pPolicy }
28 , m_visitor{ visitor }
29{
30 assert(m_visitor); // precondition
31}
const Visitor m_visitor
Definition: Observer.h:65
ExceptionPolicy *const m_pPolicy
Definition: Observer.h:64

References m_visitor.

◆ ~RecordList()

Observer::detail::RecordList::~RecordList ( )
noexcept

Non-defaulted destructor. Beware stack growth

Definition at line 33 of file Observer.cpp.

34{
36 auto pRecord = move(next);
37 while (pRecord)
38 pRecord = move(pRecord->next);
39}

References Observer::detail::RecordLink::next.

Member Function Documentation

◆ Subscribe()

Subscription Observer::detail::RecordList::Subscribe ( std::shared_ptr< RecordBase pRecord)
Precondition
pRecord != nullptr

Definition at line 41 of file Observer.cpp.

42{
43 assert(pRecord); // precondition
44 auto result = Subscription{ pRecord };
45 if (auto &pNext = (pRecord->next = move(next)))
46 pNext->prev = pRecord;
47 pRecord->prev = weak_from_this();
48 next = move(pRecord);
49 return result;
50}

References Observer::detail::RecordLink::next.

◆ Visit()

bool Observer::detail::RecordList::Visit ( const void *  arg)

Definition at line 52 of file Observer.cpp.

53{
54 assert(m_visitor); // See constructor
55 if (m_pPolicy)
57 bool result = false;
58 for (auto pRecord = next; pRecord; pRecord = pRecord->next) {
59 try {
60 if (m_visitor(*pRecord, arg)) {
61 result = true;
62 break;
63 }
64 // pRecord might have been removed from the list by the callback,
65 // but pRecord->next is unchanged. We won't see callbacks added by
66 // the callback, because they are earlier in the list.
67 }
68 catch (...) {
70 result = true;
71 break;
72 }
73 }
74 }
75 // Intentionally not in a finally():
76 if (m_pPolicy)
78 return result;
79}
virtual void OnEndPublish() noexcept(false)=0
Called at the end of each publication, if exiting normally; may throw.
virtual bool OnEachFailedCallback() noexcept(false)=0
virtual void OnBeginPublish()=0
Called at the start of each publication.

References m_pPolicy, m_visitor, Observer::detail::RecordLink::next, Observer::ExceptionPolicy::OnBeginPublish(), Observer::ExceptionPolicy::OnEachFailedCallback(), and Observer::ExceptionPolicy::OnEndPublish().

Here is the call graph for this function:

Member Data Documentation

◆ m_pPolicy

ExceptionPolicy* const Observer::detail::RecordList::m_pPolicy
private

Definition at line 64 of file Observer.h.

Referenced by Visit().

◆ m_visitor

const Visitor Observer::detail::RecordList::m_visitor
private

Definition at line 65 of file Observer.h.

Referenced by RecordList(), and Visit().


The documentation for this struct was generated from the following files: