GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
ReadconDbAbi.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
// See LICENSE for details.
4
#pragma once
5
6
// ABI contract with readcon-db. The header must carry the major gpridge is
7
// written for and a minor at or above the lowest minor that declares the
8
// archive and trajectory calls gpridge makes; the loaded library must
9
// accept the stamp built from that header.
10
11
#include <readcon-db.h>
12
13
#include <cstdint>
14
#include <mutex>
15
#include <sstream>
16
#include <stdexcept>
17
#include <string>
18
20
#define GPR_READCON_DB_ABI_MAJOR 1
23
#define GPR_READCON_DB_ABI_MIN_MINOR 0
24
25
static_assert
(RKRDB_ABI_VERSION_MAJOR ==
GPR_READCON_DB_ABI_MAJOR
,
26
"gpridge is written against readcon-db C ABI major "
27
"GPR_READCON_DB_ABI_MAJOR; the readcon-db.h found declares "
28
"another major"
);
29
static_assert
(RKRDB_ABI_VERSION_MINOR >=
GPR_READCON_DB_ABI_MIN_MINOR
,
30
"readcon-db C ABI is older than gpridge needs "
31
"(see subprojects/readcon-db.wrap)"
);
32
33
namespace
gpr::readcon_db_abi
{
34
35
struct
Stamp
{
36
std::uint32_t
major
= 0;
37
std::uint32_t
minor
= 0;
38
std::uint32_t
layout
= 0;
39
};
40
41
[[nodiscard]]
inline
std::string
describe
(
const
Stamp
& stamp)
42
{
43
std::ostringstream
out
;
44
out
<< stamp.
major
<<
'.'
<< stamp.
minor
<<
" layout "
<< stamp.
layout
;
45
return
out
.str();
46
}
47
52
[[nodiscard]]
inline
std::string
mismatch
(
const
Stamp
& header,
53
const
Stamp
& library,
54
bool
library_accepts)
55
{
56
if
(library_accepts && header.
major
== library.
major
&&
57
header.
layout
== library.
layout
)
58
return
{};
59
return
"readcon-db ABI mismatch: gpridge was built against "
60
"readcon-db.h "
+
61
describe
(header) +
" and the loaded library reports "
+
62
describe
(library) +
63
(library_accepts ?
""
:
" and rejects the header's stamp"
);
64
}
65
66
[[nodiscard]]
inline
Stamp
headerStamp
() noexcept
67
{
68
return
{RKRDB_ABI_VERSION_MAJOR, RKRDB_ABI_VERSION_MINOR,
69
RKRDB_ABI_LAYOUT_REVISION};
70
}
71
72
[[nodiscard]]
inline
Stamp
libraryStamp
()
73
{
74
return
{rkrdb_abi_version_major(), rkrdb_abi_version_minor(),
75
rkrdb_abi_layout_revision()};
76
}
77
79
[[nodiscard]]
inline
std::string
loadedLibraryMismatch
()
80
{
81
const
Stamp
header =
headerStamp
();
82
return
mismatch
(
83
header,
libraryStamp
(),
84
rkrdb_abi_compatible(header.
major
, header.
minor
, header.
layout
) != 0);
85
}
86
89
inline
void
requireCompatibleLibrary
()
90
{
91
static
std::once_flag checked;
92
static
std::string failure;
93
std::call_once(checked, [] { failure =
loadedLibraryMismatch
(); });
94
if
(!failure.empty())
throw
std::runtime_error(failure);
95
}
96
97
}
// namespace gpr::readcon_db_abi
GPR_READCON_DB_ABI_MAJOR
#define GPR_READCON_DB_ABI_MAJOR
Major of the readcon-db C ABI gpridge is written against.
Definition
ReadconDbAbi.h:20
GPR_READCON_DB_ABI_MIN_MINOR
#define GPR_READCON_DB_ABI_MIN_MINOR
Definition
ReadconDbAbi.h:23
out
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Definition
eon_relax_engine.h:240
gpr::readcon_db_abi
Definition
ReadconDbAbi.h:33
gpr::readcon_db_abi::loadedLibraryMismatch
std::string loadedLibraryMismatch()
The mismatch message for the loaded library; empty when compatible.
Definition
ReadconDbAbi.h:79
gpr::readcon_db_abi::mismatch
std::string mismatch(const Stamp &header, const Stamp &library, bool library_accepts)
Definition
ReadconDbAbi.h:52
gpr::readcon_db_abi::headerStamp
Stamp headerStamp() noexcept
Definition
ReadconDbAbi.h:66
gpr::readcon_db_abi::describe
std::string describe(const Stamp &stamp)
Definition
ReadconDbAbi.h:41
gpr::readcon_db_abi::requireCompatibleLibrary
void requireCompatibleLibrary()
Definition
ReadconDbAbi.h:89
gpr::readcon_db_abi::libraryStamp
Stamp libraryStamp()
Definition
ReadconDbAbi.h:72
gpr::readcon_db_abi::Stamp
Definition
ReadconDbAbi.h:35
gpr::readcon_db_abi::Stamp::layout
std::uint32_t layout
Definition
ReadconDbAbi.h:38
gpr::readcon_db_abi::Stamp::minor
std::uint32_t minor
Definition
ReadconDbAbi.h:37
gpr::readcon_db_abi::Stamp::major
std::uint32_t major
Definition
ReadconDbAbi.h:36
managers
io
ReadconDbAbi.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf