Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
Scroom::Utils::Base Class Reference

#include <utilities.hh>

Inheritance diagram for Scroom::Utils::Base:
Inheritance graph
Collaboration diagram for Scroom::Utils::Base:
Collaboration graph

Public Member Functions

 Base ()=default
 
 Base (const Base &)=delete
 
 Base (Base &&)=delete
 
Baseoperator= (const Base &)=delete
 
Baseoperator= (Base &&)=delete
 
virtual ~Base ()=default
 
template<typename R >
std::shared_ptr< R > shared_from_this ()
 
template<typename R >
std::shared_ptr< R const > shared_from_this () const
 

Detailed Description

Base class that inherits from std::enable_shared_from_this.

In an inheritance hierarchy, you can inherit from std::enable_shared_from_this only once. Otherwise, you'll get two copies of the internal weak pointer, and only one gets initialized.

To work with this restriction, this class inherits from std::enable_shared_from_this, and provides methods to dynamic_cast to whatever subtype you like.

You should always inherit virtually from this class, to ensure that even in the face of multiple inheritance, there always is only one copy of Base.

Constructor & Destructor Documentation

◆ Base() [1/3]

Scroom::Utils::Base::Base ( )
default

◆ Base() [2/3]

Scroom::Utils::Base::Base ( const Base )
delete

◆ Base() [3/3]

Scroom::Utils::Base::Base ( Base &&  )
delete

◆ ~Base()

virtual Scroom::Utils::Base::~Base ( )
virtualdefault

Member Function Documentation

◆ operator=() [1/2]

Base & Scroom::Utils::Base::operator= ( Base &&  )
delete

◆ operator=() [2/2]

Base & Scroom::Utils::Base::operator= ( const Base )
delete

◆ shared_from_this() [1/2]

template<typename R >
std::shared_ptr< R > Scroom::Utils::Base::shared_from_this ( )
inline

Calls shared_from_this() with a built-in dynamic cast, to make it usable in subclasses.

49 {
50 return std::dynamic_pointer_cast<R, Base>(std::enable_shared_from_this<Base>::shared_from_this());
51 }

Referenced by on_view_destroyed().

Here is the caller graph for this function:

◆ shared_from_this() [2/2]

template<typename R >
std::shared_ptr< R const > Scroom::Utils::Base::shared_from_this ( ) const
inline

Calls shared_from_this() with a built-in dynamic cast, to make it usable in subclasses.

59 {
60 return std::dynamic_pointer_cast<R const, Base const>(std::enable_shared_from_this<Base>::shared_from_this());
61 }

The documentation for this class was generated from the following file: