KiCad PCB EDA Suite
UTIL::LINK Class Reference

Simple RAII-handle to a subscription. More...

#include <observable.h>

Public Member Functions

 LINK ()
 
 LINK (std::shared_ptr< DETAIL::OBSERVABLE_BASE::IMPL > token, void *observer)
 
 LINK (LINK &&other)
 
 LINK (const LINK &)=delete
 
void operator= (const LINK &)=delete
 
LINKoperator= (LINK &&other)
 
void reset ()
 
 operator bool () const
 
 ~LINK ()
 

Private Attributes

std::shared_ptr< DETAIL::OBSERVABLE_BASE::IMPLtoken_
 
void * observer_
 

Detailed Description

Simple RAII-handle to a subscription.

Definition at line 102 of file observable.h.

Constructor & Destructor Documentation

◆ LINK() [1/4]

UTIL::LINK::LINK ( )

Definition at line 120 of file observable.cpp.

121 : observer_( nullptr )
122 {
123 }

◆ LINK() [2/4]

UTIL::LINK::LINK ( std::shared_ptr< DETAIL::OBSERVABLE_BASE::IMPL token,
void *  observer 
)

Definition at line 126 of file observable.cpp.

127 : token_( std::move( token ) ), observer_( observer )
128 {
129 }

References move.

◆ LINK() [3/4]

UTIL::LINK::LINK ( LINK &&  other)

Definition at line 132 of file observable.cpp.

133 : token_( std::move( other.token_ ) ), observer_( other.observer_ )
134 {
135 other.token_.reset();
136 }

References move.

◆ LINK() [4/4]

UTIL::LINK::LINK ( const LINK )
delete

◆ ~LINK()

UTIL::LINK::~LINK ( )

Definition at line 154 of file observable.cpp.

155 {
156 reset();
157 }

References reset().

Member Function Documentation

◆ operator bool()

UTIL::LINK::operator bool ( ) const
explicit

Definition at line 148 of file observable.cpp.

149 {
150 return token_ ? true : false;
151 }

◆ operator=() [1/2]

void UTIL::LINK::operator= ( const LINK )
delete

◆ operator=() [2/2]

LINK & UTIL::LINK::operator= ( LINK &&  other)

Definition at line 139 of file observable.cpp.

140 {
141 token_ = std::move( other.token_ );
142 other.token_.reset();
143 observer_ = other.observer_;
144 return *this;
145 }

References observer_, and token_.

◆ reset()

void UTIL::LINK::reset ( )

Definition at line 160 of file observable.cpp.

161 {
162 if(token_)
163 {
164 token_->remove_observer( observer_ );
165 token_.reset();
166 }
167 }

References observer_, and token_.

Referenced by ~LINK().

Member Data Documentation

◆ observer_

void* UTIL::LINK::observer_
private

Definition at line 121 of file observable.h.

Referenced by operator=(), and reset().

◆ token_

std::shared_ptr<DETAIL::OBSERVABLE_BASE::IMPL> UTIL::LINK::token_
private

Definition at line 120 of file observable.h.

Referenced by operator=(), and reset().


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