1/* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import {Timestamp} from 'common/time'; 18import {ParserTimestampConverter} from 'common/timestamp_converter'; 19import {CoarseVersion} from 'trace/coarse_version'; 20import { 21 CustomQueryParserResultTypeMap, 22 CustomQueryType, 23} from 'trace/custom_query'; 24import {AbsoluteEntryIndex, EntriesRange} from 'trace/index_types'; 25import {Parser} from 'trace/parser'; 26import {TraceType} from 'trace/trace_type'; 27 28export abstract class AbstractTracesParser<T> implements Parser<T> { 29 protected timestamps: Timestamp[] | undefined; 30 protected timestampConverter: ParserTimestampConverter; 31 32 constructor(timestampConverter: ParserTimestampConverter) { 33 this.timestampConverter = timestampConverter; 34 } 35 36 customQuery<Q extends CustomQueryType>( 37 type: Q, 38 entriesRange: EntriesRange, 39 ): Promise<CustomQueryParserResultTypeMap[Q]> { 40 throw new Error('Not implemented'); 41 } 42 43 getTimestamps(): Timestamp[] | undefined { 44 return this.timestamps; 45 } 46 47 abstract getCoarseVersion(): CoarseVersion; 48 abstract parse(): Promise<void>; 49 abstract createTimestamps(): Promise<void>; 50 abstract getDescriptors(): string[]; 51 abstract getTraceType(): TraceType; 52 abstract getEntry(index: AbsoluteEntryIndex): Promise<T>; 53 abstract getLengthEntries(): number; 54 abstract getRealToMonotonicTimeOffsetNs(): bigint | undefined; 55 abstract getRealToBootTimeOffsetNs(): bigint | undefined; 56} 57