Scroom  0.14
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 >
boost::shared_ptr< R > shared_from_this ()
 
template<typename R >
boost::shared_ptr< R const > shared_from_this () const
 

Detailed Description

Base class that inherits from boost::enable_shared_from_this.

In an inheritance hierarchy, you can inherit from boost::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 boost::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 >
boost::shared_ptr< R > Scroom::Utils::Base::shared_from_this

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

110  {
111  return boost::dynamic_pointer_cast<R, Base>(boost::enable_shared_from_this<Base>::shared_from_this());
112  }

Referenced by on_view_destroyed().

Here is the caller graph for this function:

◆ shared_from_this() [2/2]

template<typename R >
boost::shared_ptr< R const > Scroom::Utils::Base::shared_from_this

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

116  {
117  return boost::dynamic_pointer_cast<R const, Base const>(boost::enable_shared_from_this<Base>::shared_from_this());
118  }

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