Commit | Line | Data |
---|---|---|
8c8bf09f | 1 | /******************************************************************************* |
11252342 | 2 | * Copyright (c) 2009, 2013 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 | ||
11252342 | 33 | private String fName; |
5500a7f0 | 34 | |
11252342 AM |
35 | // ------------------------------------------------------------------------ |
36 | // Constructor | |
37 | // ------------------------------------------------------------------------ | |
e31e01e8 | 38 | |
8fd82db5 FC |
39 | /** |
40 | * Default constructor. To be used in conjunction with init() | |
41 | */ | |
12c155f5 | 42 | public TmfComponent() { |
11252342 | 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 | * |
11252342 AM |
50 | * @param name |
51 | * the component name | |
8fd82db5 | 52 | */ |
12c155f5 | 53 | public void init(String name) { |
5500a7f0 | 54 | TmfCoreTracer.traceComponent(this, "created"); //$NON-NLS-1$ |
12c155f5 FC |
55 | fName = name; |
56 | TmfSignalManager.register(this); | |
57 | } | |
58 | ||
11252342 AM |
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) { | |
00641a97 | 76 | init(other.fName); |
11252342 | 77 | } |
5500a7f0 | 78 | |
00641a97 | 79 | // ------------------------------------------------------------------------ |
8fd82db5 | 80 | // Getters/setters |
00641a97 FC |
81 | // ------------------------------------------------------------------------ |
82 | ||
8fd82db5 FC |
83 | @Override |
84 | public String getName() { | |
85 | return fName; | |
86 | } | |
87 | ||
11252342 AM |
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 | } | |
e31e01e8 | 110 | |
8c8bf09f | 111 | } |