Loading...
Searching...
No Matches
eonc::ARTnResource Class Reference

#include <ARTnResource.h>

Public Types

using artn_create_fn = int (*)()
using setup_artn_fn = void (*)(const int nat, bool *cerr)
using artn_fn
using artn_destroy_fn = void (*)()
using set_param_fn
using get_param_fn = int (*)(const char *name, void *cval)
using get_runparam_fn = int (*)(const char *name, void *cval)
using get_data_fn = int (*)(const char *name, void **cval)
using print_caller_fn = void (*)()
using artn_step_fn
using get_error_fn = int (*)(void **cmsg)
 Retrieve pARTn error code + c_malloc'd message pointer.

Public Member Functions

bool is_loaded () const noexcept
 True if libartn was successfully loaded.
void require_loaded () const
 Throws std::runtime_error if libartn is not available.
artn_create_fn get_create_fn () const
setup_artn_fn get_setup_fn () const
artn_fn get_artn_fn () const
artn_destroy_fn get_destroy_fn () const
set_param_fn get_set_param_fn () const
get_param_fn get_get_param_fn () const
get_runparam_fn get_get_runparam_fn () const
get_data_fn get_get_data_fn () const
print_caller_fn get_print_caller_fn () const
artn_step_fn get_artn_step_fn () const
get_error_fn get_get_error_fn () const
 May be null on older pARTn builds that predate the C get_error wrapper; callers must null-check before dispatching.
 ARTnResource (const ARTnResource &)=delete
 Non-copyable, non-movable.
ARTnResourceoperator= (const ARTnResource &)=delete

Static Public Member Functions

static ARTnResourceinstance ()
 Singleton accessor (Meyer's pattern).

Public Attributes

std::mutex library_mutex
 Global mutex to ensure only one thread accesses ARTn library at a time.

Private Member Functions

 ARTnResource ()
 ~ARTnResource ()
template<typename Fn>
Fn load_sym (const char *name) const
 Try to load a symbol; returns nullptr on failure.

Private Attributes

bool m_loaded {false}
dynlib::Handle m_handle {}
artn_create_fn artn_create_ {nullptr}
setup_artn_fn setup_artn_ {nullptr}
artn_fn artn_ {nullptr}
artn_destroy_fn artn_destroy_ {nullptr}
set_param_fn set_param_ {nullptr}
get_param_fn get_param_ {nullptr}
get_runparam_fn get_runparam_ {nullptr}
get_data_fn get_data_ {nullptr}
print_caller_fn print_caller_ {nullptr}
artn_step_fn artn_step_ {nullptr}
get_error_fn get_error_ {nullptr}

Detailed Description

Definition at line 34 of file ARTnResource.h.

Member Typedef Documentation

◆ artn_create_fn

Definition at line 37 of file ARTnResource.h.

◆ artn_destroy_fn

Definition at line 43 of file ARTnResource.h.

◆ artn_fn

Initial value:
void (*)(const int nat, const double *etot, const double *f,
int const *ityp, double *const tau, const int *order,
const double *lat, const int *if_pos, int *disp_code,
double *disp_vec, bool *lconv)

Definition at line 39 of file ARTnResource.h.

◆ artn_step_fn

Initial value:
void (*)(const int nat, const double etot,
double *const force, int const *ityp,
double *const pos, const double *box,
const int *if_pos, double *displ_vec,
bool *lconv)

Definition at line 50 of file ARTnResource.h.

◆ get_data_fn

using eonc::ARTnResource::get_data_fn = int (*)(const char *name, void **cval)

Definition at line 48 of file ARTnResource.h.

◆ get_error_fn

using eonc::ARTnResource::get_error_fn = int (*)(void **cmsg)

Retrieve pARTn error code + c_malloc'd message pointer.

Defined in m_artn_error.f90 as bind(C, name="get_error"): int get_error(void** cmsg); Non-zero return indicates an error; *cmsg then points at a C-string the caller must std::free. Zero leaves *cmsg null.

Definition at line 60 of file ARTnResource.h.

◆ get_param_fn

using eonc::ARTnResource::get_param_fn = int (*)(const char *name, void *cval)

Definition at line 46 of file ARTnResource.h.

◆ get_runparam_fn

using eonc::ARTnResource::get_runparam_fn = int (*)(const char *name, void *cval)

Definition at line 47 of file ARTnResource.h.

◆ print_caller_fn

Definition at line 49 of file ARTnResource.h.

◆ set_param_fn

Initial value:
int (*)(const char *const name, const int crank,
const int *csize, const void *cval)

Definition at line 44 of file ARTnResource.h.

◆ setup_artn_fn

using eonc::ARTnResource::setup_artn_fn = void (*)(const int nat, bool *cerr)

Definition at line 38 of file ARTnResource.h.

Constructor & Destructor Documentation

◆ ARTnResource() [1/2]

eonc::ARTnResource::ARTnResource ( const ARTnResource & )
delete

Non-copyable, non-movable.

◆ ARTnResource() [2/2]

eonc::ARTnResource::ARTnResource ( )
private

◆ ~ARTnResource()

eonc::ARTnResource::~ARTnResource ( )
private

Member Function Documentation

◆ get_artn_fn()

artn_fn eonc::ARTnResource::get_artn_fn ( ) const
inline

Definition at line 77 of file ARTnResource.h.

77{ return artn_; }

◆ get_artn_step_fn()

artn_step_fn eonc::ARTnResource::get_artn_step_fn ( ) const
inline

Definition at line 84 of file ARTnResource.h.

84{ return artn_step_; }
artn_step_fn artn_step_

◆ get_create_fn()

artn_create_fn eonc::ARTnResource::get_create_fn ( ) const
inline

Definition at line 75 of file ARTnResource.h.

75{ return artn_create_; }
artn_create_fn artn_create_

◆ get_destroy_fn()

artn_destroy_fn eonc::ARTnResource::get_destroy_fn ( ) const
inline

Definition at line 78 of file ARTnResource.h.

78{ return artn_destroy_; }
artn_destroy_fn artn_destroy_

◆ get_get_data_fn()

get_data_fn eonc::ARTnResource::get_get_data_fn ( ) const
inline

Definition at line 82 of file ARTnResource.h.

82{ return get_data_; }
get_data_fn get_data_

◆ get_get_error_fn()

get_error_fn eonc::ARTnResource::get_get_error_fn ( ) const
inline

May be null on older pARTn builds that predate the C get_error wrapper; callers must null-check before dispatching.

Definition at line 87 of file ARTnResource.h.

87{ return get_error_; }
get_error_fn get_error_

◆ get_get_param_fn()

get_param_fn eonc::ARTnResource::get_get_param_fn ( ) const
inline

Definition at line 80 of file ARTnResource.h.

80{ return get_param_; }
get_param_fn get_param_

◆ get_get_runparam_fn()

get_runparam_fn eonc::ARTnResource::get_get_runparam_fn ( ) const
inline

Definition at line 81 of file ARTnResource.h.

81{ return get_runparam_; }
get_runparam_fn get_runparam_

◆ get_print_caller_fn()

print_caller_fn eonc::ARTnResource::get_print_caller_fn ( ) const
inline

Definition at line 83 of file ARTnResource.h.

83{ return print_caller_; }
print_caller_fn print_caller_

◆ get_set_param_fn()

set_param_fn eonc::ARTnResource::get_set_param_fn ( ) const
inline

Definition at line 79 of file ARTnResource.h.

79{ return set_param_; }
set_param_fn set_param_

◆ get_setup_fn()

setup_artn_fn eonc::ARTnResource::get_setup_fn ( ) const
inline

Definition at line 76 of file ARTnResource.h.

76{ return setup_artn_; }
setup_artn_fn setup_artn_

◆ instance()

ARTnResource & eonc::ARTnResource::instance ( )
static

Singleton accessor (Meyer's pattern).

◆ is_loaded()

bool eonc::ARTnResource::is_loaded ( ) const
inlinenodiscardnoexcept

True if libartn was successfully loaded.

Definition at line 69 of file ARTnResource.h.

69{ return m_loaded; }

◆ load_sym()

template<typename Fn>
Fn eonc::ARTnResource::load_sym ( const char * name) const
inlineprivate

Try to load a symbol; returns nullptr on failure.

Definition at line 114 of file ARTnResource.h.

114 {
115 return reinterpret_cast<Fn>(dynlib::sym(m_handle, name));
116 }
dynlib::Handle m_handle
void * sym(Handle h, const char *name) noexcept
Definition DynLib.h:75

◆ operator=()

ARTnResource & eonc::ARTnResource::operator= ( const ARTnResource & )
delete

◆ require_loaded()

void eonc::ARTnResource::require_loaded ( ) const

Throws std::runtime_error if libartn is not available.

Member Data Documentation

◆ artn_

artn_fn eonc::ARTnResource::artn_ {nullptr}
private

Definition at line 103 of file ARTnResource.h.

103{nullptr};

◆ artn_create_

artn_create_fn eonc::ARTnResource::artn_create_ {nullptr}
private

Definition at line 101 of file ARTnResource.h.

101{nullptr};

◆ artn_destroy_

artn_destroy_fn eonc::ARTnResource::artn_destroy_ {nullptr}
private

Definition at line 104 of file ARTnResource.h.

104{nullptr};

◆ artn_step_

artn_step_fn eonc::ARTnResource::artn_step_ {nullptr}
private

Definition at line 110 of file ARTnResource.h.

110{nullptr};

◆ get_data_

get_data_fn eonc::ARTnResource::get_data_ {nullptr}
private

Definition at line 108 of file ARTnResource.h.

108{nullptr};

◆ get_error_

get_error_fn eonc::ARTnResource::get_error_ {nullptr}
private

Definition at line 111 of file ARTnResource.h.

111{nullptr};

◆ get_param_

get_param_fn eonc::ARTnResource::get_param_ {nullptr}
private

Definition at line 106 of file ARTnResource.h.

106{nullptr};

◆ get_runparam_

get_runparam_fn eonc::ARTnResource::get_runparam_ {nullptr}
private

Definition at line 107 of file ARTnResource.h.

107{nullptr};

◆ library_mutex

std::mutex eonc::ARTnResource::library_mutex

Global mutex to ensure only one thread accesses ARTn library at a time.

Definition at line 66 of file ARTnResource.h.

◆ m_handle

dynlib::Handle eonc::ARTnResource::m_handle {}
private

Definition at line 98 of file ARTnResource.h.

98{};

◆ m_loaded

bool eonc::ARTnResource::m_loaded {false}
private

Definition at line 97 of file ARTnResource.h.

97{false};

◆ print_caller_

print_caller_fn eonc::ARTnResource::print_caller_ {nullptr}
private

Definition at line 109 of file ARTnResource.h.

109{nullptr};

◆ set_param_

set_param_fn eonc::ARTnResource::set_param_ {nullptr}
private

Definition at line 105 of file ARTnResource.h.

105{nullptr};

◆ setup_artn_

setup_artn_fn eonc::ARTnResource::setup_artn_ {nullptr}
private

Definition at line 102 of file ARTnResource.h.

102{nullptr};

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