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