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