-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9b3c85
commit ff84aac
Showing
20 changed files
with
195 additions
and
63 deletions.
There are no files selected for viewing
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 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
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
File renamed without changes.
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,59 @@ | ||
import { BaseInteractiveInputDriver } from '@plugins/types'; | ||
import { | ||
BaseInputConfig, | ||
InputDTO, | ||
} from '@shared/hardware-config/input-config/base-input-config'; | ||
import { SwitchConfig } from '@shared/hardware-config/input-config/switch-config'; | ||
import { XYConfig } from '@shared/hardware-config/input-config/xy-config'; | ||
|
||
import { Registry } from './registry'; | ||
|
||
/** | ||
* Similar to a simple input registry, but includes an additional registry | ||
* to store temporary references to configs. This is useful when a device | ||
* receives a message from a Switch or XY input, because those child configs | ||
* (switch steps or x-axis/y-axis configs) are stored here. | ||
* | ||
* Also guarantees that child configs won't be serialized with the rest of | ||
* the project. | ||
*/ | ||
export class InputRegistryWithSubregistry extends Registry< | ||
InputDTO, | ||
BaseInputConfig | ||
> { | ||
/** | ||
* Stores the child configs of XY and Switch configs. | ||
*/ | ||
InputSubregistry = new Registry<InputDTO, BaseInputConfig>(); | ||
|
||
/** | ||
* Tries to return the requested item from its class' own store. If undefined, | ||
* tries to return the requested item from the subregistry. | ||
*/ | ||
public get< | ||
U extends BaseInputConfig< | ||
InputDTO, | ||
BaseInteractiveInputDriver | ||
> = BaseInputConfig<InputDTO, BaseInteractiveInputDriver> | ||
>(id: string): U | undefined { | ||
return super.get(id) || this.InputSubregistry.get(id); | ||
} | ||
|
||
public register( | ||
key: string, | ||
item: BaseInputConfig<InputDTO, BaseInteractiveInputDriver> | ||
): void { | ||
super.register(key, item); | ||
|
||
if (item instanceof SwitchConfig) { | ||
item.steps.forEach((s) => { | ||
this.InputSubregistry.register(s.qualifiedId, s); | ||
}); | ||
} | ||
|
||
if (item instanceof XYConfig) { | ||
this.InputSubregistry.register(item.x.qualifiedId, item.x); | ||
this.InputSubregistry.register(item.y.qualifiedId, item.y); | ||
} | ||
} | ||
} |
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,7 @@ | ||
import { InputRegistryWithSubregistry } from './input-registry-with-subregistry'; | ||
|
||
/** | ||
* Normalized store of `InputConfig`s. Objects must be stored and retrieved | ||
* using the qualifiedId of inputConfigs. | ||
*/ | ||
export const InputRegistry = new InputRegistryWithSubregistry(); |
2 changes: 1 addition & 1 deletion
2
src/main/plugin-registry.ts → src/main/registry/plugin-registry.ts
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { BasePlugin, PluginDTO } from '../plugins/core/base-plugin'; | ||
import type { BasePlugin, PluginDTO } from '../../plugins/core/base-plugin'; | ||
import { Registry } from './registry'; | ||
|
||
export const PluginRegistry = new Registry<PluginDTO, BasePlugin>(); |
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
Oops, something went wrong.