1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.ctf
.core
.event
.types
.composite
;
15 import java
.util
.List
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.tracecompass
.ctf
.core
.event
.scope
.ILexicalScope
;
19 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.Declaration
;
20 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.Definition
;
21 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.ICompositeDefinition
;
22 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.IEventHeaderDeclaration
;
23 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.IntegerDeclaration
;
24 import org
.eclipse
.tracecompass
.ctf
.core
.event
.types
.IntegerDefinition
;
26 import com
.google
.common
.collect
.ImmutableList
;
29 * An event header definition, as shown in the example of the CTF spec examples
32 * @author Matthew Khouzam
34 public final class EventHeaderDefinition
extends Definition
implements ICompositeDefinition
{
36 private static final @NonNull List
<String
> FIELD_NAMES
= ImmutableList
.of(
37 IEventHeaderDeclaration
.ID
,
38 IEventHeaderDeclaration
.TIMESTAMP
41 private final int fId
;
42 private final long fTimestamp
;
43 private final int fTimestampLength
;
46 * Event header defintion
52 * @param eventHeaderDecl
53 * The declaration of this defintion
54 * @param timestampLength
55 * the number of bits valid in the timestamp
57 public EventHeaderDefinition(@NonNull Declaration eventHeaderDecl
, int id
, long timestamp
, int timestampLength
) {
58 super(eventHeaderDecl
, null, ILexicalScope
.EVENT_HEADER
.getPath(), ILexicalScope
.EVENT_HEADER
);
60 fTimestamp
= timestamp
;
61 fTimestampLength
= timestampLength
;
65 * Gets the timestamp declaration
67 * @return the timestamp declaration
69 public int getTimestampLength() {
70 return fTimestampLength
;
76 * @return the event id
85 * @return the timestamp
87 public long getTimestamp() {
92 public Definition
getDefinition(String fieldName
) {
93 if (fieldName
.equals(IEventHeaderDeclaration
.ID
)) {
94 return new IntegerDefinition(IntegerDeclaration
.INT_32B_DECL
, null, IEventHeaderDeclaration
.ID
, getId());
95 } else if (fieldName
.equals(IEventHeaderDeclaration
.TIMESTAMP
)) {
96 return new IntegerDefinition(IntegerDeclaration
.INT_64B_DECL
, null, IEventHeaderDeclaration
.TIMESTAMP
, getTimestamp());
102 public @NonNull List
<String
> getFieldNames() {