ctf: Move CTF plugins to Java 7 and fix warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / SequenceDeclaration.java
CommitLineData
866e5b51
FC
1/*******************************************************************************
2 * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
3 *
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
8 *
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.ctf.core.event.types;
14
2feb8414
AM
15import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
16
866e5b51 17/**
d37aaa7f
FC
18 * A CTF sequence declaration.
19 *
9ac2eb62
MK
20 * An array where the size is fixed but declared in the trace, unlike array
21 * where it is declared with a literal
d37aaa7f
FC
22 *
23 * @version 1.0
24 * @author Matthew Khouzam
25 * @author Simon Marchi
866e5b51
FC
26 */
27public class SequenceDeclaration implements IDeclaration {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32
33 private final IDeclaration elemType;
34 private final String lengthName;
35
36 // ------------------------------------------------------------------------
37 // Constructors
38 // ------------------------------------------------------------------------
39
9ac2eb62 40 /**
be6df2d8 41 * Constructor
9ac2eb62
MK
42 *
43 * @param lengthName
be6df2d8 44 * the name of the field describing the length
9ac2eb62 45 * @param elemType
be6df2d8 46 * The element type
9ac2eb62 47 */
866e5b51
FC
48 public SequenceDeclaration(String lengthName, IDeclaration elemType) {
49 this.elemType = elemType;
50 this.lengthName = lengthName;
51 }
52
53 // ------------------------------------------------------------------------
be6df2d8 54 // Getters/Setters/Predicates
866e5b51
FC
55 // ------------------------------------------------------------------------
56
9ac2eb62
MK
57 /**
58 * Gets the element type
59 * @return the element type
60 */
866e5b51
FC
61 public IDeclaration getElementType() {
62 return elemType;
63 }
64
9ac2eb62
MK
65 /**
66 * Gets the name of the length field
67 * @return the name of the length field
68 */
866e5b51
FC
69 public String getLengthName() {
70 return lengthName;
71 }
72
fd74e6c1
MK
73 @Override
74 public long getAlignment() {
75 return getElementType().getAlignment();
76 }
9ac2eb62 77
866e5b51
FC
78 // ------------------------------------------------------------------------
79 // Operations
80 // ------------------------------------------------------------------------
81
82 @Override
83 public SequenceDefinition createDefinition(
84 IDefinitionScope definitionScope, String fieldName) {
2feb8414
AM
85 SequenceDefinition ret = null;
86 try {
87 ret = new SequenceDefinition(this, definitionScope, fieldName);
88 } catch (CTFReaderException e) {
89 // Temporarily catch this here, eventually this should be thrown
90 // up the call stack
91 e.printStackTrace();
92 }
93 return ret;
866e5b51
FC
94 }
95
96 @Override
97 public String toString() {
98 /* Only used for debugging */
99 return "[declaration] sequence[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
100 }
101
102}
This page took 0.037014 seconds and 5 git commands to generate.