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)
 
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.
 
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

Member Function Documentation

◆ acceptPendingProposal()

◆ CancelProposal()

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

◆ onTimerExpiry()

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

Timer expiry callback in the UI thread.

Definition at line 101 of file construction_manager.cpp.

References ACTIVATION_HELPER< T >::acceptPendingProposal().

Referenced by ACTIVATION_HELPER< T >::ACTIVATION_HELPER().

◆ ProposeActivation()

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 140 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal().

◆ 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 134 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal(), and ACTIVATION_HELPER< T >::ProposeActivation().

◆ m_lastProposal

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

The most recently-proposed item.

Definition at line 137 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal(), and ACTIVATION_HELPER< T >::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

◆ m_timeout

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

Activation timeout in milliseconds.

Definition at line 128 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER< T >::ProposeActivation().

◆ m_timer


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