46 : iteration_count_( 0 ), owned_by_( owned_by )
52 return owned_by_ ==
nullptr;
77 if( iteration_count_ == 0 )
84 return iteration_count_ != 0;
90 assert( !is_iterating() );
91 observers_.push_back( observer );
97 auto it = std::find( observers_.begin(), observers_.end(), observer );
99 if( it == observers_.end() )
108 observers_.erase( it );
115 observers_.erase( it, observers_.end() );
121 : observer_( nullptr )
126 LINK::LINK( std::shared_ptr<DETAIL::OBSERVABLE_BASE::IMPL> token,
void* observer )
127 : token_(
std::
move( token ) ), observer_( observer )
133 : token_(
std::
move( other.token_ ) ), observer_( other.observer_ )
135 other.token_.reset();
141 token_ = std::move( other.token_ );
142 other.token_.reset();
148 LINK::operator bool()
const
150 return token_ ? true :
false;
178 : impl_( other.get_shared_impl() )
191 impl_ = std::make_shared<IMPL>(
this );
198 impl_ = std::make_shared<IMPL>();
219 impl_->add_observer( observer );
226 impl_->remove_observer( observer );
233 impl_->enter_iteration();
241 impl_->leave_iteration();
243 if( !
impl_->is_iterating() && !
impl_->is_shared() &&
impl_.use_count() == 1 )
252 return impl_->observers_.size();
Simple RAII-handle to a subscription.
void operator=(const LINK &)=delete
std::shared_ptr< DETAIL::OBSERVABLE_BASE::IMPL > token_
A model subscriber implementation using links to represent connections.
bool is_iterating() const
void remove_observer(void *observer)
void add_observer(void *observer)
IMPL(OBSERVABLE_BASE *owned_by=nullptr)
void remove_observer(void *observer)
std::shared_ptr< IMPL > get_shared_impl()
void add_observer(void *observer)
void on_observers_empty()
void allocate_shared_impl()
std::shared_ptr< IMPL > impl_
bool operator()(const T &val) const