34 #ifndef PSYSTEM_FRAMEWORK_UNIQUE_HANDLE_HPP
35 #define PSYSTEM_FRAMEWORK_UNIQUE_HANDLE_HPP
75 template <
typename T,
typename D, T kInval
idHandle>
80 template <
typename T2,
typename, T2 kInval
idHandle2>
99 static constexpr T invalid_handle_value = kInvalidHandle;
248 T kInvalidHandle = INVALID_HANDLE_VALUE>
275 using base::invalid_handle_value;
324 template <
typename D2>
363 if (kInvalidHandle != this->
m_handle)
395 if (std::addressof(o) ==
this)
return *
this;
399 m_deleter = std::forward<deleter_type>(o.m_deleter);
465 if (kInvalidHandle != this->
m_handle)
491 handle_type tmp_handle = o.
m_handle;
535 template <
typename T, T kInval
idHandle>
562 using base::invalid_handle_value;
609 if (kInvalidHandle != this->
m_handle)
644 if (kInvalidHandle != this->
m_handle)
663 handle_type tmp_handle = o.
m_handle;
690 template <
typename T,
typename D, T kInval
idHandle>
710 template <
typename T,
typename D, T kInval
idHandle>
711 struct hash<
psystem::unique_handle<T, D, kInvalidHandle> >
721 return std::hash<typename unique_handle_type::handle_type>()(
746 template <
typename T,
typename D, T kInval
idHandle>
751 return (h1.get() == h2.get());
770 template <
typename T,
typename D, T kInval
idHandle>
794 template <
typename T,
typename D, T kInval
idHandle>
820 template <
typename T,
typename D, T kInval
idHandle>
844 template <
typename T,
typename D, T kInval
idHandle>
868 template <
typename T,
typename D, T kInval
idHandle>
876 #endif // PSYSTEM_FRAMEWORK_UNIQUE_HANDLE_HPP
D deleter_type
The data-type of the clean-up facility.
Definition: unique_handle.hpp:88
void swap(unique_handle &o) noexcept
Swap ownership of two unique_handle instances.
Definition: unique_handle.hpp:483
A simple functor to close handles (for use with RAII handle containers).
Definition: default_close_handle.hpp:49
Uniquely manage a single "handle".
Definition: unique_handle.hpp:249
unique_handle(unique_handle &&other) noexcept
Transfer ownership of a handle from another unique_handle.
Definition: unique_handle.hpp:346
T m_handle
A temporary handle for tracking changes while accessed as a pointer-to-handle type.
Definition: managed_handle_proxy.hpp:96
void swap(unique_handle &o) noexcept
Swap ownership of two unique_handle instances.
Definition: unique_handle.hpp:658
Definition: shared_handle.hpp:782
unique_handle(handle_type hndl=kInvalidHandle) noexcept
Construct an instance to manage a handle.
Definition: unique_handle.hpp:579
Disable heap allocation and deallocation.
Definition: stack_allocated.hpp:42
Base unique_handle functionality common to all template specializations.
Definition: unique_handle.hpp:76
deleter_type m_deleter
The instance that will be used to clean up the handle's resources.
Definition: unique_handle.hpp:508
size_t operator()(unique_handle_type const &value) const
Invoke the hash functor.
Definition: unique_handle.hpp:719
~unique_handle() noexcept
Destroy this container, freeing the handle managed within.
Definition: unique_handle.hpp:607
bool operator<(psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
Test if the first handle is less than the second.
Definition: unique_handle.hpp:795
unique_handle_impl(handle_type handle) noexcept
Construct this base container object with a handle.
Definition: unique_handle.hpp:113
T handle_type
The data-type of the handle being managed.
Definition: unique_handle.hpp:91
Allows safe modification of a managed handle container when accessed by the handle's address...
Definition: managed_handle_proxy.hpp:51
D deleter_type
The data-type of the clean-up facility.
Definition: unique_handle.hpp:88
void reset(handle_type hndl=kInvalidHandle) noexcept
Assign a new handle to be managed by this instance.
Definition: unique_handle.hpp:461
unique_handle & operator=(unique_handle &&o) noexcept
Transfer ownership of a handle into this instance.
Definition: unique_handle.hpp:623
~unique_handle() noexcept
Destroy this container, freeing the handle managed within.
Definition: unique_handle.hpp:361
unique_handle & operator=(unique_handle &&o) noexcept
Transfer ownership of a handle into this instance.
Definition: unique_handle.hpp:390
bool operator==(psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
Test for equality of two handles.
Definition: unique_handle.hpp:747
deleter_type & get_deleter() noexcept
Access the deleter instance within this class.
Definition: unique_handle.hpp:429
handle_type get() const noexcept
Access the handle contained in this object.
Definition: unique_handle.hpp:134
safe_address_container operator&() noexcept
Allow safe alteration of the handle by routines that return data by C-style output parameters...
Definition: unique_handle.hpp:630
T handle_type
The data-type of the handle being managed.
Definition: unique_handle.hpp:91
bool operator!=(psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
Test for inequality of two handles.
Definition: unique_handle.hpp:771
unique_handle(handle_type hndl=kInvalidHandle) noexcept
Construct an instance to manage a handle.
Definition: unique_handle.hpp:296
safe_address_container operator&() noexcept
Allow safe alteration of the handle by routines that return data by C-style output parameters...
Definition: unique_handle.hpp:412
Introduces a functor to wrap CloseHandle() for RAII handle containers.
handle_type release() noexcept
Release the handle from being managed by this class.
Definition: unique_handle.hpp:149
static void close_handle(T hndl) noexcept
Executes a handle clean-up routine without requiring an instance.
Definition: default_close_handle.hpp:64
unique_handle(unique_handle &&other) noexcept
Transfer ownership of a handle from another unique_handle.
Definition: unique_handle.hpp:596
Contains the process examination "system" and basic frameworks.
Definition: pstack_event_handler.hpp:28
Provide an internal class for safely altering a managed handle by address within its container...
bool operator>=(psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
Test if the first handle is greater than or equal to the second.
Definition: unique_handle.hpp:869
unique_handle(handle_type hndl, D2 &&deleter) noexcept
Construct an instance to manage a handle with a custom "deleter.".
Definition: unique_handle.hpp:325
deleter_type const & get_deleter() const noexcept
Access the const deleter instance within this class.
Definition: unique_handle.hpp:443
void reset(handle_type hndl=kInvalidHandle) noexcept
Assign a new handle to be managed by this instance.
Definition: unique_handle.hpp:640
bool operator>(psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
Test if the first handle is greater than the second.
Definition: unique_handle.hpp:845
Defines the psystem::stack_allocated interface.
bool operator<=(psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
Test if the first handle is less than or equal to the second.
Definition: unique_handle.hpp:821
psystem::internal::managed_handle_proxy< handle_type, unique_handle< handle_type, deleter_type, kInvalidHandle > > safe_address_container
A safe container for altering the handle by the address-of operator.
Definition: unique_handle.hpp:268
unique_handle_impl & operator=(unique_handle_impl &)=delete
Disable copy-assignment to prevent double-frees.
handle_type m_handle
The handle that will be managed by this class.
Definition: unique_handle.hpp:181