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