Files
diplomarbeit-code/lib/src/aasStore.ts
T
2023-10-16 12:55:31 +02:00

36 lines
1.0 KiB
TypeScript

import { types } from "@aas-core-works/aas-core3.0rc02-typescript";
export class AASStore {
private static instance: AASStore;
private shells: Array<types.AssetAdministrationShell> = [];
private constructor() { }
public static getInstance(): AASStore {
if (!AASStore.instance) {
AASStore.instance = new AASStore();
}
return AASStore.instance;
}
public addAAS(aas: types.AssetAdministrationShell | types.Environment): void {
if (aas instanceof types.Environment) {
if (aas.assetAdministrationShells) this.shells = this.shells.concat(aas.assetAdministrationShells);
} else {
this.shells.push(aas);
}
}
public getAAS(id: string): types.AssetAdministrationShell | undefined {
return this.shells.find((aas) => aas.id === id);
}
public removeAAS(id: string): void {
this.shells = this.shells.filter((aas) => aas.id !== id);
}
public getAll(): Array<types.AssetAdministrationShell> {
return this.shells;
}
}