blob: 8c380b2cd9c4b1540bebe75edb3aa0aa11df7086 [file] [log] [blame]
Adrià Vilanova Martínez5dd7a6f2023-03-04 18:32:27 +01001import ThreadModel from './Thread.js';
2
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +01003export default class GapModel {
Adrià Vilanova Martínez5dd7a6f2023-03-04 18:32:27 +01004 constructor(data, thread) {
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +01005 this.data = data ?? {};
Adrià Vilanova Martínez5dd7a6f2023-03-04 18:32:27 +01006 this.thread = thread ?? new ThreadModel();
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +01007 }
8
9 getCount() {
10 const a = this.data[1] ?? null;
11 return a != null ? a : 0;
12 }
13
14 setCount(value) {
15 this.data[1] = Number(value);
16 }
17
18 getStartMicroseconds() {
19 return this.data[2] ?? null;
20 }
21
22 setStartMicroseconds(value) {
23 this.data[2] = '' + value;
24 }
25
26 getStartTimestamp() {
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +010027 let a = this.getStartMicroseconds();
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +010028 if (a == null) a = '0';
29 return BigInt(a);
30 }
31
32 getEndMicroseconds() {
33 return this.data[3] ?? null;
34 }
35
36 setEndMicroseconds(value) {
37 this.data[3] = '' + value;
38 }
39
40 getEndTimestamp() {
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +010041 let a = this.getEndMicroseconds();
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +010042 if (a == null) a = '0';
43 return BigInt(a);
44 }
45
46 getParentId() {
47 const a = this.data[4];
48 return a ? Number(a) : 0;
49 }
50
51 setParentId(value) {
52 this.data[4] = '' + value;
53 }
54
55 toRawMessageOrGap() {
56 return {2: this.data};
57 }
58}