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 | |
bcec0116 | 31 | * @since 3.0 |
f9a76cac AM |
32 | */ |
33 | public class NullBackend implements IStateHistoryBackend { | |
34 | ||
b2f62cb5 AM |
35 | private final @NonNull String ssid; |
36 | ||
f9a76cac AM |
37 | /** |
38 | * Constructor | |
b2f62cb5 AM |
39 | * |
40 | * @param ssid | |
41 | * The state system's id | |
f9a76cac | 42 | */ |
b2f62cb5 AM |
43 | public NullBackend(@NonNull String ssid) { |
44 | this.ssid = ssid; | |
45 | } | |
46 | ||
47 | @Override | |
48 | public String getSSID() { | |
49 | return ssid; | |
50 | } | |
f9a76cac AM |
51 | |
52 | @Override | |
53 | public long getStartTime() { | |
54 | return 0; | |
55 | } | |
56 | ||
57 | @Override | |
58 | public long getEndTime() { | |
59 | return 0; | |
60 | } | |
61 | ||
62 | /** | |
63 | * The interval will be discarded when using a null backend. | |
64 | */ | |
65 | @Override | |
66 | public void insertPastState(long stateStartTime, long stateEndTime, | |
67 | int quark, ITmfStateValue value) { | |
68 | /* The interval is always discarded. */ | |
69 | } | |
70 | ||
71 | @Override | |
72 | public void finishedBuilding(long endTime) { | |
73 | /* Nothing to do */ | |
74 | } | |
75 | ||
76 | @Override | |
77 | public FileInputStream supplyAttributeTreeReader() { | |
78 | return null; | |
79 | } | |
80 | ||
81 | @Override | |
82 | public File supplyAttributeTreeWriterFile() { | |
83 | return null; | |
84 | } | |
85 | ||
86 | @Override | |
87 | public long supplyAttributeTreeWriterFilePosition() { | |
88 | return -1; | |
89 | } | |
90 | ||
91 | @Override | |
92 | public void removeFiles() { | |
93 | /* Nothing to do */ | |
94 | } | |
95 | ||
96 | @Override | |
97 | public void dispose() { | |
98 | /* Nothing to do */ | |
99 | } | |
100 | ||
101 | /** | |
102 | * Null back-ends cannot run queries. Nothing will be put in | |
103 | * currentStateInfo. | |
104 | */ | |
105 | @Override | |
106 | public void doQuery(List<ITmfStateInterval> currentStateInfo, long t) { | |
107 | /* Cannot do past queries */ | |
108 | } | |
109 | ||
110 | /** | |
111 | * Null back-ends cannot run queries. 'null' will be returned. | |
112 | * | |
113 | * @return Always returns null. | |
114 | */ | |
115 | @Override | |
116 | public ITmfStateInterval doSingularQuery(long t, int attributeQuark) { | |
117 | /* Cannot do past queries */ | |
118 | return null; | |
119 | } | |
120 | ||
f9a76cac AM |
121 | @Override |
122 | public void debugPrint(PrintWriter writer) { | |
123 | writer.println("Null history backend"); //$NON-NLS-1$ | |
124 | } | |
125 | } |