KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ACTIVATION_HELPER< T > Class Template Reference

A helper class to manage the activation of a "proposal" after a timeout. More...

Public Types

using ACTIVATION_CALLBACK = std::function<void( T&& )>
 

Public Member Functions

 ACTIVATION_HELPER (std::chrono::milliseconds aTimeout, ACTIVATION_CALLBACK aCallback)
 
 ~ACTIVATION_HELPER ()
 
void ProposeActivation (T &&aProposal, std::size_t aProposalTag, bool aAcceptImmediately)
 
void CancelProposal ()
 

Private Member Functions

void onTimerExpiry (wxTimerEvent &aEvent)
 Timer expiry callback in the UI thread.
 
void acceptPendingProposal ()
 

Private Attributes

std::mutex m_mutex
 
std::chrono::milliseconds m_timeout
 Activation timeout in milliseconds.
 
std::optional< std::size_t > m_pendingProposalTag
 The last proposal tag that was made.
 
std::optional< std::size_t > m_lastAcceptedProposalTag
 The last proposal that was accepted.
 
T m_lastProposal
 The most recently-proposed item.
 
ACTIVATION_CALLBACK m_callback
 Callback to call when the proposal is accepted.
 
wxTimer m_timer
 

Detailed Description

template<typename T>
class ACTIVATION_HELPER< T >

A helper class to manage the activation of a "proposal" after a timeout.

When a proposal is made, a timer starts. If no new proposal is made and the proposal is not canceled before the timer expires, the proposal is "accepted" via a callback.

Proposals are "tagged" with a hash - this is used to avoid reproposing the same thing multiple times.

Template Parameters
TThe type of the proposal, which will be passed to the callback (by value)

Definition at line 46 of file construction_manager.cpp.

Member Typedef Documentation

◆ ACTIVATION_CALLBACK

template<typename T>
using ACTIVATION_HELPER< T >::ACTIVATION_CALLBACK = std::function<void( T&& )>

Definition at line 49 of file construction_manager.cpp.

Constructor & Destructor Documentation

◆ ACTIVATION_HELPER()

template<typename T>
ACTIVATION_HELPER< T >::ACTIVATION_HELPER ( std::chrono::milliseconds aTimeout,
ACTIVATION_CALLBACK aCallback )
inline

Definition at line 51 of file construction_manager.cpp.

References m_callback, m_timeout, m_timer, move, and onTimerExpiry().

◆ ~ACTIVATION_HELPER()

template<typename T>
ACTIVATION_HELPER< T >::~ACTIVATION_HELPER ( )
inline

Definition at line 58 of file construction_manager.cpp.

References m_mutex, m_pendingProposalTag, m_timer, and onTimerExpiry().

Member Function Documentation

◆ acceptPendingProposal()

template<typename T>
void ACTIVATION_HELPER< T >::acceptPendingProposal ( )
inlineprivate

◆ CancelProposal()

template<typename T>
void ACTIVATION_HELPER< T >::CancelProposal ( )
inline

Definition at line 102 of file construction_manager.cpp.

References m_mutex, m_pendingProposalTag, and m_timer.

◆ onTimerExpiry()

template<typename T>
void ACTIVATION_HELPER< T >::onTimerExpiry ( wxTimerEvent & aEvent)
inlineprivate

Timer expiry callback in the UI thread.

Definition at line 113 of file construction_manager.cpp.

References acceptPendingProposal().

Referenced by ACTIVATION_HELPER(), and ~ACTIVATION_HELPER().

◆ ProposeActivation()

template<typename T>
void ACTIVATION_HELPER< T >::ProposeActivation ( T && aProposal,
std::size_t aProposalTag,
bool aAcceptImmediately )
inline

Member Data Documentation

◆ m_callback

template<typename T>
ACTIVATION_CALLBACK ACTIVATION_HELPER< T >::m_callback
private

Callback to call when the proposal is accepted.

Definition at line 152 of file construction_manager.cpp.

Referenced by acceptPendingProposal(), and ACTIVATION_HELPER().

◆ m_lastAcceptedProposalTag

template<typename T>
std::optional<std::size_t> ACTIVATION_HELPER< T >::m_lastAcceptedProposalTag
private

The last proposal that was accepted.

Definition at line 146 of file construction_manager.cpp.

Referenced by acceptPendingProposal(), and ProposeActivation().

◆ m_lastProposal

template<typename T>
T ACTIVATION_HELPER< T >::m_lastProposal
private

The most recently-proposed item.

Definition at line 149 of file construction_manager.cpp.

Referenced by acceptPendingProposal(), and ProposeActivation().

◆ m_mutex

template<typename T>
std::mutex ACTIVATION_HELPER< T >::m_mutex
mutableprivate

◆ m_pendingProposalTag

template<typename T>
std::optional<std::size_t> ACTIVATION_HELPER< T >::m_pendingProposalTag
private

The last proposal tag that was made.

Definition at line 143 of file construction_manager.cpp.

Referenced by acceptPendingProposal(), CancelProposal(), ProposeActivation(), and ~ACTIVATION_HELPER().

◆ m_timeout

template<typename T>
std::chrono::milliseconds ACTIVATION_HELPER< T >::m_timeout
private

Activation timeout in milliseconds.

Definition at line 140 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER(), and ProposeActivation().

◆ m_timer

template<typename T>
wxTimer ACTIVATION_HELPER< T >::m_timer
private

The documentation for this class was generated from the following file: