Template Numerical Library version\ main:f17d0c8
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TNL::Pointers::SharedPointer< Object, Devices::Host > Class Template Reference

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

#include <TNL/Pointers/SharedPointerHost.h>

Inheritance diagram for TNL::Pointers::SharedPointer< Object, Devices::Host >:
Inheritance graph
[legend]
Collaboration diagram for TNL::Pointers::SharedPointer< Object, Devices::Host >:
Collaboration graph
[legend]

Classes

struct  PointerData
 

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>
 SharedPointer (Args... args)
 Constructor with parameters of the Object constructor.
 
 SharedPointer (const SharedPointer &pointer)
 Copy constructor.
 
template<typename Object_ , typename = Enabler< Object_ >>
 SharedPointer (const SharedPointer< Object_, DeviceType > &pointer)
 Copy constructor.
 
 SharedPointer (SharedPointer &&pointer) noexcept
 Move constructor.
 
template<typename Object_ , typename = Enabler< Object_ >>
 SharedPointer (SharedPointer< Object_, DeviceType > &&pointer)
 Move constructor.
 
template<typename Value >
 SharedPointer (std::initializer_list< std::initializer_list< Value > > list)
 Constructor with nested initializer lists.
 
template<typename Value >
 SharedPointer (std::initializer_list< Value > list)
 Constructor with initializer list.
 
 SharedPointer (std::nullptr_t)
 Constructor of an empty pointer.
 
 ~SharedPointer () override
 Destructor.
 
void clear ()
 Reset the pointer to empty state.
 
template<typename Device = Devices::Host>
__cuda_callable__ const ObjectgetData () const
 Constant object reference getter.
 
template<typename Device = Devices::Host>
__cuda_callable__ ObjectmodifyData ()
 Non-constant object reference getter.
 
 operator bool () const
 Conversion to boolean type.
 
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 SharedPointeroperator= (const SharedPointer &ptr)
 Assignment operator.
 
template<typename Object_ , typename = Enabler< Object_ >>
const SharedPointeroperator= (const SharedPointer< Object_, DeviceType > &ptr)
 Assignment operator for compatible object types.
 
const SharedPointeroperator= (SharedPointer &&ptr) noexcept
 Move operator.
 
template<typename Object_ , typename = Enabler< Object_ >>
const SharedPointeroperator= (SharedPointer< Object_, DeviceType > &&ptr)
 Move operator.
 
template<typename... Args>
bool recreate (Args... args)
 Create new object based in given constructor parameters.
 
void swap (SharedPointer &ptr2)
 Swap the owned object with another pointer.
 
bool synchronize () override
 Cross-device pointer synchronization.
 

Protected Member Functions

template<typename... Args>
bool allocate (Args... args)
 
void free ()
 

Protected Attributes

PointerData * pd
 

Detailed Description

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

Specialization of the SharedPointer for the host system.

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

Constructor & Destructor Documentation

◆ SharedPointer() [1/7]

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

Constructor with parameters of the Object constructor.

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

◆ SharedPointer() [2/7]

template<typename Object >
template<typename Value >
TNL::Pointers::SharedPointer< Object, Devices::Host >::SharedPointer ( 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..

◆ SharedPointer() [3/7]

template<typename Object >
template<typename Value >
TNL::Pointers::SharedPointer< Object, Devices::Host >::SharedPointer ( 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..

◆ SharedPointer() [4/7]

template<typename Object >
TNL::Pointers::SharedPointer< Object, Devices::Host >::SharedPointer ( const SharedPointer< Object, Devices::Host > & pointer)
inline

Copy constructor.

Parameters
pointeris the source shared pointer.

◆ SharedPointer() [5/7]

template<typename Object >
template<typename Object_ , typename = Enabler< Object_ >>
TNL::Pointers::SharedPointer< Object, Devices::Host >::SharedPointer ( const SharedPointer< Object_, DeviceType > & pointer)
inline

Copy constructor.

This is specialization for compatible object types.

Parameters
pointeris the source shared pointer.

◆ SharedPointer() [6/7]

template<typename Object >
TNL::Pointers::SharedPointer< Object, Devices::Host >::SharedPointer ( SharedPointer< Object, Devices::Host > && pointer)
inlinenoexcept

Move constructor.

Parameters
pointeris the source shared pointer.

◆ SharedPointer() [7/7]

template<typename Object >
template<typename Object_ , typename = Enabler< Object_ >>
TNL::Pointers::SharedPointer< Object, Devices::Host >::SharedPointer ( SharedPointer< Object_, DeviceType > && pointer)
inline

Move constructor.

This is specialization for compatible object types.

Parameters
pointeris the source shared pointer.

Member Function Documentation

◆ getData()

template<typename Object >
template<typename Device = Devices::Host>
__cuda_callable__ const Object & TNL::Pointers::SharedPointer< Object, Devices::Host >::getData ( ) const
inline

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>
__cuda_callable__ Object & TNL::Pointers::SharedPointer< Object, Devices::Host >::modifyData ( )
inline

Non-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.

◆ operator bool()

template<typename Object >
TNL::Pointers::SharedPointer< 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 >
bool TNL::Pointers::SharedPointer< 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::SharedPointer< 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::SharedPointer< 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::SharedPointer< 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::SharedPointer< 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/4]

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

Assignment operator.

It assigns object owned by the pointer ptr to this pointer.

Parameters
ptrinput pointer
Returns
constant reference to this

◆ operator=() [2/4]

template<typename Object >
template<typename Object_ , typename = Enabler< Object_ >>
const SharedPointer & TNL::Pointers::SharedPointer< Object, Devices::Host >::operator= ( const SharedPointer< Object_, DeviceType > & ptr)
inline

Assignment operator for compatible object types.

It assigns object owned by the pointer ptr to this pointer.

Parameters
ptrinput pointer
Returns
constant reference to this

◆ operator=() [3/4]

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

Move operator.

It assigns object owned by the pointer ptr to this pointer.

Parameters
ptrinput pointer
Returns
constant reference to this

◆ operator=() [4/4]

template<typename Object >
template<typename Object_ , typename = Enabler< Object_ >>
const SharedPointer & TNL::Pointers::SharedPointer< Object, Devices::Host >::operator= ( SharedPointer< Object_, DeviceType > && ptr)
inline

Move operator.

It assigns object owned by the pointer ptr to this pointer.

Parameters
ptrinput pointer
Returns
constant reference to this

◆ recreate()

template<typename Object >
template<typename... Args>
bool TNL::Pointers::SharedPointer< Object, Devices::Host >::recreate ( Args... args)
inline

Create new object based in given constructor parameters.

Template Parameters
Argsis variadic template type of arguments to be passed to the object constructor.
Parameters
argsare arguments to be passed to the object constructor.
Returns
true if recreation was successful, false otherwise.

◆ swap()

template<typename Object >
void TNL::Pointers::SharedPointer< Object, Devices::Host >::swap ( SharedPointer< Object, Devices::Host > & ptr2)
inline

Swap the owned object with another pointer.

Parameters
ptr2the other shared pointer for swapping.

◆ synchronize()

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

Cross-device pointer synchronization.

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

Returns
true.

Implements TNL::Pointers::SmartPointer.


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