Move alltests plugin to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / linuxtools / tmf / core / component / TmfComponent.java
CommitLineData
8c8bf09f 1/*******************************************************************************
d91063d0 2 * Copyright (c) 2009, 2014 Ericsson
5500a7f0 3 *
8c8bf09f
ASL
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
5500a7f0 8 *
8c8bf09f
ASL
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
d91063d0 11 * Bernd Hufmann - Add interface for broadcasting signals asynchronously
8c8bf09f
ASL
12 *******************************************************************************/
13
6c13869b 14package org.eclipse.linuxtools.tmf.core.component;
8c8bf09f 15
5500a7f0 16import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
6c13869b
FC
17import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
18import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
8c8bf09f
ASL
19
20/**
e31e01e8
FC
21 * This is the base class of the TMF components.
22 * <p>
8fd82db5
FC
23 * Currently, it only addresses the inter-component signaling.
24 *
25 * @version 1.0
26 * @author Francois Chouinard
8c8bf09f
ASL
27 */
28public abstract class TmfComponent implements ITmfComponent {
29
00641a97
FC
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
11252342 34 private String fName;
5500a7f0 35
11252342
AM
36 // ------------------------------------------------------------------------
37 // Constructor
38 // ------------------------------------------------------------------------
e31e01e8 39
8fd82db5
FC
40 /**
41 * Default constructor. To be used in conjunction with init()
42 */
12c155f5 43 public TmfComponent() {
11252342 44 this(""); //$NON-NLS-1$
12c155f5
FC
45 }
46
8fd82db5
FC
47 /**
48 * Perform component initialization and register it as a signal listener.
49 * Need to be called when the default constructor was used.
5500a7f0 50 *
11252342
AM
51 * @param name
52 * the component name
8fd82db5 53 */
12c155f5 54 public void init(String name) {
5500a7f0 55 TmfCoreTracer.traceComponent(this, "created"); //$NON-NLS-1$
12c155f5
FC
56 fName = name;
57 TmfSignalManager.register(this);
58 }
59
11252342
AM
60 /**
61 * The standard constructor
62 *
63 * @param name
64 * the component name
65 */
66 public TmfComponent(String name) {
67 init(name);
68 }
69
70 /**
71 * The copy constructor
72 *
73 * @param other
74 * the other component
75 */
76 public TmfComponent(TmfComponent other) {
00641a97 77 init(other.fName);
11252342 78 }
5500a7f0 79
00641a97 80 // ------------------------------------------------------------------------
8fd82db5 81 // Getters/setters
00641a97
FC
82 // ------------------------------------------------------------------------
83
8fd82db5
FC
84 @Override
85 public String getName() {
86 return fName;
87 }
88
11252342
AM
89 /**
90 * @param name
91 * the new component name
92 */
93 protected void setName(String name) {
94 fName = name;
95 }
96
97 // ------------------------------------------------------------------------
98 // ITmfComponent
99 // ------------------------------------------------------------------------
100
101 @Override
102 public void dispose() {
103 TmfSignalManager.deregister(this);
104 TmfCoreTracer.traceComponent(this, "disposed"); //$NON-NLS-1$
105 }
106
107 @Override
108 public void broadcast(TmfSignal signal) {
109 TmfSignalManager.dispatchSignal(signal);
110 }
e31e01e8 111
d91063d0
BH
112 /**
113 * @since 3.0
114 */
115 @Override
116 public void broadcastAsync(TmfSignal signal) {
117 TmfSignalManager.dispatchSignalAsync(signal);
118 }
8c8bf09f 119}
This page took 0.067187 seconds and 5 git commands to generate.