More javadoc updates
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / ctf / core / event / types / Definition.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
ce2388e0 15import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
866e5b51
FC
16
17/**
d37aaa7f
FC
18 * A CTF definiton
19 *
20 * A definition is like an object of a declaration class. It fills the declaration
21 * with values. <br>
9ac2eb62
MK
22 * An example: <br>
23 * int i = 0; <br>
24 * <b>int</b> is the declaration.<br>
25 * <b>i</b> is the definition.<br>
26 * <b>0</b> is the value assigned to the definition, not the declaration.<br>
27 *
d37aaa7f
FC
28 * @version 1.0
29 * @author Matthew Khouzam
30 * @author Simon Marchi
866e5b51
FC
31 */
32public abstract class Definition {
33
34 // ------------------------------------------------------------------------
35 // Attributes
36 // ------------------------------------------------------------------------
37
07002e0a 38 /** The name of the field in its container */
866e5b51
FC
39 protected final String fieldName;
40
07002e0a 41 /** The complete path of this field */
866e5b51
FC
42 protected final String path;
43
07002e0a 44 /**
866e5b51
FC
45 * The definition scope in which this definition is found.
46 *
47 * The complete path of a definition is thus the path of the definition
48 * scope DOT the name of the definition (name of the field in its container)
49 */
50 protected final IDefinitionScope definitionScope;
51
52 // ------------------------------------------------------------------------
53 // Constructors
54 // ------------------------------------------------------------------------
55
9ac2eb62
MK
56 /**
57 * Constructor
58 *
59 * @param definitionScope
60 * the definition is in a scope, (normally a struct) what is it?
61 * @param fieldName
62 * the name of the definition. (it is a field in the parent
63 * scope)
64 */
866e5b51
FC
65 public Definition(IDefinitionScope definitionScope, String fieldName) {
66 this.definitionScope = definitionScope;
67 this.fieldName = fieldName;
68 if (definitionScope != null) {
69 String parentPath = definitionScope.getPath();
70 if (parentPath.length() > 0) {
71 path = parentPath + "." + fieldName; //$NON-NLS-1$
72 } else {
73 path = fieldName;
74 }
75 } else {
76 path = fieldName;
77 }
78
79 /*
80 * System.out.println("[definition] " + this.getClass().getSimpleName()
81 * + " " + path + " created");
82 */
83 }
84
85 // ------------------------------------------------------------------------
86 // Operations
87 // ------------------------------------------------------------------------
88
9ac2eb62
MK
89 /**
90 *
91 * @return gets the declaration of a datatype
92 *
93 */
94 public abstract IDeclaration getDeclaration();
95
96 /**
97 * Read the definition from a bitbuffer
98 *
99 * @param input
100 * the bitbuffer containing the data to read.
101 */
866e5b51
FC
102 public abstract void read(BitBuffer input);
103
104 @Override
105 public String toString() {
106 return path + '[' + Integer.toHexString(hashCode()) + ']';
107 }
108}
This page took 0.030028 seconds and 5 git commands to generate.