Add annotation and new method for subsystems

This commit is contained in:
JeremyStar™ 2024-06-29 22:17:17 +02:00
parent 4793d7aefe
commit aa5b196fb3
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
6 changed files with 70 additions and 0 deletions

View file

@ -19,10 +19,12 @@
package de.staropensource.sosengine.base;
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
import de.staropensource.sosengine.base.classes.SubsystemMainClass;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.sosengine.base.events.EngineCrashEvent;
import de.staropensource.sosengine.base.events.EngineShutdownEvent;
import de.staropensource.sosengine.base.events.LogEvent;
@ -49,6 +51,7 @@ import java.util.Map;
* @since 1-alpha0
*/
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
@EngineSubsystem
public final class Engine implements SubsystemMainClass {
/**
* Instance.
@ -74,6 +77,20 @@ public final class Engine implements SubsystemMainClass {
@NotNull
private LoggerInstance logger;
/**
* Contains a list of all registered subsystems.
*
* @since 1-alpha1
*
* -- GETTER --
* Returns a list of all registered subsystems.
*
* @since 1-alpha1
*/
@NotNull
@Getter
private ImmutableMap<@NotNull Class<? extends SubsystemMainClass>, @NotNull DependencyVector> subsystems = new ImmutableMap<>();
/**
* Indicates if the engine is shutting down.
*

View file

@ -23,6 +23,7 @@ import de.staropensource.sosengine.base.Engine;
import de.staropensource.sosengine.base.annotations.EventListener;
import de.staropensource.sosengine.base.events.internal.InternalEngineShutdownEvent;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.types.DependencyVector;
/**
* The interface for engine subsystem main classes.
@ -39,6 +40,14 @@ public interface SubsystemMainClass {
*/
LoggerInstance logger = null;
/**
* Returns the {@link DependencyVector} for this subsystem.
*
* @see DependencyVector
* @since 1-alpha1
*/
DependencyVector getDependencyVector();
/**
* Called when the engine shuts down.
*

View file

@ -19,12 +19,16 @@
package de.staropensource.sosengine.graphics.opengl;
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
import de.staropensource.sosengine.base.annotations.EventListener;
import de.staropensource.sosengine.base.classes.events.EventPriority;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
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.utility.Miscellaneous;
import de.staropensource.sosengine.graphics.GraphicsSubsystem;
import de.staropensource.sosengine.graphics.classes.ApiMainClass;
@ -43,6 +47,7 @@ import static org.lwjgl.glfw.GLFW.*;
* @since 1-alpha0
*/
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
@EngineSubsystem
public final class OpenGlSubsystem implements ApiMainClass {
/**
* Instance.
@ -187,4 +192,10 @@ public final class OpenGlSubsystem implements ApiMainClass {
logger.info("Shut down in " + shutdownTime + "ms");
}
/** {@inheritDoc} */
@Override
public DependencyVector getDependencyVector() {
return new DependencyVector("opengl", StarOpenSourceVersioningSystem.class, EngineInformation.getInstance().getVersioningString());
}
}

View file

@ -19,14 +19,18 @@
package de.staropensource.sosengine.graphics;
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
import de.staropensource.sosengine.base.annotations.EventListener;
import de.staropensource.sosengine.base.classes.SubsystemMainClass;
import de.staropensource.sosengine.base.classes.events.EventPriority;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.sosengine.base.events.internal.InternalEngineShutdownEvent;
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.utility.ListFormatter;
import de.staropensource.sosengine.base.utility.Miscellaneous;
import de.staropensource.sosengine.graphics.classes.ApiMainClass;
@ -46,6 +50,7 @@ import java.util.Map;
* @since 1-alpha0
*/
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
@EngineSubsystem
public final class GraphicsSubsystem implements SubsystemMainClass {
/**
* Instance.
@ -140,6 +145,12 @@ public final class GraphicsSubsystem implements SubsystemMainClass {
EventHelper.precomputeEventListeners(GraphicsErrorEvent.class);
}
/** {@inheritDoc} */
@Override
public DependencyVector getDependencyVector() {
return new DependencyVector("graphics", StarOpenSourceVersioningSystem.class, EngineInformation.getInstance().getVersioningString());
}
/**
* Shuts the subsystem down.
*

View file

@ -19,11 +19,15 @@
package de.staropensource.sosengine.graphics.vulkan;
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
import de.staropensource.sosengine.base.annotations.EventListener;
import de.staropensource.sosengine.base.classes.events.EventPriority;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
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.utility.Miscellaneous;
import de.staropensource.sosengine.graphics.GraphicsSubsystem;
import de.staropensource.sosengine.graphics.classes.ApiMainClass;
@ -40,6 +44,7 @@ import static org.lwjgl.glfw.GLFW.*;
* @since 1-alpha0
*/
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
@EngineSubsystem
public final class VulkanSubsystem implements ApiMainClass {
/**
* Instance.
@ -162,4 +167,10 @@ public final class VulkanSubsystem implements ApiMainClass {
logger.info("Shut down in " + shutdownTime + "ms");
}
/** {@inheritDoc} */
@Override
public DependencyVector getDependencyVector() {
return new DependencyVector("vulkan", StarOpenSourceVersioningSystem.class, EngineInformation.getInstance().getVersioningString());
}
}

View file

@ -19,11 +19,15 @@
package de.staropensource.sosengine.slf4j_compat;
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
import de.staropensource.sosengine.base.classes.SubsystemMainClass;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import de.staropensource.sosengine.base.data.info.EngineInformation;
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
import de.staropensource.sosengine.base.events.LogEvent;
import de.staropensource.sosengine.base.logging.LoggerInstance;
import de.staropensource.sosengine.base.types.CodePart;
import de.staropensource.sosengine.base.types.DependencyVector;
import lombok.Getter;
import org.slf4j.LoggerFactory;
@ -34,6 +38,7 @@ import org.slf4j.LoggerFactory;
* @since 1-alpha0
*/
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
@EngineSubsystem
public class Slf4jCompatibilitySubsystem implements SubsystemMainClass {
/**
* Instance.
@ -67,4 +72,10 @@ public class Slf4jCompatibilitySubsystem implements SubsystemMainClass {
LoggerFactory.getLogger(CompatibilityLogger.class).debug("If you see this then the SLF4J Compatibility Subsystem is working!");
logger.info("Initialized subsystem");
}
/** {@inheritDoc} */
@Override
public DependencyVector getDependencyVector() {
return new DependencyVector("slf4j-compat", StarOpenSourceVersioningSystem.class, EngineInformation.getInstance().getVersioningString());
}
}