OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::clonable_ptr< T > Class Template Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/clonable_ptr.hpp>

Inheritance diagram for Slic3r::clonable_ptr< T >:

Public Types

typedef T element_type
 The type of the managed object, aliased as member type.

Public Member Functions

 clonable_ptr () noexcept
 Default constructor.
 clonable_ptr (T *p) noexcept
 Constructor with the provided pointer to manage.
 clonable_ptr (const clonable_ptr &rhs)
 Copy constructor, clones by calling the rhs.clone() method.
 clonable_ptr (clonable_ptr &&rhs) noexcept
 Move constructor, never throws.
clonable_ptr & operator= (const clonable_ptr &rhs)
 Assignment operator.
clonable_ptr & operator= (clonable_ptr &&rhs)
 Move operator, never throws.
 ~clonable_ptr () noexcept
 the destructor releases its ownership and destroy the object
void reset () noexcept
 this reset releases its ownership and destroy the object
void reset (T *p) noexcept
 this reset release its ownership and re-acquire another one
void swap (clonable_ptr &rhs) noexcept
 Swap method for the copy-and-swap idiom (copy constructor and swap method).
void release () noexcept
 release the ownership of the px pointer without destroying the object!
 operator bool () const noexcept
T & operator* () const noexcept
T * operator-> () const noexcept
T * get () const noexcept

Private Member Functions

void destroy () noexcept
 release the ownership of the px pointer and destroy the object
void release () const noexcept
 hack: const-cast release the ownership of the px pointer without destroying the object!

Private Attributes

T * px
 Native pointer.

Detailed Description

template<class T>
class Slic3r::clonable_ptr< T >

Member Typedef Documentation

◆ element_type

template<class T>
typedef T Slic3r::clonable_ptr< T >::element_type

The type of the managed object, aliased as member type.

Constructor & Destructor Documentation

◆ clonable_ptr() [1/4]

template<class T>
Slic3r::clonable_ptr< T >::clonable_ptr ( )
inlinenoexcept

Default constructor.

36 :
37 px(nullptr)
38 {
39 }
T * px
Native pointer.
Definition clonable_ptr.hpp:141

References px.

Referenced by clonable_ptr(), clonable_ptr(), operator=(), operator=(), and swap().

Here is the caller graph for this function:

◆ clonable_ptr() [2/4]

template<class T>
Slic3r::clonable_ptr< T >::clonable_ptr ( T * p)
inlineexplicitnoexcept

Constructor with the provided pointer to manage.

41 :
42 px(p)
43 {
44 }
Definition clonable_ptr.hpp:30

◆ clonable_ptr() [3/4]

template<class T>
Slic3r::clonable_ptr< T >::clonable_ptr ( const clonable_ptr< T > & rhs)
inline

Copy constructor, clones by calling the rhs.clone() method.

46 :
47 px(rhs ? rhs.px->clone() : nullptr)
48 {
49 }

References clonable_ptr(), and px.

Here is the call graph for this function:

◆ clonable_ptr() [4/4]

template<class T>
Slic3r::clonable_ptr< T >::clonable_ptr ( clonable_ptr< T > && rhs)
inlinenoexcept

Move constructor, never throws.

51 :
52 px(rhs.px)
53 {
54 rhs.px = nullptr;
55 }

References clonable_ptr().

Here is the call graph for this function:

◆ ~clonable_ptr()

template<class T>
Slic3r::clonable_ptr< T >::~clonable_ptr ( )
inlinenoexcept

the destructor releases its ownership and destroy the object

73 {
74 destroy();
75 }
void destroy() noexcept
release the ownership of the px pointer and destroy the object
Definition clonable_ptr.hpp:128

References destroy().

Here is the call graph for this function:

Member Function Documentation

◆ destroy()

template<class T>
void Slic3r::clonable_ptr< T >::destroy ( )
inlineprivatenoexcept

release the ownership of the px pointer and destroy the object

129 {
130 delete px;
131 px = nullptr;
132 }

References px.

Referenced by ~clonable_ptr(), reset(), and reset().

Here is the caller graph for this function:

◆ get()

template<class T>
T * Slic3r::clonable_ptr< T >::get ( ) const
inlinenoexcept
121 {
122 // no assert, can return nullptr
123 return px;
124 }

References px.

Referenced by Slic3r::ConfigOptionDef::get_default_value().

Here is the caller graph for this function:

◆ operator bool()

template<class T>
Slic3r::clonable_ptr< T >::operator bool ( ) const
inlinenoexcept
105 {
106 return (nullptr != px); // TODO nullptrptr
107 }

References px.

◆ operator*()

template<class T>
T & Slic3r::clonable_ptr< T >::operator* ( ) const
inlinenoexcept
111 {
112 assert(nullptr != px);
113 return *px;
114 }

References px.

◆ operator->()

template<class T>
T * Slic3r::clonable_ptr< T >::operator-> ( ) const
inlinenoexcept
116 {
117 assert(nullptr != px);
118 return px;
119 }

References px.

◆ operator=() [1/2]

template<class T>
clonable_ptr & Slic3r::clonable_ptr< T >::operator= ( clonable_ptr< T > && rhs)
inline

Move operator, never throws.

65 {
66 delete px;
67 px = rhs.px;
68 rhs.px = nullptr;
69 return *this;
70 }

References clonable_ptr(), and px.

Here is the call graph for this function:

◆ operator=() [2/2]

template<class T>
clonable_ptr & Slic3r::clonable_ptr< T >::operator= ( const clonable_ptr< T > & rhs)
inline

Assignment operator.

58 {
59 delete px;
60 px = rhs ? rhs.px->clone() : nullptr;
61 return *this;
62 }

References clonable_ptr(), and px.

Here is the call graph for this function:

◆ release() [1/2]

template<class T>
void Slic3r::clonable_ptr< T >::release ( ) const
inlineprivatenoexcept

hack: const-cast release the ownership of the px pointer without destroying the object!

136 {
137 px = nullptr;
138 }

References px.

◆ release() [2/2]

template<class T>
void Slic3r::clonable_ptr< T >::release ( )
inlinenoexcept

release the ownership of the px pointer without destroying the object!

99 {
100 px = nullptr;
101 }

References px.

◆ reset() [1/2]

template<class T>
void Slic3r::clonable_ptr< T >::reset ( )
inlinenoexcept

this reset releases its ownership and destroy the object

78 {
79 destroy();
80 }

References destroy().

Here is the call graph for this function:

◆ reset() [2/2]

template<class T>
void Slic3r::clonable_ptr< T >::reset ( T * p)
inlinenoexcept

this reset release its ownership and re-acquire another one

83 {
84 assert((nullptr == p) || (px != p)); // auto-reset not allowed
85 destroy();
86 px = p;
87 }

References destroy(), and px.

Here is the call graph for this function:

◆ swap()

template<class T>
void Slic3r::clonable_ptr< T >::swap ( clonable_ptr< T > & rhs)
inlinenoexcept

Swap method for the copy-and-swap idiom (copy constructor and swap method).

91 {
92 T *tmp = px;
93 px = rhs.px;
94 rhs.px = tmp;
95 }

References clonable_ptr(), and px.

Here is the call graph for this function:

Member Data Documentation

◆ px


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