Public Member Functions | Public Attributes | Private Member Functions | List of all members
PLMD::Plumed::SafePtr Class Reference

Small class that wraps plumed_safeptr in order to make its initialization easier. More...

Public Member Functions

 SafePtr () noexcept
 Default constructor, nullptr. More...
 
 SafePtr (__PLUMED_WRAPPER_STD nullptr_t, __PLUMED_WRAPPER_STD size_t nelem, const __PLUMED_WRAPPER_STD size_t *shape) noexcept
 Construct from null. More...
 
 SafePtr (const plumed_safeptr &safe, __PLUMED_WRAPPER_STD size_t nelem=0, const __PLUMED_WRAPPER_STD size_t *shape=__PLUMED_WRAPPER_CXX_NULLPTR) noexcept
 
plumed_safeptr get_safeptr () const noexcept
 Here we create all the required instances 1: void 3: integral 4: floating 5: FILE 0x100: unsigned. More...
 

Public Attributes

char buffer [32]
 This buffer holds a copy of the data when they are passed by value. More...
 
plumed_safeptr safe
 

Private Member Functions

 SafePtr (const SafePtr &)
 non copyable (copy would require managing buffer, could be added in the future if needed) More...
 
SafePtroperator= (SafePtr const &)
 non assignable (assignment would require managing buffer, could be added in the future if needed) More...
 

Detailed Description

Small class that wraps plumed_safeptr in order to make its initialization easier.

Constructor & Destructor Documentation

◆ SafePtr() [1/4]

PLMD::Plumed::SafePtr::SafePtr ( const SafePtr )
private

non copyable (copy would require managing buffer, could be added in the future if needed)

◆ SafePtr() [2/4]

PLMD::Plumed::SafePtr::SafePtr ( )
inlinenoexcept

Default constructor, nullptr.

◆ SafePtr() [3/4]

PLMD::Plumed::SafePtr::SafePtr ( const plumed_safeptr safe,
__PLUMED_WRAPPER_STD size_t  nelem = 0,
const __PLUMED_WRAPPER_STD size_t *  shape = __PLUMED_WRAPPER_CXX_NULLPTR 
)
inlineexplicitnoexcept

◆ SafePtr() [4/4]

PLMD::Plumed::SafePtr::SafePtr ( __PLUMED_WRAPPER_STD  nullptr_t,
__PLUMED_WRAPPER_STD size_t  nelem,
const __PLUMED_WRAPPER_STD size_t *  shape 
)
inlinenoexcept

Construct from null.

Member Function Documentation

◆ get_safeptr()

plumed_safeptr PLMD::Plumed::SafePtr::get_safeptr ( ) const
inlinenoexcept

Here we create all the required instances 1: void 3: integral 4: floating 5: FILE 0x100: unsigned.

Return the contained plumed_safeptr

◆ operator=()

SafePtr& PLMD::Plumed::SafePtr::operator= ( SafePtr const &  )
private

non assignable (assignment would require managing buffer, could be added in the future if needed)

Member Data Documentation

◆ buffer

char PLMD::Plumed::SafePtr::buffer[32]

This buffer holds a copy of the data when they are passed by value.

The size is sufficient to hold any primitive type. Notice that the buffer is required to enable conversions (e.g., passing a class that can be converted to int) and, at the same time, allow the object to exist after SafePtr constructor has completed. A perhaps cleaner implementation would require a base class containing the plumed_safeptr object, derived classes depending on the argument type as a template parameter, and overloaded functions returning this derived class.

◆ safe

plumed_safeptr PLMD::Plumed::SafePtr::safe

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