Template Numerical Library version\ main:df396df
Loading...
Searching...
No Matches
TNL::Pointers::UniquePointer< Object, Devices::Host > Class Template Reference

Specialization of the UniquePointer for the host system. More...

#include <TNL/Pointers/UniquePointer.h>

Inheritance diagram for TNL::Pointers::UniquePointer< Object, Devices::Host >:
Collaboration diagram for TNL::Pointers::UniquePointer< Object, Devices::Host >:

Public Types

using DeviceType = Devices::Host
 Type of the device where the object is to be mirrored.
 
using ObjectType = Object
 Type of the object owned by the pointer.
 

Public Member Functions

template<typename... Args>
 UniquePointer (const Args... args)
 Constructor with parameters of the Object constructor.
 
template<typename Value >
 UniquePointer (std::initializer_list< std::initializer_list< Value > > list)
 Constructor with nested initializer lists.
 
template<typename Value >
 UniquePointer (std::initializer_list< Value > list)
 Constructor with initializer list.
 
 UniquePointer (std::nullptr_t)
 Constructor of empty pointer.
 
 ~UniquePointer () override
 Destructor.
 
template<typename Device = Devices::Host>
const ObjectgetData () const
 Constant object reference getter.
 
template<typename Device = Devices::Host>
ObjectmodifyData ()
 Non-constant object reference getter.
 
__cuda_callable__ operator bool () const
 Conversion to boolean type.
 
__cuda_callable__ bool operator! () const
 Negation operator.
 
Objectoperator* ()
 Dereferencing operator for accessing the object owned by non-constant smart pointer.
 
const Objectoperator* () const
 Dereferencing operator for accessing the object owned by constant smart pointer.
 
Objectoperator-> ()
 Arrow operator for accessing the object owned by non-constant smart pointer.
 
const Objectoperator-> () const
 Arrow operator for accessing the object owned by constant smart pointer.
 
const UniquePointeroperator= (UniquePointer &&ptr) noexcept
 Move operator.
 
const UniquePointeroperator= (UniquePointer &ptr)
 Assignment operator.
 
bool synchronize () override
 Cross-device pointer synchronization.
 
- Public Member Functions inherited from TNL::Pointers::SmartPointer

Protected Attributes

Objectpointer
 

Detailed Description

template<typename Object>
class TNL::Pointers::UniquePointer< Object, Devices::Host >

Specialization of the UniquePointer for the host system.

Template Parameters
Objectis a type of object to be owned by the pointer.

Constructor & Destructor Documentation

◆ UniquePointer() [1/3]

template<typename Object >
template<typename... Args>
TNL::Pointers::UniquePointer< Object, Devices::Host >::UniquePointer ( const Args... args)
inlineexplicit

Constructor with parameters of the Object constructor.

Template Parameters
Argsis variadic template type of arguments of the Object constructor.
argsare arguments passed to the Object constructor.

◆ UniquePointer() [2/3]

template<typename Object >
template<typename Value >
TNL::Pointers::UniquePointer< Object, Devices::Host >::UniquePointer ( std::initializer_list< Value > list)
inlineexplicit

Constructor with initializer list.

Template Parameters
Valueis type of the initializer list elements.
Parameters
listis the instance of the initializer list..

◆ UniquePointer() [3/3]

template<typename Object >
template<typename Value >
TNL::Pointers::UniquePointer< Object, Devices::Host >::UniquePointer ( std::initializer_list< std::initializer_list< Value > > list)
inlineexplicit

Constructor with nested initializer lists.

Template Parameters
Valueis type of the nested initializer list elements.
Parameters
listis the instance of the nested initializer list..

Member Function Documentation

◆ getData()

template<typename Object >
template<typename Device = Devices::Host>
const Object & TNL::Pointers::UniquePointer< Object, Devices::Host >::getData ( ) const
inlinenodiscard

Constant object reference getter.

No synchronization of this pointer will be performed due to calling this method.

Template Parameters
Devicesays what image of the object one want to dereference. It can be either DeviceType or Devices::Host.
Returns
constant reference to the object image on given device.

◆ modifyData()

template<typename Object >
template<typename Device = Devices::Host>
Object & TNL::Pointers::UniquePointer< Object, Devices::Host >::modifyData ( )
inlinenodiscard

Non-constant object reference getter.

After calling this method, the object owned by the pointer might need to be synchronized. One should not forget to call Pointers::synchronizeSmartPointersOnDevice< Devices::Cuda >() before calling CUDA kernel using object from this smart pointer.

Template Parameters
Devicesays what image of the object one want to dereference. It can be either DeviceType or Devices::Host.
Returns
constant reference to the object image on given device.

◆ operator bool()

template<typename Object >
__cuda_callable__ TNL::Pointers::UniquePointer< Object, Devices::Host >::operator bool ( ) const
inline

Conversion to boolean type.

Returns
Returns true if the pointer is not empty, false otherwise.

◆ operator!()

template<typename Object >
__cuda_callable__ bool TNL::Pointers::UniquePointer< Object, Devices::Host >::operator! ( ) const
inline

Negation operator.

Returns
Returns false if the pointer is not empty, true otherwise.

◆ operator*() [1/2]

template<typename Object >
Object & TNL::Pointers::UniquePointer< Object, Devices::Host >::operator* ( )
inline

Dereferencing operator for accessing the object owned by non-constant smart pointer.

Returns
reference to the object owned by this smart pointer.

◆ operator*() [2/2]

template<typename Object >
const Object & TNL::Pointers::UniquePointer< Object, Devices::Host >::operator* ( ) const
inline

Dereferencing operator for accessing the object owned by constant smart pointer.

Returns
constant reference to the object owned by this smart pointer.

◆ operator->() [1/2]

template<typename Object >
Object * TNL::Pointers::UniquePointer< Object, Devices::Host >::operator-> ( )
inline

Arrow operator for accessing the object owned by non-constant smart pointer.

Returns
pointer to the object owned by this smart pointer.

◆ operator->() [2/2]

template<typename Object >
const Object * TNL::Pointers::UniquePointer< Object, Devices::Host >::operator-> ( ) const
inline

Arrow operator for accessing the object owned by constant smart pointer.

Returns
constant pointer to the object owned by this smart pointer.

◆ operator=() [1/2]

template<typename Object >
const UniquePointer & TNL::Pointers::UniquePointer< Object, Devices::Host >::operator= ( UniquePointer< Object, Devices::Host > && ptr)
inlinenoexcept

Move operator.

It assigns object owned by the pointer ptr to this pointer. The original pointer ptr is reset to empty state.

Parameters
ptrinput pointer
Returns
constant reference to this

◆ operator=() [2/2]

template<typename Object >
const UniquePointer & TNL::Pointers::UniquePointer< Object, Devices::Host >::operator= ( UniquePointer< Object, Devices::Host > & ptr)
inline

Assignment operator.

It assigns object owned by the pointer ptr to this pointer. The original pointer ptr is reset to empty state.

Parameters
ptrinput pointer
Returns
constant reference to this

◆ synchronize()

template<typename Object >
bool TNL::Pointers::UniquePointer< Object, Devices::Host >::synchronize ( )
inlineoverridevirtual

Cross-device pointer synchronization.

For the smart pointers in the host, this method does nothing.

Returns
true.

Implements TNL::Pointers::SmartPointer.


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