diff --git a/base/src/main/java/de/staropensource/sosengine/base/Engine.java b/base/src/main/java/de/staropensource/sosengine/base/Engine.java index 1fd83420..720078d0 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/Engine.java +++ b/base/src/main/java/de/staropensource/sosengine/base/Engine.java @@ -319,14 +319,16 @@ public final class Engine implements SubsystemMainClass { // Initialize subsystems logger.info("Initializing engine subsystems"); + long initTime; for (DependencySubsystemVector vector : subsystems) { - logger.verb("Initializing subsystem " + vector.getMainClass().getClass().getName()); + logger.diag("Initializing subsystem " + vector.getMainClass().getName() + " (" + vector.getMainClass().getClass().getName() + ")"); try { - vector.getMainClass().initializeSubsystem(); + initTime = Miscellaneous.measureExecutionTime(() -> vector.getMainClass().initializeSubsystem()); } catch (Throwable throwable) { - logger.crash("An error occurred trying to initialize subsystem " + vector.getMainClass().getClass().getName() + ": " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage())); + logger.crash("An error occurred trying to initialize subsystem " + vector.getMainClass().getName() + " (" + vector.getMainClass().getClass().getName() + "): " + throwable.getClass().getName() + (throwable.getMessage() == null ? "" : ": " + throwable.getMessage())); throw throwable; } + logger.diag("Initialized subsystem " + vector.getMainClass().getName() + " (" + vector.getMainClass().getClass().getName() + ") in " + initTime + "ms"); } // Update 'subsystems' @@ -363,6 +365,15 @@ public final class Engine implements SubsystemMainClass { Runtime.getRuntime().exit(exitCode); } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getName() { + return "base"; + } + /** {@inheritDoc} */ @Override public void initializeSubsystem() {} diff --git a/base/src/main/java/de/staropensource/sosengine/base/annotations/EngineSubsystem.java b/base/src/main/java/de/staropensource/sosengine/base/annotations/EngineSubsystem.java index 090e2710..290da870 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/annotations/EngineSubsystem.java +++ b/base/src/main/java/de/staropensource/sosengine/base/annotations/EngineSubsystem.java @@ -19,11 +19,16 @@ package de.staropensource.sosengine.base.annotations; +import de.staropensource.sosengine.base.classes.SubsystemMainClass; + import java.lang.annotation.*; /** * This annotation marks a class as a subsystem main class. + *

+ * Make sure your subsystem implements {@link SubsystemMainClass}. * + * @see SubsystemMainClass * @since v1-alpha1 */ @SuppressWarnings("unused") diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemMainClass.java b/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemMainClass.java index b7a22253..d69134f3 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemMainClass.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemMainClass.java @@ -20,6 +20,7 @@ package de.staropensource.sosengine.base.classes; import de.staropensource.sosengine.base.Engine; +import de.staropensource.sosengine.base.annotations.EngineSubsystem; import de.staropensource.sosengine.base.annotations.EventListener; import de.staropensource.sosengine.base.internal.events.InternalEngineShutdownEvent; import de.staropensource.sosengine.base.logging.LoggerInstance; @@ -29,6 +30,7 @@ import org.jetbrains.annotations.NotNull; /** * The interface for engine subsystem main classes. * + * @see EngineSubsystem * @since v1-alpha0 */ @SuppressWarnings({ "unused" }) @@ -41,6 +43,14 @@ public interface SubsystemMainClass { */ LoggerInstance logger = null; + /** + * Returns the name of this subsystem. + * + * @since v1-alpha2 + */ + @NotNull + String getName(); + /** * Initializes this subsystem. * diff --git a/base/src/main/javadoc/overview.html b/base/src/main/javadoc/overview.html index 503a23db..d79ef2df 100644 --- a/base/src/main/javadoc/overview.html +++ b/base/src/main/javadoc/overview.html @@ -20,11 +20,4 @@

Welcome to the sos!engine API documentation!
You are currently in the documentation for the base subsystem, the core of the engine.

The most interesting parts for developers wanting to use the engine are:

- diff --git a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java index 648b5321..db20d389 100644 --- a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java +++ b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java @@ -40,6 +40,8 @@ import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFWErrorCallback; import org.lwjgl.system.MemoryUtil; +import java.util.Locale; + import static org.lwjgl.glfw.GLFW.*; /** @@ -98,18 +100,21 @@ public final class OpenGlSubsystem implements ApiMainClass { } } + /** {@inheritDoc} */ + @NotNull + @Override + public String getName() { + return getApiName().toLowerCase(Locale.ROOT); + } + /** {@inheritDoc} */ @Override public void initializeSubsystem() { - long initTime = Miscellaneous.measureExecutionTime(() -> { - // Precompute event listeners - EventHelper.precomputeEventListeners(GraphicsErrorEvent.class); + // Precompute event listeners + EventHelper.precomputeEventListeners(GraphicsErrorEvent.class); - // Register Graphics API - GraphicsSubsystem.getInstance().registerGraphicsApi(this); - }); - - logger.verb("Initialized subsystem in " + initTime + "ms"); + // Register Graphics API + GraphicsSubsystem.getInstance().registerGraphicsApi(this); } /** {@inheritDoc} */ diff --git a/graphics/src/main/java/de/staropensource/sosengine/graphics/GraphicsSubsystem.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/GraphicsSubsystem.java index 3cfb6642..0b6e8632 100644 --- a/graphics/src/main/java/de/staropensource/sosengine/graphics/GraphicsSubsystem.java +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/GraphicsSubsystem.java @@ -118,23 +118,25 @@ public final class GraphicsSubsystem implements SubsystemMainClass { instance = this; else { instance.logger.crash("Graphics subsystem tried to initialize twice"); - return; } } + /** {@inheritDoc} */ + @NotNull + @Override + public String getName() { + return "graphics"; + } + /** {@inheritDoc} */ @Override public void initializeSubsystem() { - long initTime = Miscellaneous.measureExecutionTime(() -> { - // Initialize GraphicsSubsystemConfiguration and load it - new GraphicsSubsystemConfiguration(); - GraphicsSubsystemConfiguration.getInstance().loadConfiguration(); + // Initialize GraphicsSubsystemConfiguration and load it + new GraphicsSubsystemConfiguration(); + GraphicsSubsystemConfiguration.getInstance().loadConfiguration(); - // Precompute event listeners - precomputeEventListeners(); - }); - - logger.verb("Initialized subsystem in " + initTime + "ms"); + // Precompute event listeners + precomputeEventListeners(); } /** diff --git a/graphics/vulkan/src/main/java/de/staropensource/sosengine/graphics/vulkan/VulkanSubsystem.java b/graphics/vulkan/src/main/java/de/staropensource/sosengine/graphics/vulkan/VulkanSubsystem.java index 37257500..99ef7990 100644 --- a/graphics/vulkan/src/main/java/de/staropensource/sosengine/graphics/vulkan/VulkanSubsystem.java +++ b/graphics/vulkan/src/main/java/de/staropensource/sosengine/graphics/vulkan/VulkanSubsystem.java @@ -37,6 +37,8 @@ import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFWErrorCallback; +import java.util.Locale; + import static org.lwjgl.glfw.GLFW.*; /** @@ -96,18 +98,21 @@ public final class VulkanSubsystem implements ApiMainClass { } } + /** {@inheritDoc} */ + @NotNull + @Override + public String getName() { + return getApiName().toLowerCase(Locale.ROOT); + } + /** {@inheritDoc} */ @Override public void initializeSubsystem() { - long initTime = Miscellaneous.measureExecutionTime(() -> { - // Warn about instability - logger.warn("The Vulkan Graphics API is in an unfinished state. Trying to initialize the Graphics API will cause an engine crash."); + // Warn about instability + logger.warn("The Vulkan Graphics API is in an unfinished state. Trying to initialize the Graphics API will cause an engine crash."); - // Register Graphics API - GraphicsSubsystem.getInstance().registerGraphicsApi(this); - }); - - logger.verb("Initialized subsystem in " + initTime + "ms"); + // Register Graphics API + GraphicsSubsystem.getInstance().registerGraphicsApi(this); } /** {@inheritDoc} */ diff --git a/settings.gradle b/settings.gradle index f357d6bf..f6c60818 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,11 +17,10 @@ * along with this program. If not, see . */ -rootProject.name = 'sosengine' +rootProject.name = "sosengine" -include 'base' -include 'slf4j-compat' -include 'graphics' -include 'graphics:opengl' -include 'graphics:vulkan' -include 'testapp' +include "base" +include "slf4j-compat" +include "graphics" +include "graphics:opengl" +include "graphics:vulkan" diff --git a/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/Slf4jCompatibilitySubsystem.java b/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/Slf4jCompatibilitySubsystem.java index 98196d87..7d8f1f4e 100644 --- a/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/Slf4jCompatibilitySubsystem.java +++ b/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/Slf4jCompatibilitySubsystem.java @@ -28,7 +28,6 @@ import de.staropensource.sosengine.base.logging.LoggerInstance; import de.staropensource.sosengine.base.types.CodePart; import de.staropensource.sosengine.base.types.DependencyVector; import de.staropensource.sosengine.base.types.logging.LogIssuer; -import de.staropensource.sosengine.base.utility.Miscellaneous; import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.slf4j.LoggerFactory; @@ -71,12 +70,17 @@ public class Slf4jCompatibilitySubsystem implements SubsystemMainClass { } } + /** {@inheritDoc} */ + @NotNull + @Override + public String getName() { + return "slf4j-compat"; + } + /** {@inheritDoc} */ @Override public void initializeSubsystem() { - logger.verb("Initialized subsystem in " + - Miscellaneous.measureExecutionTime(() -> LoggerFactory.getLogger(CompatibilityLogger.class).debug("If you see this then the SLF4J Compatibility Subsystem is working!")) - + "ms"); + LoggerFactory.getLogger(CompatibilityLogger.class).debug("If you see this then the SLF4J Compatibility Subsystem is working!"); } /** {@inheritDoc} */ diff --git a/testapp/build.gradle b/testapp/build.gradle index 5ebee838..45d01437 100644 --- a/testapp/build.gradle +++ b/testapp/build.gradle @@ -42,8 +42,8 @@ dependencies { implementation(project(":base")) implementation(project(":slf4j-compat")) implementation(project(":graphics")) - implementation project(":graphics:vulkan") - implementation project(":graphics:opengl") + implementation(project(":graphics:vulkan")) + implementation(project(":graphics:opengl")) implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why }