xref: /honee/include/honee.h (revision 0c70a8bcd2b7fcfffcc94798a5a3a808db05e6f3)
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
4a5677b81SMohi #include <petsc.h>
5a5677b81SMohi #include <stdbool.h>
678c5b8e5SJames Wright typedef struct Honee_private *Honee;
7a5677b81SMohi 
8a5677b81SMohi #define HONEE_VERSION_MAJOR 0
9a5677b81SMohi #define HONEE_VERSION_MINOR 0
10a5677b81SMohi #define HONEE_VERSION_PATCH 0
11a5677b81SMohi #define HONEE_VERSION_RELEASE false
12a5677b81SMohi /// Compile-time check that the the current library version is at least as
13a5677b81SMohi /// recent as the specified version. This macro is typically used in
14a5677b81SMohi /// @code
15a5677b81SMohi /// #if HONEE_VERSION_GE(0, 1, 0)
16a5677b81SMohi ///   code path that needs at least 0.1.0
17a5677b81SMohi /// #else
18a5677b81SMohi ///   fallback code for older versions
19a5677b81SMohi /// #endif
20a5677b81SMohi /// @endcode
21a5677b81SMohi ///
22a5677b81SMohi /// A non-release version always compares as positive infinity.
23a5677b81SMohi ///
24a5677b81SMohi #define HONEE_VERSION_GE(major, minor, patch) \
25a5677b81SMohi   (!HONEE_VERSION_RELEASE ||                  \
26a5677b81SMohi    (HONEE_VERSION_MAJOR > major ||            \
27a5677b81SMohi     (HONEE_VERSION_MAJOR == major && (HONEE_VERSION_MINOR > minor || (HONEE_VERSION_MINOR == minor && HONEE_VERSION_PATCH >= patch)))))
28a5677b81SMohi 
29a5677b81SMohi PetscErrorCode HoneeGetVersion(int *major, int *minor, int *patch, PetscBool *release);
30a5677b81SMohi PetscErrorCode HoneeGetGitVersion(const char **git_version);
31a5677b81SMohi PetscErrorCode HoneeGetBuildConfiguration(const char **build_config);
32*0c70a8bcSJames Wright 
33*0c70a8bcSJames Wright PetscErrorCode HoneeSetContainer(Honee honee, const char key[], void *container, PetscCtxDestroyFn *container_destroy);
34*0c70a8bcSJames Wright PetscErrorCode HoneeGetContainer(Honee honee, const char key[], void *container);
35*0c70a8bcSJames Wright PetscErrorCode HoneeHasContainer(Honee honee, const char key[], PetscBool *has_key);
36