Commit | Line | Data |
---|---|---|
8c8bf09f ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 Ericsson | |
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 | ||
9aae0442 | 15 | import org.eclipse.linuxtools.tmf.Tracer; |
8c8bf09f ASL |
16 | import org.eclipse.linuxtools.tmf.signal.TmfSignal; |
17 | import org.eclipse.linuxtools.tmf.signal.TmfSignalManager; | |
18 | ||
19 | /** | |
20 | * <b><u>TmfComponent</u></b> | |
21 | * <p> | |
22 | * This is the base class of the TMF components. | |
23 | * <p> | |
24 | * Currently, it only addresses the inter-component signaling. | |
25 | */ | |
26 | public abstract class TmfComponent implements ITmfComponent { | |
27 | ||
28 | private String fName; | |
29 | ||
30 | // ------------------------------------------------------------------------ | |
31 | // Constructor | |
32 | // ------------------------------------------------------------------------ | |
33 | ||
34 | public TmfComponent(String name) { | |
35 | fName = name; | |
9aae0442 | 36 | if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "created"); |
8c8bf09f ASL |
37 | TmfSignalManager.register(this); |
38 | } | |
39 | ||
40 | public TmfComponent(TmfComponent oldComponent) { | |
41 | this.fName = oldComponent.fName; | |
42 | ||
43 | // Should we register? Probably not but I'm not quite sure what this does | |
44 | //register(); | |
45 | } | |
46 | ||
47 | /* (non-Javadoc) | |
48 | * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#getName() | |
49 | */ | |
50 | protected void setName(String name) { | |
51 | fName = name; | |
52 | } | |
53 | ||
54 | // ------------------------------------------------------------------------ | |
55 | // ITmfComponent | |
56 | // ------------------------------------------------------------------------ | |
57 | ||
58 | /* (non-Javadoc) | |
59 | * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#getName() | |
60 | */ | |
61 | public String getName() { | |
62 | return fName; | |
63 | } | |
64 | ||
65 | /* (non-Javadoc) | |
66 | * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#dispose() | |
67 | */ | |
68 | public void dispose() { | |
69 | TmfSignalManager.deregister(this); | |
9aae0442 | 70 | if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "terminated"); |
8c8bf09f ASL |
71 | } |
72 | ||
73 | /* (non-Javadoc) | |
74 | * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#broadcast(org.eclipse.linuxtools.tmf.signal.TmfSignal) | |
75 | */ | |
76 | public void broadcast(TmfSignal signal) { | |
77 | TmfSignalManager.dispatchSignal(signal); | |
78 | } | |
79 | ||
80 | } |