xref: /honee/include/honee.h (revision a8340a88e4f16c7466d3b6f8d21e2d6e377c4c74)
178c5b8e5SJames Wright // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors.
278c5b8e5SJames Wright // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
378c5b8e5SJames Wright #pragma once
4*a8340a88SJames Wright #include <ceed.h>
5a5677b81SMohi #include <petsc.h>
6a5677b81SMohi #include <stdbool.h>
778c5b8e5SJames Wright typedef struct Honee_private *Honee;
8a5677b81SMohi 
9a5677b81SMohi #define HONEE_VERSION_MAJOR 0
10a5677b81SMohi #define HONEE_VERSION_MINOR 0
11a5677b81SMohi #define HONEE_VERSION_PATCH 0
12a5677b81SMohi #define HONEE_VERSION_RELEASE false
13a5677b81SMohi /// Compile-time check that the the current library version is at least as
14a5677b81SMohi /// recent as the specified version. This macro is typically used in
15a5677b81SMohi /// @code
16a5677b81SMohi /// #if HONEE_VERSION_GE(0, 1, 0)
17a5677b81SMohi ///   code path that needs at least 0.1.0
18a5677b81SMohi /// #else
19a5677b81SMohi ///   fallback code for older versions
20a5677b81SMohi /// #endif
21a5677b81SMohi /// @endcode
22a5677b81SMohi ///
23a5677b81SMohi /// A non-release version always compares as positive infinity.
24a5677b81SMohi ///
25a5677b81SMohi #define HONEE_VERSION_GE(major, minor, patch) \
26a5677b81SMohi   (!HONEE_VERSION_RELEASE ||                  \
27a5677b81SMohi    (HONEE_VERSION_MAJOR > major ||            \
28a5677b81SMohi     (HONEE_VERSION_MAJOR == major && (HONEE_VERSION_MINOR > minor || (HONEE_VERSION_MINOR == minor && HONEE_VERSION_PATCH >= patch)))))
29a5677b81SMohi 
30a5677b81SMohi PetscErrorCode HoneeGetVersion(int *major, int *minor, int *patch, PetscBool *release);
31a5677b81SMohi PetscErrorCode HoneeGetGitVersion(const char **git_version);
32a5677b81SMohi PetscErrorCode HoneeGetBuildConfiguration(const char **build_config);
330c70a8bcSJames Wright 
340c70a8bcSJames Wright PetscErrorCode HoneeSetContainer(Honee honee, const char key[], void *container, PetscCtxDestroyFn *container_destroy);
350c70a8bcSJames Wright PetscErrorCode HoneeGetContainer(Honee honee, const char key[], void *container);
360c70a8bcSJames Wright PetscErrorCode HoneeHasContainer(Honee honee, const char key[], PetscBool *has_key);
37