24#ifndef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN
34 bool successful =
true;
39 deferredObserver->update();
40 }
catch (std::exception& e) {
51 "could not notify one or more observers: " << errMsg);
62 bool successful =
true;
67 }
catch (std::exception& e) {
82 "could not notify one or more observers: " << errMsg);
90#include <boost/signals2/signal_type.hpp>
98 typedef boost::signals2::signal_type<
100 boost::signals2::keywords::mutex_type<std::recursive_mutex> >
103 void connect(
const signal_type::slot_type& slot) {
108 void disconnect(
const T& slot) {
109 sig_.disconnect(slot);
112 void operator()()
const {
123 explicit ProxyUpdater(
const ext::shared_ptr<T>& observerProxy)
124 : proxy_(observerProxy.
get()) {}
126 void operator()()
const {
130 bool operator==(
const ProxyUpdater<T>& other)
const {
131 return proxy_ == other.proxy_;
134 bool operator!=(
const ProxyUpdater<T>& other)
const {
135 return proxy_ != other.proxy_;
143 std::lock_guard<std::recursive_mutex> lock(mutex_);
147 detail::Signal::signal_type::slot_type slot {detail::ProxyUpdater<Observer::Proxy>(observerProxy)};
148 #if defined(QL_USE_STD_SHARED_PTR)
149 sig_->connect(slot.track_foreign(observerProxy));
151 sig_->connect(slot.track(observerProxy));
158 std::lock_guard<std::recursive_mutex> lock(mutex_);
169 sig_->disconnect(detail::ProxyUpdater<Observer::Proxy>(observerProxy));
178 bool updatesEnabled =
false;
184 std::lock_guard<std::recursive_mutex> lock(mutex_);
195 : sig_(new detail::Signal()) { }
198 : sig_(new detail::Signal()) {
std::pair< iterator, bool > registerObserver(Observer *)
Size unregisterObserver(Observer *)
set_type deferredObservers_
void unregisterDeferredObserver(Observer *)
void registerDeferredObservers(const Observable::set_type &observers)
bool updatesEnabled() const
static ObservableSettings & instance()
access to the unique instance
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
T get(const std::vector< T > &v, Size i, U defaultValue)
bool operator==(const Currency &c1, const Currency &c2)
bool operator!=(const Currency &c1, const Currency &c2)
observer/observable pattern