Commit | Line | Data |
---|---|---|
f9a76cac | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2013, 2014 Ericsson |
f9a76cac AM |
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 | * Alexandre Montplaisir - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
e894a508 | 13 | package org.eclipse.tracecompass.statesystem.core.backend; |
f9a76cac AM |
14 | |
15 | import java.io.File; | |
16 | import java.io.FileInputStream; | |
17 | import java.io.PrintWriter; | |
18 | import java.util.List; | |
19 | ||
b2f62cb5 | 20 | import org.eclipse.jdt.annotation.NonNull; |
e894a508 AM |
21 | import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; |
22 | import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; | |
f9a76cac AM |
23 | |
24 | /** | |
25 | * An implement of a state history back-end to simply discards *all* the | |
26 | * intervals it receives. Obviously, no queries can be done on it. It is useful | |
cb42195c AM |
27 | * for using with a StateSystem on which you will only want to do "ongoing" |
28 | * requests. | |
f9a76cac AM |
29 | * |
30 | * @author Alexandre Montplaisir | |
31 | */ | |
32 | public class NullBackend implements IStateHistoryBackend { | |
33 | ||
b2f62cb5 AM |
34 | private final @NonNull String ssid; |
35 | ||
f9a76cac AM |
36 | /** |
37 | * Constructor | |
b2f62cb5 AM |
38 | * |
39 | * @param ssid | |
40 | * The state system's id | |
f9a76cac | 41 | */ |
b2f62cb5 AM |
42 | public NullBackend(@NonNull String ssid) { |
43 | this.ssid = ssid; | |
44 | } | |
45 | ||
46 | @Override | |
47 | public String getSSID() { | |
48 | return ssid; | |
49 | } | |
f9a76cac AM |
50 | |
51 | @Override | |
52 | public long getStartTime() { | |
53 | return 0; | |
54 | } | |
55 | ||
56 | @Override | |
57 | public long getEndTime() { | |
58 | return 0; | |
59 | } | |
60 | ||
61 | /** | |
62 | * The interval will be discarded when using a null backend. | |
63 | */ | |
64 | @Override | |
65 | public void insertPastState(long stateStartTime, long stateEndTime, | |
66 | int quark, ITmfStateValue value) { | |
67 | /* The interval is always discarded. */ | |
68 | } | |
69 | ||
70 | @Override | |
71 | public void finishedBuilding(long endTime) { | |
72 | /* Nothing to do */ | |
73 | } | |
74 | ||
75 | @Override | |
76 | public FileInputStream supplyAttributeTreeReader() { | |
77 | return null; | |
78 | } | |
79 | ||
80 | @Override | |
81 | public File supplyAttributeTreeWriterFile() { | |
82 | return null; | |
83 | } | |
84 | ||
85 | @Override | |
86 | public long supplyAttributeTreeWriterFilePosition() { | |
87 | return -1; | |
88 | } | |
89 | ||
90 | @Override | |
91 | public void removeFiles() { | |
92 | /* Nothing to do */ | |
93 | } | |
94 | ||
95 | @Override | |
96 | public void dispose() { | |
97 | /* Nothing to do */ | |
98 | } | |
99 | ||
100 | /** | |
101 | * Null back-ends cannot run queries. Nothing will be put in | |
102 | * currentStateInfo. | |
103 | */ | |
104 | @Override | |
105 | public void doQuery(List<ITmfStateInterval> currentStateInfo, long t) { | |
106 | /* Cannot do past queries */ | |
107 | } | |
108 | ||
109 | /** | |
110 | * Null back-ends cannot run queries. 'null' will be returned. | |
111 | * | |
112 | * @return Always returns null. | |
113 | */ | |
114 | @Override | |
115 | public ITmfStateInterval doSingularQuery(long t, int attributeQuark) { | |
116 | /* Cannot do past queries */ | |
117 | return null; | |
118 | } | |
119 | ||
f9a76cac AM |
120 | @Override |
121 | public void debugPrint(PrintWriter writer) { | |
122 | writer.println("Null history backend"); //$NON-NLS-1$ | |
123 | } | |
124 | } |