Fix bug when tracefile is not aligned. Now supports exotic architectures.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / SequenceDeclaration.java
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
13 package org.eclipse.linuxtools.ctf.core.event.types;
14
15 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
16
17 /**
18 * <b><u>SequenceDeclaration</u></b>
19 */
20 public class SequenceDeclaration implements IDeclaration {
21
22 // ------------------------------------------------------------------------
23 // Attributes
24 // ------------------------------------------------------------------------
25
26 private final IDeclaration elemType;
27 private final String lengthName;
28
29 // ------------------------------------------------------------------------
30 // Constructors
31 // ------------------------------------------------------------------------
32
33 public SequenceDeclaration(String lengthName, IDeclaration elemType) {
34 this.elemType = elemType;
35 this.lengthName = lengthName;
36 }
37
38 // ------------------------------------------------------------------------
39 // Gettters/Setters/Predicates
40 // ------------------------------------------------------------------------
41
42 public IDeclaration getElementType() {
43 return elemType;
44 }
45
46 public String getLengthName() {
47 return lengthName;
48 }
49
50 @Override
51 public long getAlignment() {
52 return getElementType().getAlignment();
53 }
54 // ------------------------------------------------------------------------
55 // Operations
56 // ------------------------------------------------------------------------
57
58 @Override
59 public SequenceDefinition createDefinition(
60 IDefinitionScope definitionScope, String fieldName) {
61 SequenceDefinition ret = null;
62 try {
63 ret = new SequenceDefinition(this, definitionScope, fieldName);
64 } catch (CTFReaderException e) {
65 // Temporarily catch this here, eventually this should be thrown
66 // up the call stack
67 e.printStackTrace();
68 }
69 return ret;
70 }
71
72 @Override
73 public String toString() {
74 /* Only used for debugging */
75 return "[declaration] sequence[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
76 }
77
78 }
This page took 0.039526 seconds and 5 git commands to generate.