16 #ifndef ROOT7_TDrawable 17 #define ROOT7_TDrawable 23 namespace Experimental {
29 class TVirtualCanvasPainter;
45 virtual void Execute(
const std::string &);
58 T* fWeakForIO =
nullptr;
77 new (&fShared) std::shared_ptr<T>(uniweak.
fWeak.lock());
85 new (&fShared) std::shared_ptr<T>(std::move(rhs.fShared));
90 T *
operator->()
const {
return fIsShared ? fRaw : fShared.get(); }
92 operator bool()
const {
return fIsShared ? (bool)fRaw : (
bool)fShared; }
97 fShared.~shared_ptr();
102 TUniWeakPtr(
const std::shared_ptr<T> &ptr): fWeak(ptr), fWeakForIO(ptr.get()), fIsWeak(true) {}
103 TUniWeakPtr(std::unique_ptr<T> &&ptr): fUnique(
std::move(ptr)), fIsWeak(false) {}
107 fWeak = std::move(rhs.fWeak);
108 auto shptr = rhs.fWeak.lock();
109 fWeakForIO = shptr.get();
111 fUnique = std::move(rhs.fUnique);
119 Accessor
Get()
const {
return Accessor(*
this); }
Accessor(const TUniWeakPtr &uniweak)
Base class for drawable entities: objects that can be painted on a TPad.
Namespace for new ROOT classes and functions.
TUniWeakPtr(TUniWeakPtr &&rhs)
bool fIsShared
fRaw or fShared?
Gives transparent access to the shared or unique pointer.
std::unique_ptr< T > fUnique
std::shared_ptr< T > fShared
The shared_ptr accessing a TUniWeak's weak_ptr.
T * fRaw
The raw, non-owning pointer accessing a TUniWeak's unique_ptr.
TUniWeakPtr(std::unique_ptr< T > &&ptr)
Abstract interface for painting a canvas.
TUniWeakPtr(const std::shared_ptr< T > &ptr)
virtual void PopulateMenu(TMenuItems &)
Method can be used to provide menu items for the drawn object.