modelling

This commit is contained in:
2020-05-04 20:04:38 +02:00
parent 373635f0db
commit 3838c8c978
7 changed files with 43 additions and 52 deletions

View File

@ -0,0 +1,21 @@
export abstract class Assignable {
protected data: Record<string, unknown> = {};
public assign (da: Assignable): void {
this.assign_object (da.get_data ());
}
public assign_to (da: Assignable): void {
da.assign (this);
}
public assign_object (obj: Record<string, unknown>): void {
for (const key of Object.keys (obj))
this.data[key] = obj[key];
}
public get_data (): Record<string, unknown> {
return this.data;
}
}

View File

@ -1,6 +0,0 @@
export interface DataApply {
apply(da: DataApply): void;
apply_object(obj: Record<string, unknown>): void;
apply_to(da: DataApply): void;
get_data(): Record<string, unknown>;
}

View File

@ -0,0 +1,7 @@
export interface Serializable {
serialize(): string;
}
export interface Deserializable {
deserialize(str: string): Serializable;
}

View File

@ -1,3 +1,2 @@
export { DataApply } from './DataApply';
export { Serializable } from './Serializable';
export { Graphable } from './Graphable';
export { Assignable } from './Assignable';
export { Serializable, Deserializable } from './Serializable';