[TMF] Optimize TimeGraphControl.drawState() method.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / component / TmfComponent.java
... / ...
CommitLineData
1/*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made 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:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.core.component;
14
15import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
16import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
17import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
18
19/**
20 * This is the base class of the TMF components.
21 * <p>
22 * Currently, it only addresses the inter-component signaling.
23 *
24 * @version 1.0
25 * @author Francois Chouinard
26 */
27public abstract class TmfComponent implements ITmfComponent {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32
33 private String fName;
34
35 // ------------------------------------------------------------------------
36 // Constructor
37 // ------------------------------------------------------------------------
38
39 /**
40 * Default constructor. To be used in conjunction with init()
41 */
42 public TmfComponent() {
43 this(""); //$NON-NLS-1$
44 }
45
46 /**
47 * Perform component initialization and register it as a signal listener.
48 * Need to be called when the default constructor was used.
49 *
50 * @param name
51 * the component name
52 */
53 public void init(String name) {
54 TmfCoreTracer.traceComponent(this, "created"); //$NON-NLS-1$
55 fName = name;
56 TmfSignalManager.register(this);
57 }
58
59 /**
60 * The standard constructor
61 *
62 * @param name
63 * the component name
64 */
65 public TmfComponent(String name) {
66 init(name);
67 }
68
69 /**
70 * The copy constructor
71 *
72 * @param other
73 * the other component
74 */
75 public TmfComponent(TmfComponent other) {
76 init(other.fName);
77 }
78
79 // ------------------------------------------------------------------------
80 // Getters/setters
81 // ------------------------------------------------------------------------
82
83 @Override
84 public String getName() {
85 return fName;
86 }
87
88 /**
89 * @param name
90 * the new component name
91 */
92 protected void setName(String name) {
93 fName = name;
94 }
95
96 // ------------------------------------------------------------------------
97 // ITmfComponent
98 // ------------------------------------------------------------------------
99
100 @Override
101 public void dispose() {
102 TmfSignalManager.deregister(this);
103 TmfCoreTracer.traceComponent(this, "disposed"); //$NON-NLS-1$
104 }
105
106 @Override
107 public void broadcast(TmfSignal signal) {
108 TmfSignalManager.dispatchSignal(signal);
109 }
110
111}
This page took 0.024383 seconds and 5 git commands to generate.