1 #ifndef ABLATELIBRARY_LOGGABLE_HPP
2 #define ABLATELIBRARY_LOGGABLE_HPP
4 #include "demangler.hpp"
5 #include "petscUtilities.hpp"
7 namespace ablate::utilities {
11 inline static PetscClassId petscClassId = 0;
14 mutable PetscLogEvent activeEvent = PETSC_DECIDE;
18 if (petscClassId == 0) {
19 auto className = utilities::Demangler::Demangle(
typeid(T).name());
24 inline const PetscClassId& GetPetscClassId()
const {
return petscClassId; }
26 inline PetscLogEvent RegisterEvent(
const char* eventName) {
27 PetscLogEvent eventId;
32 inline void StartEvent(
const char* eventName)
const {
33 if (activeEvent == PETSC_DECIDE) {
37 throw std::runtime_error(
"Cannot Start Event, an event is already active.");
41 inline void EndEvent()
const {
42 if (activeEvent > 0) {
43 PetscLogEventEnd(activeEvent, 0, 0, 0, 0);
44 activeEvent = PETSC_DECIDE;
46 throw std::runtime_error(
"Cannot End Event. No active event.");
Definition: loggable.hpp:9
static utilities::PetscUtilities::ErrorChecker checkError
Definition: petscUtilities.hpp:46