57 #ifndef STAGE_MODEL_W_LINK_H 58 #define STAGE_MODEL_W_LINK_H 64 #include <type_traits> 65 #include <sigc++/trackable.h> 72 using error::LUMIERA_ERROR_BOTTOM_VALUE;
107 WLink (TAR& targetWidget)
112 : widget_{r.widget_?
attachTo(*r.widget_) :
nullptr}
116 : widget_{rr.widget_?
attachTo(*rr.widget_) :
nullptr}
141 if (tl == tr)
return;
144 if (tr) l.widget_ = l.
attachTo (*tr);
145 if (tl) r.widget_ = r.
attachTo (*tl);
150 operator bool()
const 152 return bool{widget_};
170 bool isValid()
const {
return bool{*
this}; }
171 bool isActive()
const {
return bool{*
this}; }
182 widget_->remove_destroy_notify_callback (&widget_);
195 if (widget_ == &otherTarget)
return;
202 __ensureAlive()
const 206 , LERR_(BOTTOM_VALUE));
216 static_assert (std::is_base_of<sigc::trackable, TAR>()
217 ,
"target type required to be sigc::trackable");
220 target.add_destroy_notify_callback (&widget_
223 TAR* & widgetPtr = *
static_cast<TAR**
>(p);
230 catch (std::exception& problem)
232 throw error::External (problem,
_Fmt{
"WLink could not attach to %s. Problem is %s"} % target % problem);
236 ERROR (
stage,
"Unknown exception while attaching WLink");
237 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.