48 #ifndef STAGE_MODEL_W_LINK_H 49 #define STAGE_MODEL_W_LINK_H 55 #include <type_traits> 56 #include <sigc++/trackable.h> 63 using error::LUMIERA_ERROR_BOTTOM_VALUE;
98 WLink (TAR& targetWidget)
103 : widget_{r.widget_?
attachTo(*r.widget_) :
nullptr}
107 : widget_{rr.widget_?
attachTo(*rr.widget_) :
nullptr}
132 if (tl == tr)
return;
135 if (tr) l.widget_ = l.
attachTo (*tr);
136 if (tl) r.widget_ = r.
attachTo (*tl);
141 operator bool()
const 143 return bool{widget_};
161 bool isValid()
const {
return bool{*
this}; }
162 bool isActive()
const {
return bool{*
this}; }
173 widget_->remove_destroy_notify_callback (&widget_);
186 if (widget_ == &otherTarget)
return;
193 __ensureAlive()
const 197 , LERR_(BOTTOM_VALUE));
207 static_assert (std::is_base_of<sigc::trackable, TAR>()
208 ,
"target type required to be sigc::trackable");
211 target.add_destroy_notify_callback (&widget_
214 TAR* & widgetPtr = *
static_cast<TAR**
>(p);
221 catch (std::exception& problem)
223 throw error::External (problem,
_Fmt{
"WLink could not attach to %s. Problem is %s"} % target % problem);
227 ERROR (
stage,
"Unknown exception while attaching WLink");
228 throw error::External (
_Fmt{
"WLink could not attach to %s due to unidentified Problems"} % target);
WLink & operator=(WLink other)
void clear()
detach and deactivate this link
#define ERROR_LOG_AND_IGNORE(_FLAG_, _OP_DESCR_)
convenience shortcut for a sequence of catch blocks just logging and consuming an error...
void connect(TAR &otherTarget)
(re)connect this smart link to the given target.
A front-end for using printf-style formatting.
Derived specific exceptions within Lumiera's exception hierarchy.
Lumiera GTK UI implementation root.
Lumiera error handling (C++ interface).
TAR * attachTo(TAR &target)
Managed link to a sigc::trackable UI widget, without taking ownership.
friend void swap(WLink &l, WLink &r)
swap the pointees, including callback registration.