Skip to content
Snippets Groups Projects
Commit adbe74d6 authored by David Trattnig's avatar David Trattnig
Browse files

Engine as singleton. #43 #44

parent f8bd8fd3
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,7 @@ class Engine(): ...@@ -44,6 +44,7 @@ class Engine():
""" """
The Engine. The Engine.
""" """
instance = None
engine_time_offset = 0.0 engine_time_offset = 0.0
logger = None logger = None
...@@ -68,6 +69,9 @@ class Engine(): ...@@ -68,6 +69,9 @@ class Engine():
Args: Args:
config (AuraConfig): The configuration config (AuraConfig): The configuration
""" """
if Engine.instance:
raise Exception("Engine is already running!")
Engine.instance = self
self.config = config self.config = config
self.plugins = dict() self.plugins = dict()
self.logger = logging.getLogger("AuraEngine") self.logger = logging.getLogger("AuraEngine")
...@@ -178,6 +182,14 @@ class Engine(): ...@@ -178,6 +182,14 @@ class Engine():
return SU.timestamp() + Engine.engine_time_offset return SU.timestamp() + Engine.engine_time_offset
@staticmethod
def get_instance():
"""
Returns the one and only engine.
"""
return Engine.instance
def terminate(self): def terminate(self):
""" """
Terminates the engine and all related processes. Terminates the engine and all related processes.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment