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 | ||
13 | package org.eclipse.linuxtools.tmf.component; | |
14 | ||
8d2e2848 | 15 | import org.eclipse.linuxtools.tmf.signal.TmfSignal; |
8c8bf09f ASL |
16 | import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; |
17 | ||
18 | /** | |
19 | * <b><u>TmfComponent</u></b> | |
20 | * <p> | |
e31e01e8 FC |
21 | * This is the base class of the TMF components. |
22 | * <p> | |
23 | * Currently, it only addresses the inter-component signaling. | |
8c8bf09f ASL |
24 | */ |
25 | public abstract class TmfComponent implements ITmfComponent { | |
26 | ||
00641a97 FC |
27 | // ------------------------------------------------------------------------ |
28 | // Attributes | |
29 | // ------------------------------------------------------------------------ | |
30 | ||
ce785d7d | 31 | private String fName; |
fc6ccf6f | 32 | |
e31e01e8 FC |
33 | // ------------------------------------------------------------------------ |
34 | // Constructor | |
35 | // ------------------------------------------------------------------------ | |
36 | ||
12c155f5 | 37 | public TmfComponent() { |
73005152 | 38 | this(""); //$NON-NLS-1$ |
12c155f5 FC |
39 | } |
40 | ||
41 | public void init(String name) { | |
42 | fName = name; | |
43 | TmfSignalManager.register(this); | |
44 | } | |
45 | ||
fc6ccf6f | 46 | public TmfComponent(String name) { |
00641a97 | 47 | init(name); |
e31e01e8 | 48 | } |
377f1ad8 | 49 | |
00641a97 FC |
50 | public TmfComponent(TmfComponent other) { |
51 | init(other.fName); | |
377f1ad8 WB |
52 | } |
53 | ||
00641a97 FC |
54 | // ------------------------------------------------------------------------ |
55 | // Accessors | |
56 | // ------------------------------------------------------------------------ | |
57 | ||
ce785d7d FC |
58 | protected void setName(String name) { |
59 | fName = name; | |
60 | } | |
61 | ||
e31e01e8 FC |
62 | // ------------------------------------------------------------------------ |
63 | // ITmfComponent | |
64 | // ------------------------------------------------------------------------ | |
65 | ||
d4011df2 | 66 | @Override |
2fb2eb37 FC |
67 | public String getName() { |
68 | return fName; | |
8c8bf09f ASL |
69 | } |
70 | ||
d4011df2 | 71 | @Override |
2fb2eb37 | 72 | public void dispose() { |
e31e01e8 | 73 | TmfSignalManager.deregister(this); |
9b635e61 | 74 | // if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "terminated"); |
8c8bf09f ASL |
75 | } |
76 | ||
d4011df2 | 77 | @Override |
e31e01e8 | 78 | public void broadcast(TmfSignal signal) { |
8d2e2848 FC |
79 | TmfSignalManager.dispatchSignal(signal); |
80 | } | |
e31e01e8 | 81 | |
8c8bf09f | 82 | } |