-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from MechDancer/teardown
Support removing components from scope
- Loading branch information
Showing
16 changed files
with
265 additions
and
97 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/org/mechdancer/dependency/DependencyHandler.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.mechdancer.dependency | ||
|
||
/** | ||
* Events of a [DynamicScope] | ||
*/ | ||
sealed interface ScopeEvent { | ||
/** | ||
* A new component was added to the scope | ||
*/ | ||
@JvmInline | ||
value class DependencyArrivedEvent(val dependency: Component) : ScopeEvent | ||
|
||
/** | ||
* A component was removed from the scope | ||
*/ | ||
@JvmInline | ||
value class DependencyLeftEvent(val dependency: Component) : ScopeEvent | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/org/mechdancer/dependency/ScopeEventHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.mechdancer.dependency | ||
|
||
/** | ||
* [ScopeEventHandler] handles [ScopeEvent] | ||
*/ | ||
interface ScopeEventHandler { | ||
/** | ||
* Handle a [scopeEvent] | ||
*/ | ||
fun handle(scopeEvent: ScopeEvent) | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/org/mechdancer/dependency/TeardownStrictDependencyException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.mechdancer.dependency | ||
|
||
/** | ||
* [TeardownStrictDependencyException] is the exception indicates that | ||
* a component which was depended on strictly was being removed from the scope | ||
*/ | ||
class TeardownStrictDependencyException( | ||
toRemove: Component, | ||
dependency: TypeSafeDependency.Dependency<*> | ||
) : RuntimeException("Cannot teardown $toRemove from scope, $dependency depends strictly on this") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.