Browse Source

Implemented "wrapped" system driver concept.

woollybah 7 years ago
parent
commit
fd7a542d4d
1 changed files with 12 additions and 1 deletions
  1. 12 1
      system.mod/driver.bmx

+ 12 - 1
system.mod/driver.bmx

@@ -30,6 +30,11 @@ Type TSystemDriver
 
 End Type
 
+Interface IWrappedSystemDriver
+	Method SetDriver(driver:TSystemDriver)
+	Method GetDriver:TSystemDriver()
+End Interface
+
 Private
 Global _Driver:TSystemDriver
 Public
@@ -39,7 +44,13 @@ bbdoc: Initialises the BlitzMax system driver.
 about: There can only be one system driver initialised. A second call to this function will result in an exception.
 End Rem
 Function InitSystemDriver(driver:TSystemDriver)
-	If _Driver Throw "Cannot initialise " + driver.ToString() + ". System driver already configured as " + _Driver.ToString()
+	If _Driver Then
+		If IWrappedSystemDriver(driver) Then
+			IWrappedSystemDriver(driver).SetDriver(_Driver)
+		Else
+			Throw "Cannot initialise " + driver.ToString() + ". System driver already configured as " + _Driver.ToString()
+		End If
+	End If
 	_Driver = driver
 End Function