Loading...
Searching...
No Matches
MetatomicLoader.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Runtime loader for libmetatomic_pot.so (C ABI).
7*/
8#pragma once
9
10#include "eon/DynLib.h"
11#include "metatomic_c_abi.h"
12
13#include <stdexcept>
14#include <string>
15
16namespace eonc {
17
19public:
20 using create_fn = EonMtaPot *(*)(const EonMtaConfig *, char *, size_t);
21 using destroy_fn = void (*)(EonMtaPot *);
22 using force_fn = int (*)(EonMtaPot *, long, const double *, const int *,
23 double *, double *, double *, const double *);
24 using abi_version_fn = int (*)(void);
25
26 static MetatomicLoader &instance();
27
29 bool try_load();
30
31 [[nodiscard]] bool is_loaded() const noexcept { return m_loaded; }
32 void require_loaded();
33
34 create_fn create{nullptr};
36 force_fn force{nullptr};
38
41
42private:
43 MetatomicLoader() = default;
45
46 bool m_loaded{false};
48};
49
50} // namespace eonc
bool try_load()
Attempt (re)load if not yet successful. Safe after potentials_path inject.
MetatomicLoader & operator=(const MetatomicLoader &)=delete
int(*)(void) abi_version_fn
static MetatomicLoader & instance()
MetatomicLoader(const MetatomicLoader &)=delete
bool is_loaded() const noexcept
void(*)(EonMtaPot *) destroy_fn
EonMtaPot *(*)(const EonMtaConfig *, char *, size_t) create_fn
dynlib::Handle m_handle
abi_version_fn abi_version
int(*)(EonMtaPot *, long, const double *, const int *, double *, double *, double *, const double *) force_fn
void * Handle
Definition DynLib.h:60
RAII resource manager for the ARTn C library with global synchronization.
Flat config for create (mirrors Parameters::metatomic_options_t).