expose new introspection to library interfaces for consistency

This commit is contained in:
Axel Kohlmeyer
2024-08-07 10:37:20 -04:00
parent 937c17f3b8
commit f197ce3165
7 changed files with 52 additions and 0 deletions

View File

@ -150,6 +150,7 @@ liblammpsplugin_t *liblammpsplugin_load(const char *lib)
ADDSYM(config_has_png_support);
ADDSYM(config_has_jpeg_support);
ADDSYM(config_has_ffmpeg_support);
ADDSYM(config_has_curl_support);
ADDSYM(config_has_exceptions);
ADDSYM(config_has_package);

View File

@ -203,6 +203,7 @@ struct _liblammpsplugin {
int (*config_has_png_support)();
int (*config_has_jpeg_support)();
int (*config_has_ffmpeg_support)();
int (*config_has_curl_support)();
int (*config_has_exceptions)();
int (*config_has_package)(const char *);

View File

@ -196,6 +196,7 @@ MODULE LIBLAMMPS
PROCEDURE, NOPASS :: config_has_jpeg_support => lmp_config_has_jpeg_support
PROCEDURE, NOPASS :: config_has_ffmpeg_support &
=> lmp_config_has_ffmpeg_support
PROCEDURE, NOPASS :: config_has_curl_support => lmp_config_has_curl_support
PROCEDURE, NOPASS :: config_has_exceptions => lmp_config_has_exceptions
PROCEDURE, NOPASS :: config_has_package => lmp_config_has_package
PROCEDURE, NOPASS :: config_package_count => lammps_config_package_count
@ -793,6 +794,12 @@ MODULE LIBLAMMPS
INTEGER(c_int) :: lammps_config_has_ffmpeg_support
END FUNCTION lammps_config_has_ffmpeg_support
FUNCTION lammps_config_has_curl_support() BIND(C)
IMPORT :: c_int
IMPLICIT NONE
INTEGER(c_int) :: lammps_config_has_curl_support
END FUNCTION lammps_config_has_curl_support
FUNCTION lammps_config_has_exceptions() BIND(C)
IMPORT :: c_int
IMPLICIT NONE
@ -2881,6 +2888,14 @@ CONTAINS
lmp_config_has_ffmpeg_support = (has_ffmpeg_support /= 0_c_int)
END FUNCTION lmp_config_has_ffmpeg_support
! equivalent function to lammps_config_has_curl_support
LOGICAL FUNCTION lmp_config_has_curl_support()
INTEGER(c_int) :: has_curl_support
has_curl_support = lammps_config_has_curl_support()
lmp_config_has_curl_support = (has_curl_support /= 0_c_int)
END FUNCTION lmp_config_has_curl_support
! equivalent function to lammps_config_has_exceptions
LOGICAL FUNCTION lmp_config_has_exceptions()
INTEGER(c_int) :: has_exceptions

View File

@ -1969,6 +1969,21 @@ class lammps(object):
# -------------------------------------------------------------------------
@property
def has_curl_support(self):
""" Report whether the LAMMPS shared library was compiled with support
for downloading files through libcurl.
This is a wrapper around the :cpp:func:`lammps_config_has_curl_support`
function of the library interface.
:return: state of CURL support
:rtype: bool
"""
return self.lib.lammps_config_has_curl_support() != 0
# -------------------------------------------------------------------------
def has_package(self, name):
""" Report if the named package has been enabled in the LAMMPS shared library.

View File

@ -5877,6 +5877,23 @@ int lammps_config_has_ffmpeg_support() {
/* ---------------------------------------------------------------------- */
/** Check if the LAMMPS library supports downloading files via libcurl
\verbatim embed:rst
The LAMMPS :doc:`geturl command <geturl>` supports downloading files
through using `the libcurl library <https://curl.se/libcurl/>`_.
This function checks whether this feature was :ref:`enabled at compile
time <libcurl>` and LAMMPS linked to the libcurl library.
\endverbatim
*
* \return 1 if yes, otherwise 0
*/
int lammps_config_has_curl_support() {
return Info::has_curl_support() ? 1 : 0;
}
/* ---------------------------------------------------------------------- */
/** Check whether LAMMPS errors will throw C++ exceptions.
*
\verbatim embed:rst

View File

@ -243,6 +243,7 @@ int lammps_config_has_gzip_support();
int lammps_config_has_png_support();
int lammps_config_has_jpeg_support();
int lammps_config_has_ffmpeg_support();
int lammps_config_has_curl_support();
int lammps_config_has_exceptions();
int lammps_config_has_package(const char *);

View File

@ -171,6 +171,7 @@ extern int lammps_config_has_gzip_support();
extern int lammps_config_has_png_support();
extern int lammps_config_has_jpeg_support();
extern int lammps_config_has_ffmpeg_support();
extern int lammps_config_has_curl_support();
extern int lammps_config_has_exceptions();
extern int lammps_config_has_package(const char *);
extern int lammps_config_package_count();
@ -359,6 +360,7 @@ extern int lammps_config_has_gzip_support();
extern int lammps_config_has_png_support();
extern int lammps_config_has_jpeg_support();
extern int lammps_config_has_ffmpeg_support();
extern int lammps_config_has_curl_support();
extern int lammps_config_has_exceptions();
extern int lammps_config_has_package(const char *);
extern int lammps_config_package_count();