Commit | Line | Data |
---|---|---|
8c8bf09f | 1 | /******************************************************************************* |
e31e01e8 | 2 | * Copyright (c) 2009, 2010 Ericsson |
8c8bf09f ASL |
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 | ||
6c13869b | 13 | package org.eclipse.linuxtools.tmf.core.component; |
8c8bf09f | 14 | |
6c13869b FC |
15 | import org.eclipse.linuxtools.tmf.core.signal.TmfSignal; |
16 | import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager; | |
8c8bf09f ASL |
17 | |
18 | /** | |
e31e01e8 FC |
19 | * This is the base class of the TMF components. |
20 | * <p> | |
8fd82db5 FC |
21 | * Currently, it only addresses the inter-component signaling. |
22 | * | |
23 | * @version 1.0 | |
24 | * @author Francois Chouinard | |
8c8bf09f ASL |
25 | */ |
26 | public abstract class TmfComponent implements ITmfComponent { | |
27 | ||
00641a97 FC |
28 | // ------------------------------------------------------------------------ |
29 | // Attributes | |
30 | // ------------------------------------------------------------------------ | |
31 | ||
ce785d7d | 32 | private String fName; |
fc6ccf6f | 33 | |
e31e01e8 FC |
34 | // ------------------------------------------------------------------------ |
35 | // Constructor | |
36 | // ------------------------------------------------------------------------ | |
37 | ||
8fd82db5 FC |
38 | /** |
39 | * Default constructor. To be used in conjunction with init() | |
40 | */ | |
12c155f5 | 41 | public TmfComponent() { |
73005152 | 42 | this(""); //$NON-NLS-1$ |
12c155f5 FC |
43 | } |
44 | ||
8fd82db5 FC |
45 | /** |
46 | * Perform component initialization and register it as a signal listener. | |
47 | * Need to be called when the default constructor was used. | |
48 | * | |
49 | * @param name the component name | |
50 | */ | |
12c155f5 FC |
51 | public void init(String name) { |
52 | fName = name; | |
53 | TmfSignalManager.register(this); | |
54 | } | |
55 | ||
8fd82db5 FC |
56 | /** |
57 | * The standard constructor | |
58 | * | |
59 | * @param name the component name | |
60 | */ | |
fc6ccf6f | 61 | public TmfComponent(String name) { |
00641a97 | 62 | init(name); |
e31e01e8 | 63 | } |
377f1ad8 | 64 | |
8fd82db5 FC |
65 | /** |
66 | * The copy constructor | |
67 | * | |
68 | * @param other the other component | |
69 | */ | |
00641a97 FC |
70 | public TmfComponent(TmfComponent other) { |
71 | init(other.fName); | |
377f1ad8 WB |
72 | } |
73 | ||
00641a97 | 74 | // ------------------------------------------------------------------------ |
8fd82db5 | 75 | // Getters/setters |
00641a97 FC |
76 | // ------------------------------------------------------------------------ |
77 | ||
8fd82db5 FC |
78 | /* (non-Javadoc) |
79 | * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#getName() | |
80 | */ | |
81 | @Override | |
82 | public String getName() { | |
83 | return fName; | |
84 | } | |
85 | ||
86 | /** | |
87 | * @param name the new component name | |
88 | */ | |
ce785d7d FC |
89 | protected void setName(String name) { |
90 | fName = name; | |
91 | } | |
92 | ||
e31e01e8 FC |
93 | // ------------------------------------------------------------------------ |
94 | // ITmfComponent | |
95 | // ------------------------------------------------------------------------ | |
96 | ||
8fd82db5 FC |
97 | /* (non-Javadoc) |
98 | * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#dispose() | |
99 | */ | |
d4011df2 | 100 | @Override |
2fb2eb37 | 101 | public void dispose() { |
e31e01e8 | 102 | TmfSignalManager.deregister(this); |
9b635e61 | 103 | // if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "terminated"); |
8c8bf09f ASL |
104 | } |
105 | ||
8fd82db5 FC |
106 | /* (non-Javadoc) |
107 | * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#broadcast(org.eclipse.linuxtools.tmf.core.signal.TmfSignal) | |
108 | */ | |
d4011df2 | 109 | @Override |
e31e01e8 | 110 | public void broadcast(TmfSignal signal) { |
8d2e2848 FC |
111 | TmfSignalManager.dispatchSignal(signal); |
112 | } | |
e31e01e8 | 113 | |
8c8bf09f | 114 | } |