Loading...
Searching...
No Matches
Public Member Functions | List of all members
BPrivate::Network::BBorrow< T > Class Template Reference

Smart pointer that borrows an object from a BExclusiveBorrow owner. More...

Public Member Functions

 BBorrow () noexcept
 Create a new smart pointer with no value.
 
 BBorrow (BBorrow &&other) noexcept
 Move constructor.
 
template<typename P >
 BBorrow (BExclusiveBorrow< P > &owner)
 Construct a borrowed object from the owner.
 
 BBorrow (nullptr_t) noexcept
 Special constructor that builds an empty borrow object.
 
 ~BBorrow ()
 Destructor that returns the object to the original owner.
 
bool HasValue () const noexcept
 Check if the object has a value or is empty.
 
T & operator* () const
 Dereference operator.
 
T * operator-> () const
 Dereference operator.
 
BBorrowoperator= (BBorrow &&other) noexcept
 Move assignment.
 
void Return () noexcept
 Return object to the owner.
 

Detailed Description

template<typename T>
class BPrivate::Network::BBorrow< T >

Smart pointer that borrows an object from a BExclusiveBorrow owner.

The BBorrow smart pointer is the accompanyment to the BExclusiveBorrow owner object. See the documentation on that template class on how to use the smart pointer pairs to express and enforce exclusive ownership between the owner and the borrower.

Like a BExclusiveBorrow object, a BBorrow object can either have a borrow or be empty. When it is empty, it means the current object is not borrowing anything at that moment. Any calls to access the underlying data will fail in that case.

Template Parameters
TThe type of object that is owned by this smart pointer.
Since
Haiku R1

Constructor & Destructor Documentation

◆ BBorrow() [1/4]

template<typename T >
BPrivate::Network::BBorrow< T >::BBorrow ( )
inlinenoexcept

Create a new smart pointer with no value.

Since
Haiku R1

◆ BBorrow() [2/4]

template<typename T >
BPrivate::Network::BBorrow< T >::BBorrow ( nullptr_t  )
inlinenoexcept

Special constructor that builds an empty borrow object.

Since
Haiku R1

◆ BBorrow() [3/4]

template<typename T >
template<typename P >
BPrivate::Network::BBorrow< T >::BBorrow ( BExclusiveBorrow< P > &  owner)
inlineexplicit

Construct a borrowed object from the owner.

Parameters
ownerThe owner to borrow from.
Exceptions
BBorrowErrorIn case the owner already borrowed their object, or in case the owner is an empty object, as you cannot borrow something that is not there.
Template Parameters
TThe type of object for this BBorrow object.
PThe type of objedt for the BExclusiveBorrow object. This allows you to have different types between the owner and the borrower, with the requirement that a pointer to type P can be cast to a pointer of type T without issue.
Since
Haiku R1

◆ BBorrow() [4/4]

template<typename T >
BPrivate::Network::BBorrow< T >::BBorrow ( BBorrow< T > &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe object to move from. It will be left empty after the move.
Since
Haiku R1

◆ ~BBorrow()

template<typename T >
BPrivate::Network::BBorrow< T >::~BBorrow ( )
inline

Destructor that returns the object to the original owner.

If the original owner no longer exists, the underlying object will be deleted.

Since
Haiku R1

Member Function Documentation

◆ HasValue()

template<typename T >
bool BPrivate::Network::BBorrow< T >::HasValue ( ) const
inlinenoexcept

Check if the object has a value or is empty.

Since
Haiku R1

◆ operator*()

template<typename T >
T & BPrivate::Network::BBorrow< T >::operator* ( ) const
inline

Dereference operator.

Exceptions
BBorrowErrorWhen the smart pointer is empty and there is no object to access.
Since
Haiku R1

◆ operator->()

template<typename T >
T * BPrivate::Network::BBorrow< T >::operator-> ( ) const
inline

Dereference operator.

Exceptions
BBorrowErrorWhen the smart pointer is empty and there is no object to access.
Since
Haiku R1

◆ operator=()

template<typename T >
BBorrow & BPrivate::Network::BBorrow< T >::operator= ( BBorrow< T > &&  other)
inlinenoexcept

Move assignment.

Parameters
otherThe object to move from. It will be left empty after the move.
Since
Haiku R1

References BPrivate::Network::BBorrow< T >::Return().

◆ Return()

template<typename T >
void BPrivate::Network::BBorrow< T >::Return ( )
inlinenoexcept

Return object to the owner.

The current object will be set to be an empty object after this call. If the object is already empty, this call will not do anything. If the owner no longer exists, the object will be disposed off.

Since
Haiku R1

Referenced by BPrivate::Network::BBorrow< T >::operator=().