libzypp 17.37.17
|
#include <zypp-core/zyppng/base/base.h>
Public Types | |
using | Ptr = std::shared_ptr<Base> |
using | WeakPtr = std::weak_ptr<Base> |
Public Member Functions | |
Base () | |
virtual | ~Base () |
WeakPtr | parent () const |
void | addChild (const Base::Ptr &child) |
void | removeChild (const Ptr &child) |
const std::unordered_set< Ptr > & | children () const |
std::thread::id | threadId () const |
template<typename T> | |
std::vector< std::weak_ptr< T > > | findChildren () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () |
template<typename T> | |
std::weak_ptr< T > | weak_this () const |
template<typename T> | |
std::weak_ptr< T > | weak_this () |
template<typename SenderFunc, typename ReceiverFunc> | |
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
Static Public Member Functions | |
template<typename Obj, typename Functor> | |
static decltype(auto) | make_base_slot (Obj *o, Functor &&f) |
template<typename SenderFunc, typename ReceiverFunc> | |
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
Protected Member Functions | |
Base (BasePrivate &dd) |
Protected Attributes | |
std::unique_ptr< BasePrivate > | d_ptr |
Private Member Functions | |
NON_COPYABLE (Base) |
The Base class is used as a common base class for objects that emit signals, it also supports a parent/child relationship where the parent object keeps a reference for all its children.
Generally, all objects that want to send or receive signals should derive from Base, since it will help enforcing a correct use of shared_ptr semantics. Generally, with signal/slot emission, it is easy to run into the issue of an object being deleted while it emits a signal. Think about a Socket that emits a closed signal. It might be removed from the list of connections and the last reference of the object gets deleted before the signal returns. In order to prevent this from happening, we established a rule of "Always own a reference to the object you use". The connection helper's Base::connect and Base::connectFunc help with enforcing this rule, even asserting when compiled without NDEBUG defined.
using zyppng::Base::Ptr = std::shared_ptr<Base> |
using zyppng::Base::WeakPtr = std::weak_ptr<Base> |
|
protected |
|
private |
Base::WeakPtr zyppng::Base::parent | ( | ) | const |
void zyppng::Base::addChild | ( | const Base::Ptr & | child | ) |
void zyppng::Base::removeChild | ( | const Ptr & | child | ) |
const std::unordered_set< Base::Ptr > & zyppng::Base::children | ( | ) | const |
std::thread::id zyppng::Base::threadId | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inlinestatic |
This allows to connect a lambda to a signal in a Base derived type. Make sure to track the objects used inside the slot for shared_ptr correctness ( always own a reference to the object you are calling )
|
inline |
|
protected |